curl -X POST https://ninja.new/v0/api/task \
-H "Authorization: Bearer nsk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Find the top 3 competitors of Shopify",
"model": "smart"
}'
curl -X POST https://ninja.new/v0/api/task \
-H "Authorization: Bearer nsk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Research the EU market for standing desks",
"model": "smart",
"maxCredits": 500
}'
curl -X POST https://ninja.new/v0/api/task \
-H "Authorization: Bearer nsk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Find the top 3 competitors of Shopify and their estimated annual revenue",
"model": "smart",
"resultSchema": {
"type": "object",
"properties": {
"competitors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"estimatedAnnualRevenue": { "type": "string" }
},
"required": ["name", "estimatedAnnualRevenue"]
}
}
},
"required": ["competitors"]
}
}'
{
"taskId": "550e8400-e29b-41d4-a716-446655440000",
"status": "pending"
}
Ninja API
Create a task
Submit a prompt to Ninja and start execution in the background. Returns immediately with a task ID and a pending status you can poll.
POST
/
v0
/
api
/
task
curl -X POST https://ninja.new/v0/api/task \
-H "Authorization: Bearer nsk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Find the top 3 competitors of Shopify",
"model": "smart"
}'
curl -X POST https://ninja.new/v0/api/task \
-H "Authorization: Bearer nsk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Research the EU market for standing desks",
"model": "smart",
"maxCredits": 500
}'
curl -X POST https://ninja.new/v0/api/task \
-H "Authorization: Bearer nsk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Find the top 3 competitors of Shopify and their estimated annual revenue",
"model": "smart",
"resultSchema": {
"type": "object",
"properties": {
"competitors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"estimatedAnnualRevenue": { "type": "string" }
},
"required": ["name", "estimatedAnnualRevenue"]
}
}
},
"required": ["competitors"]
}
}'
{
"taskId": "550e8400-e29b-41d4-a716-446655440000",
"status": "pending"
}
Creates a new task and starts execution in the background. Returns immediately with a
Example:
taskId and pending status.
Request parameters
string
required
The task prompt. Must be between 1 and 16,000 characters.
string
default:"smart"
The LLM model to use.
| Value | Description |
|---|---|
fast | Fastest and cheapest. Best for simple tasks. |
smart | Balanced speed and quality. (default) |
super-smart | Most capable. Best for complex reasoning. |
object
Optional JSON Schema for structured output. When provided, the
result field in the response will be a JSON object conforming to this schema. Must follow the supported schema
format. Maximum 5 KB when serialized.integer
default:"1000"
Hard credit ceiling for the task. If the task spends this many credits in a run without producing a result, it stops and the result returns
status: "failed" with an
error explaining the budget was exceeded. Use it to cap the cost of open-ended prompts. Must be a positive integer. When omitted, it defaults to 1000 credits, so an API task is never unbounded.Response fields
string
required
UUID of the created task. Use this to poll for results via the get task result endpoint.
string
required
Always
pending for newly created tasks.curl -X POST https://ninja.new/v0/api/task \
-H "Authorization: Bearer nsk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Find the top 3 competitors of Shopify",
"model": "smart"
}'
curl -X POST https://ninja.new/v0/api/task \
-H "Authorization: Bearer nsk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Research the EU market for standing desks",
"model": "smart",
"maxCredits": 500
}'
curl -X POST https://ninja.new/v0/api/task \
-H "Authorization: Bearer nsk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Find the top 3 competitors of Shopify and their estimated annual revenue",
"model": "smart",
"resultSchema": {
"type": "object",
"properties": {
"competitors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": { "type": "string" },
"estimatedAnnualRevenue": { "type": "string" }
},
"required": ["name", "estimatedAnnualRevenue"]
}
}
},
"required": ["competitors"]
}
}'
{
"taskId": "550e8400-e29b-41d4-a716-446655440000",
"status": "pending"
}
Result schema format
TheresultSchema field must be a valid JSON Schema. The following features are not supported:
oneOf,anyOf,not,if/then/else- Numerical constraints (
minimum,maximum,multipleOf) - String length constraints (
minLength,maxLength) - Array length constraints (
minItems,maxItems) - Type arrays (e.g.
"type": ["string", "null"])
object, array, string, number, integer, boolean
The schema is validated at request time. An invalid schema returns
400 Bad Request.{
"type": "object",
"properties": {
"summary": { "type": "string" },
"score": { "type": "number" }
},
"required": ["summary", "score"]
}
Was this page helpful?