TypeScript SDK
import { NinjaChat } from "@ninjachat/sdk";
const client = new NinjaChat({ apiKey: process.env.NINJACHAT_API_KEY! });
const response = await client.responses.create({
model: "ninja/auto",
input: "Explain the key tradeoffs in one paragraph.",
});
console.log(response.output_text);import os
from ninjachat import NinjaChat
client = NinjaChat(api_key=os.environ["NINJACHAT_API_KEY"])
response = client.responses.create(
model="ninja/auto",
input="Explain the key tradeoffs in one paragraph.",
)
print(response["output_text"])curl --request POST \
--url https://www.ninjachat.ai/api/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": "<string>",
"text": {
"format": {
"type": "text"
}
}
}
'{
"id": "<string>",
"object": "response",
"created_at": 123,
"status": "completed",
"error": null,
"incomplete_details": {
"reason": "max_output_tokens"
},
"instructions": "<string>",
"max_output_tokens": 123,
"model": "<string>",
"output": [
{
"id": "<string>",
"type": "reasoning",
"status": "completed",
"summary": [
{
"type": "summary_text",
"text": "<string>"
}
]
}
],
"output_text": "<string>",
"parallel_tool_calls": true,
"previous_response_id": null,
"store": false,
"usage": {
"input_tokens": 1,
"input_tokens_details": {
"cached_tokens": 1,
"cache_creation_tokens": 1
},
"output_tokens": 1,
"output_tokens_details": {
"reasoning_tokens": 1
},
"total_tokens": 1
},
"cost_usd": 1,
"provider": "<string>",
"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": [
{}
]
}
},
"metadata": {}
}{
"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>"
}
}Text
Create a stateless response
OpenAI Responses-compatible text, vision, structured-output, and function-calling API. Set stream=true for typed lifecycle events.
POST
/
responses
TypeScript SDK
import { NinjaChat } from "@ninjachat/sdk";
const client = new NinjaChat({ apiKey: process.env.NINJACHAT_API_KEY! });
const response = await client.responses.create({
model: "ninja/auto",
input: "Explain the key tradeoffs in one paragraph.",
});
console.log(response.output_text);import os
from ninjachat import NinjaChat
client = NinjaChat(api_key=os.environ["NINJACHAT_API_KEY"])
response = client.responses.create(
model="ninja/auto",
input="Explain the key tradeoffs in one paragraph.",
)
print(response["output_text"])curl --request POST \
--url https://www.ninjachat.ai/api/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input": "<string>",
"text": {
"format": {
"type": "text"
}
}
}
'{
"id": "<string>",
"object": "response",
"created_at": 123,
"status": "completed",
"error": null,
"incomplete_details": {
"reason": "max_output_tokens"
},
"instructions": "<string>",
"max_output_tokens": 123,
"model": "<string>",
"output": [
{
"id": "<string>",
"type": "reasoning",
"status": "completed",
"summary": [
{
"type": "summary_text",
"text": "<string>"
}
]
}
],
"output_text": "<string>",
"parallel_tool_calls": true,
"previous_response_id": null,
"store": false,
"usage": {
"input_tokens": 1,
"input_tokens_details": {
"cached_tokens": 1,
"cache_creation_tokens": 1
},
"output_tokens": 1,
"output_tokens_details": {
"reasoning_tokens": 1
},
"total_tokens": 1
},
"cost_usd": 1,
"provider": "<string>",
"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": [
{}
]
}
},
"metadata": {}
}{
"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
Minimum string length:
1Required string length:
1 - 160Required array length:
1 - 15 elementsRequired string length:
1 - 160Maximum completion tokens, including reasoning where the provider counts it. Must fit the selected provider's output and context limits. Defaults to 2048 when omitted.
Required range:
x <= 9007199254740991Required range:
0 <= x <= 2Required range:
0 <= x <= 1Available options:
false Show child attributes
Show child attributes
Available options:
none, auto, required Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Maximum string length:
256Response
Completed response or SSE stream.
Available options:
response Available options:
completed, incomplete Show child attributes
Show child attributes
Required string length:
1 - 160- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
Available options:
false Show child attributes
Show child attributes
Required range:
x >= 0Show child attributes
Show child attributes
Show child attributes
Show child attributes