curl https://api.naga.ac/v1/chat/completions \
-H "Authorization: Bearer $NAGA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Say hello in one word."
}
]
}'import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["NAGA_API_KEY"],
base_url="https://api.naga.ac/v1",
)
result = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Say hello in one word."
}
],
)
print(result)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.NAGA_API_KEY,
baseURL: "https://api.naga.ac/v1",
});
const result = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Say hello in one word."
}
],
});
console.log(result);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.naga.ac/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4o-mini\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Say hello in one word.\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "chatcmpl-6Zq1s8bF2wKcT4mN",
"object": "chat.completion",
"created": 1774000000,
"model": "gpt-4o-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello",
"refusal": null
},
"finish_reason": "stop",
"logprobs": null
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 1,
"total_tokens": 19,
"prompt_tokens_details": {
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0
}
}
}Create a chat completion
Creates a model response in the OpenAI Chat Completions dialect and charges the account for the tokens it used. Requires an API key. /v1/responses and /v1/messages serve the same models in the other two dialects.
curl https://api.naga.ac/v1/chat/completions \
-H "Authorization: Bearer $NAGA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Say hello in one word."
}
]
}'import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["NAGA_API_KEY"],
base_url="https://api.naga.ac/v1",
)
result = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Say hello in one word."
}
],
)
print(result)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.NAGA_API_KEY,
baseURL: "https://api.naga.ac/v1",
});
const result = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Say hello in one word."
}
],
});
console.log(result);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.naga.ac/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4o-mini\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Say hello in one word.\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"id": "chatcmpl-6Zq1s8bF2wKcT4mN",
"object": "chat.completion",
"created": 1774000000,
"model": "gpt-4o-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello",
"refusal": null
},
"finish_reason": "stop",
"logprobs": null
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 1,
"total_tokens": 19,
"prompt_tokens_details": {
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0
}
}
}Authorizations
An account API key. Send it as Authorization: Bearer <key>.
Headers
The routing strategy when the body names none. An unknown name is ignored. A NagaAI extension. The order in which NagaAI tries the providers that serve a model. A NagaAI extension.
reliability, balanced, latency, throughput, cache Body
The OpenAI-compatible Chat Completions request. The gateway takes an unrecognized key and drops it.
The model to run, named by an id or alias from NagaAI's catalog. An entry without the chat.completions capability draws a refusal.
The conversation so far, oldest first; one entry at least.
1Hide child attributes
Hide child attributes
Who the message is from.
The contents of the message. Optional only on an assistant message.
One entry of a message's content. The role decides which kinds it admits.
Image references carried beside content. A NagaAI extension.
Hide child attributes
Hide child attributes
The image reference and its detail level.
The tag that selects this branch: type is image_url.
image_url The token that continues this image on a later turn.
Which vocabulary the token is written in.
Reasoning items of an earlier assistant turn, echoed back. A NagaAI extension that wins over reasoning_content.
One entry of a message's reasoning_details. A NagaAI extension.
- Option 1
- Option 2
- Option 3
Hide child attributes
Hide child attributes
The recap text.
The tag that selects this branch: type is reasoning.summary.
reasoning.summary An identifier travelling with the entry, never routed onto a tool call.
Which model family's reasoning dialect produced the entry, as an open string.
Where the entry sits among the turn's reasoning entries. Answers only.
The plain-text reasoning of an earlier assistant turn. A NagaAI extension.
An alias of reasoning_content, read last of the three.
A name for the participant. The gateway drops it.
On a tool message, the id of the call it answers. Required there.
The tool calls an assistant made, echoed back so results can follow.
How NagaAI orders the providers for this request. It reorders them and never removes one. A NagaAI extension.
Hide child attributes
Hide child attributes
The strategy for this request. An unknown name draws a 400.
reliability, balanced, latency, throughput, cache The tools the model is allowed to call.
One entry of tools[], told apart by type.
- Option 1
- Option 2
Hide child attributes
Hide child attributes
The declaration itself — name, description and parameter schema.
Hide child attributes
Hide child attributes
The name the model calls the function by, never empty.
What the function does, written for the model to choose by.
Whether the model follows parameters exactly when filling the arguments.
The tag that selects this branch: type is function.
function The pre-tools function-calling surface. A request carrying it draws a refusal.
How much randomness goes into the reply, between 0 and 2, and an alternative to top_p.
0 <= x <= 2The sampling cut-off, between 0 and 1, and an alternative to temperature.
0 <= x <= 1Whether the reply arrives incrementally as the model writes it.
Strings that end generation the moment the model produces one.
The ceiling on generated tokens, reasoning included. At least 1.
x >= 1An alias of max_completion_tokens, read only when that key is absent.
x >= 1How much reasoning to spend before answering, from none to xhigh.
none, minimal, low, medium, high, xhigh How hard a token is penalized for having appeared, from -2 to 2.
-2 <= x <= 2How hard repetition is penalized, scaled by how often, from -2 to 2.
-2 <= x <= 2Whether the model may return several tool calls in one turn.
Content the reply is expected to reproduce, which the gateway drops.
Hide child attributes
Hide child attributes
An aspect ratio and a size for image output. A NagaAI extension the gateway drops.
Hide child attributes
Hide child attributes
Requested width-to-height ratio. Accepted and dropped; it reaches no provider.
1:1, 1:4, 1:8, 2:3, 3:2, 3:4, 4:1, 4:3, 4:5, 5:4, 8:1, 9:16, 16:9, 21:9 Requested resolution tier. Accepted and dropped; it reaches no provider.
1K, 2K, 4K Response
The completion. application/json carries one chat.completion object when stream is false; text/event-stream carries one chat.completion.chunk per event, then the data: [DONE] sentinel, when it is true.
- Option 1
- Option 2
The completion. The gateway answers a request it does not forward with the second shape, which omits logprobs and refusal.
This answer's identifier, repeated on every frame of a stream.
What kind of object this is. Always chat.completion.
"chat.completion"
When the answer was created, in seconds since the Unix epoch.
The model that answered, by its id in the NagaAI catalog.
The answers the model produced — one entry, see index.
Hide child attributes
Hide child attributes
This answer's position in choices[]. Always 0.
The message the model produced.
Hide child attributes
Hide child attributes
Who wrote the message. Always assistant.
"assistant"
The text the model returned, or null when the turn produced none.
The reason the model gave for declining, or null.
The model's reasoning as plain text. A NagaAI extension mirroring the first reasoning item only.
The turn's reasoning as structured entries, in the order the model produced them. A NagaAI extension.
The tool calls the model made, absent when it made none.
Hide child attributes
Hide child attributes
The call's id, repeated as tool_call_id on the answering message.
What kind of call this is. Always function.
"function"
Which function to call, and with what arguments.
The images the model generated. A NagaAI extension.
Hide child attributes
Hide child attributes
What kind of entry this is. Always image_url.
"image_url"
The token that continues this image on a later turn.
Which vocabulary the token is written in.
Why the model stopped, in one of four values.
"stop"
Always null. The gateway returns no token log probabilities.
What the request cost in tokens, absent when the provider reported none.
Hide child attributes
Hide child attributes
Tokens of the prompt, cached ones included.
Tokens the model generated, reasoning and image tokens included.
The provider's own total for the request, reported as received.
The split of prompt_tokens the provider reported.
Hide child attributes
Hide child attributes
The split of completion_tokens the provider reported.
Hide child attributes
Hide child attributes