Skip to main content
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"
  }'
{
  "taskId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "pending"
}
Creates a new task and starts execution in the background. Returns immediately with a taskId and pending status.

Request parameters

prompt
string
required
The task prompt. Must be between 1 and 16,000 characters.
model
string
default:"smart"
The LLM model to use.
ValueDescription
fastFastest and cheapest. Best for simple tasks.
smartBalanced speed and quality. (default)
super-smartMost capable. Best for complex reasoning.
resultSchema
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.

Response fields

taskId
string
required
UUID of the created task. Use this to poll for results via the get task result endpoint.
status
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"
  }'
{
  "taskId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "pending"
}

Result schema format

The resultSchema 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"])
Supported types: object, array, string, number, integer, boolean
The schema is validated at request time. An invalid schema returns 400 Bad Request.
Example:
{
  "type": "object",
  "properties": {
    "summary": { "type": "string" },
    "score": { "type": "number" }
  },
  "required": ["summary", "score"]
}