Ninja API
Create a task
Submit a prompt to Ninja and start execution in the background.
POST
Creates a new task and starts execution in the background. Returns immediately with a
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.
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.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
Example: