---
title: "Run a saved preset"
method: POST
path: "/presets/{slug}/chat/completions"
---

# Run a saved preset

`POST /presets/{slug}/chat/completions`

## Request

- Base URL: `https://www.ninjachat.ai/api/v1`
- URL: `https://www.ninjachat.ai/api/v1/presets/{slug}/chat/completions`
- Auth: HTTP bearer

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.

## Path parameters

- `slug` string, required

## Headers

- `Idempotency-Key` string

## Request body

- PresetChatCompletionsRequest
  - `model` string
  - `models` string[]
  - `messages` union[], required
    - union
      - object
        - `role` 'developer', required
        - `content` union, required
          - string
          - object[]
            - `type` 'text', required
            - `text` string, required
      - object
        - `role` 'system', required
        - `content` union, required
          - string
          - object[]
            - `type` 'text', required
            - `text` string, required
      - object
        - `role` 'user', required
        - `content` union, required
          - string
          - union[]
            - union
              - …
      - object
        - `role` 'assistant', required
        - `content` union
          - string
          - object[]
            - `type` 'text', required
            - `text` string, required
        - `tool_calls` object[]
          - `id` string, required
          - `type` 'function', required
          - `extra_content` object
            - `google` object
              - …
          - `function` object, required
            - `name` string, required
            - `arguments` string, required
      - object
        - `role` 'tool', required
        - `content` union, required
          - string
          - union[]
            - union
              - …
        - `tool_call_id` string, required
  - `max_completion_tokens` integer: Maximum completion tokens, including reasoning where the provider counts it. Must fit the selected provider's output and context limits. Defaults to 2048 when omitted.
  - `temperature` number
  - `top_p` number
  - `stop` union
    - string
    - string[]
  - `frequency_penalty` number
  - `presence_penalty` number
  - `seed` integer
  - `user` string
  - `stream` boolean
  - `stream_options` object
    - `include_usage` boolean
  - `response_format` union
    - object
      - `type` 'text', required
    - object
      - `type` 'json_object', required
    - object
      - `type` 'json_schema', required
      - `json_schema` object, required
        - `name` string, required
        - `description` string
        - `schema` object, required
        - `strict` boolean
  - `tools` object[]
    - `type` 'function', required
    - `function` object, required
      - `name` string, required
      - `description` string
      - `parameters` object
      - `strict` boolean
  - `tool_choice` union
    - 'none' | 'auto' | 'required'
    - object
      - `type` 'function', required
      - `function` object, required
        - `name` string, required
  - `parallel_tool_calls` boolean
  - `reasoning` ChatReasoning
    - `effort` 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
    - `max_tokens` integer
    - `enabled` boolean
  - `routing` RoutingPolicy
    - `strategy` 'balanced' | 'cost' | 'latency' | 'quality'
    - `providers` object
      - `only` string[]
      - `exclude` string[]
      - `order` string[]
    - `allow_fallbacks` boolean
    - `require_parameters` boolean
    - `data_policy` 'default' | 'no_training' | 'zero_retention'
    - `caching` 'auto'
    - `max_cost_usd` number

## Response `200`

Chat completion or SSE stream.

- ChatCompletionResponse
  - `cost` object
    - `this_request` string, required
    - `per_image` string
    - `per_video` string
    - `images` integer
  - `balance` string
  - `metadata` object
    - `latency_ms` number, required
    - `group` string
    - `search_depth` string
    - `results_count` integer
  - `id` string, required
  - `object` 'chat.completion', required
  - `created` integer, required
  - `model` string, required
  - `resolved_model` string, required
  - `provider` string, nullable, required
  - `choices` object[], required
    - `index` integer, required
    - `message` object, required
      - `role` 'assistant', required
      - `content` string, nullable, required
      - `reasoning_content` string
      - `tool_calls` object[]
        - `id` string, required
        - `type` 'function', required
        - `extra_content` object
          - `google` object
            - `thought_signature` string, required
        - `function` object, required
          - `name` string, required
          - `arguments` string, required
    - `finish_reason` string, nullable, required
  - `usage` ChatUsage, required
    - `prompt_tokens` integer, required
    - `completion_tokens` integer, required
    - `total_tokens` integer, required
    - `prompt_tokens_details` object
      - `cached_tokens` integer
      - `cache_creation_tokens` integer
    - `completion_tokens_details` object
      - `reasoning_tokens` integer
  - `cost_usd` number, required
  - `request_id` string, required
  - `routing` RoutingSummary, required
    - `strategy` 'balanced' | 'cost' | 'latency' | 'quality', required
    - `requested_models` string[], required
    - `resolved_model` string, required
    - `provider` string, nullable, required
    - `provider_attempts` ProviderAttemptReceipt[]
      - `provider` string, required
      - `outcome` 'served' | 'failed_over' | 'failed', required
      - `attempt_index` integer, required
    - `fallbacks_allowed` boolean, required
    - `data_policy` 'default' | 'no_training' | 'zero_retention', required
    - `caching` 'auto'
    - `source` 'request' | 'project' | 'default'
    - `router` RouterDecisionSummary
      - `id` 'ninja/auto', required
      - `task` string, required
      - `classified_by` 'regex' | 'llm' | 'llm-cached', required
      - `override` 'long_context' | 'multilingual', nullable, required
      - `reasoning` string, required
      - `candidates` string[], required
      - `considered` object[], required

## Other responses

- `400`: Invalid or unsupported request parameter.
- `401`: Missing or invalid API key.
- `402`: Insufficient balance or project spend limit reached.
- `404`: No active preset with that slug on this account.
- `429`: Rate limit exceeded.
- `500`: Gateway error.

---

[API](https://skmtc.dev/ninjachat/apis/ninjachat-api.md) · [All operations](https://skmtc.dev/ninjachat/apis/ninjachat-api/llms.txt) · [OpenAPI document](https://skmtc.dev/ninjachat/apis/ninjachat-api/revisions/fa7dfcbdcb03?raw)
