Skip to main content
Create a key, point the official OpenAI SDK at NagaAI and get an answer from a model in the catalog.
1

Create an API key

Open API Keys in the dashboard and select Create API Key. The dashboard shows the key once, so copy it before you close the window.Paid models need a balance of at least 0.05 credits. Top up on the Credits page, or replace claude-sonnet-5 in the code below with a model whose id ends in :free.
2

Save the key in your environment

The examples read the key from NAGA_API_KEY, so it stays out of your code.
3

Install the OpenAI SDK

4

Send a request

Point the SDK at https://api.naga.ac/v1 and run the code:
The model answers in one sentence:
The request goes to the Responses API. The SDK collects the answer text in output_text. In raw JSON, the text is the output_text part of the message item in output.

Troubleshooting

KeyError: 'NAGA_API_KEY' or a missing API key

The code runs in a shell where NAGA_API_KEY isn’t set. Run the export command from the second step in the same terminal, then run the code again.

401

The key is wrong, disabled or expired, or it is a provisioning key. Create an API key on the API Keys page.

402 insufficient_quota

The balance is too low for a paid model. Top up on the Credits page, or switch the code to a :free model.

400 model_not_found

The model id isn’t in the catalog. Copy the id from naga.ac/models. For any other status, see Errors. To keep your Chat Completions code or the Anthropic SDK instead, see Choose an API.