import { NinjaChat } from "@ninjachat/sdk";
const client = new NinjaChat({ apiKey: process.env.NINJACHAT_API_KEY! });
const completion = await client.chat.completions.create({
model: "@support",
messages: [{ role: "user", content: "Help me reset my workspace." }],
});import os
from ninjachat import NinjaChat
client = NinjaChat(api_key=os.environ["NINJACHAT_API_KEY"])
completion = client.chat.completions.create(
model="@support",
messages=[{"role": "user", "content": "Help me reset my workspace."}],
)curl --request POST \
--url https://www.ninjachat.ai/api/v1/presets/{slug}/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"role": "developer",
"content": "<string>"
}
]
}
'{
"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>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}Run a saved preset
Chat completion using a preset’s saved model, routing, system prompt, and parameters. Send only your messages; pass model/models to override the preset’s chain for this call. Response headers include X-Ninja-Preset and X-Ninja-Preset-Version.
import { NinjaChat } from "@ninjachat/sdk";
const client = new NinjaChat({ apiKey: process.env.NINJACHAT_API_KEY! });
const completion = await client.chat.completions.create({
model: "@support",
messages: [{ role: "user", content: "Help me reset my workspace." }],
});import os
from ninjachat import NinjaChat
client = NinjaChat(api_key=os.environ["NINJACHAT_API_KEY"])
completion = client.chat.completions.create(
model="@support",
messages=[{"role": "user", "content": "Help me reset my workspace."}],
)curl --request POST \
--url https://www.ninjachat.ai/api/v1/presets/{slug}/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"role": "developer",
"content": "<string>"
}
]
}
'{
"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>"
}
}{
"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.
1 - 255Path Parameters
Body
1- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
Show child attributes
Show child attributes
1 - 1601 - 15 elements1 - 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.
x <= 90071992547409910 <= x <= 20 <= x <= 1-2 <= x <= 2-2 <= x <= 2256Show child attributes
Show child attributes
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
Show child attributes
Show child attributes
none, auto, required Show child attributes
Show child attributes
Show child attributes
Show child attributes
Response
Chat completion or SSE stream.
chat.completion 1 - 1601 - 160Show child attributes
Show child attributes
Show child attributes
Show child attributes
x >= 0Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes