Create a chat completion (legacy path)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://www.ninjachat.ai/api/v1/chat', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://www.ninjachat.ai/api/v1/chat"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://www.ninjachat.ai/api/v1/chat \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'{
"id": "<string>",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"resolved_model": "<string>",
"provider": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "assistant",
"content": "<string>",
"reasoning_content": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
},
"extra_content": {
"google": {
"thought_signature": "<string>"
}
}
}
]
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 1,
"completion_tokens": 1,
"total_tokens": 1,
"prompt_tokens_details": {
"cached_tokens": 1,
"cache_creation_tokens": 1
},
"completion_tokens_details": {
"reasoning_tokens": 1
}
},
"cost_usd": 1,
"request_id": "<string>",
"routing": {
"strategy": "balanced",
"requested_models": [
"<string>"
],
"resolved_model": "<string>",
"provider": "<string>",
"fallbacks_allowed": true,
"data_policy": "default",
"provider_attempts": [
{
"provider": "<string>",
"outcome": "served",
"attempt_index": 1
}
],
"caching": "auto",
"source": "request",
"router": {
"id": "ninja/auto",
"task": "<string>",
"classified_by": "regex",
"override": "long_context",
"reasoning": "<string>",
"candidates": [
"<string>"
],
"considered": [
{}
]
}
},
"cost": {
"this_request": "<string>",
"per_image": "<string>",
"per_video": "<string>",
"images": 1
},
"balance": "<string>",
"metadata": {
"latency_ms": 1,
"group": "<string>",
"search_depth": "<string>",
"results_count": 1
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}Legacy (supported)
Create a chat completion (legacy path)
Supported compatibility surface — kept working indefinitely, but not the path for new integrations. Modern equivalent: POST /responses.
Backward-compatible path for /chat/completions, including historical field spellings and session memory.
POST
/
chat
Create a chat completion (legacy path)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://www.ninjachat.ai/api/v1/chat', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://www.ninjachat.ai/api/v1/chat"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)curl --request POST \
--url https://www.ninjachat.ai/api/v1/chat \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'{
"id": "<string>",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"resolved_model": "<string>",
"provider": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "assistant",
"content": "<string>",
"reasoning_content": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
},
"extra_content": {
"google": {
"thought_signature": "<string>"
}
}
}
]
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 1,
"completion_tokens": 1,
"total_tokens": 1,
"prompt_tokens_details": {
"cached_tokens": 1,
"cache_creation_tokens": 1
},
"completion_tokens_details": {
"reasoning_tokens": 1
}
},
"cost_usd": 1,
"request_id": "<string>",
"routing": {
"strategy": "balanced",
"requested_models": [
"<string>"
],
"resolved_model": "<string>",
"provider": "<string>",
"fallbacks_allowed": true,
"data_policy": "default",
"provider_attempts": [
{
"provider": "<string>",
"outcome": "served",
"attempt_index": 1
}
],
"caching": "auto",
"source": "request",
"router": {
"id": "ninja/auto",
"task": "<string>",
"classified_by": "regex",
"override": "long_context",
"reasoning": "<string>",
"candidates": [
"<string>"
],
"considered": [
{}
]
}
},
"cost": {
"this_request": "<string>",
"per_image": "<string>",
"per_video": "<string>",
"images": 1
},
"balance": "<string>",
"metadata": {
"latency_ms": 1,
"group": "<string>",
"search_depth": "<string>",
"results_count": 1
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}Authorizations
Use an API key created in the NinjaChat developer console.
Headers
Safely retry the same logical write without duplicate billing or execution.
Required string length:
1 - 255Body
application/json
The body is of type object.
Response
Chat completion or SSE stream.
Available options:
chat.completion Required string length:
1 - 160Required string length:
1 - 160Show child attributes
Show child attributes
Show child attributes
Show child attributes
Required range:
x >= 0Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes