> For the complete documentation index, see [llms.txt](https://docs.aimlapi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aimlapi.com/api-references/text-models-llm/ml-api/dynamic-router.md).

# Dynamic Router (LLM Router)

LLM router API: describe buckets in plain words, and each request goes to the model that fits it, by cost, topic or content safety. Chat, images and video.

{% columns %}
{% column width="66.66666666666666%" %}
{% hint style="info" %}
This documentation is valid for the following list of our models:

* `aimlapi/dynamic-router`
  {% endhint %}
  {% endcolumn %}

{% column width="33.33333333333334%" %} <a href="https://aimlapi.com/app/aimlapi/dynamic-router" class="button primary">Try in Playground</a>
{% endcolumn %}
{% endcolumns %}

## Model Overview

The Dynamic Router is an LLM router that you configure in each request. You describe up to ten buckets in your own words, each with the models to try in order. A decision model reads the request and picks the bucket whose description fits it best: routing by meaning, with nothing to train or host. The first model of that bucket that can take the request answers.

Use it to send easy requests to cheap models and hard ones to strong models, to keep sensitive content away from models whose providers forbid it, or as a classifier that tells your code where a request belongs.

<table data-header-hidden><thead><tr><th width="200"></th><th></th></tr></thead><tbody><tr><td><strong>Works on</strong></td><td>Chat Completions, the Responses API, the Messages API, image generation and editing, video generation</td></tr><tr><td><strong>Decision models</strong></td><td>TypeSafe Jev (the default) and Liquid AI's d1 family</td></tr><tr><td><strong>Price</strong></td><td>The model that answers, at its own rate, plus each judgement at the decision model's rate</td></tr><tr><td><strong>Without a <code>router</code></strong></td><td>Routes conversations by how much capability they need, like the <a href="https://docs.aimlapi.com/api-references/text-models-llm/ml-api/jev-router.md">Jev Router</a></td></tr></tbody></table>

{% hint style="success" %}
[Create AI/ML API Key](https://aimlapi.com/app/keys)
{% endhint %}

<details>

<summary>How to make the first API call</summary>

**1️⃣ Required setup (don’t skip this)**\
▪ **Create an account:** Sign up on the AI/ML API website (if you don’t have one yet).\
▪ **Generate an API key:** In your account dashboard, create an API key and make sure it’s **enabled** in the UI.

**2️ Copy the code example**\
At the bottom of this page, pick the snippet for your preferred programming language (Python / Node.js) and copy it into your project.

**3️ Update the snippet for your use case**\
▪ **Insert your API key:** replace `<YOUR_AIMLAPI_KEY>` with your real AI/ML API key.\
▪ **Select a model:** set the `model` field to the model you want to call.\
▪ **Provide input:** fill in the request input field(s) shown in the example.

**4️ (Optional) Tune the request**\
See the API schema below for optional generation settings.

**5️ Run your code**\
Run the updated code in your development environment.

{% hint style="success" %}
For a detailed walkthrough, use our [Quickstart guide](https://docs.aimlapi.com/quickstart/setting-up).
{% endhint %}

</details>

## How the LLM router works

1. You send a request with `"model": "aimlapi/dynamic-router"` and a `router` object that lists your buckets.
2. The decision model reads the request, images included, and picks the bucket whose `when` fits it best.
3. The bucket's models are tried in your order. The first one that can take the request answers. If it fails, the next one does.
4. The response says what happened. `meta.router` names the bucket and the reason, and `meta.model` names the model that answered.

Two shapes of bucket table change this:

* **A bucket with no models** (`"models": []`) ends the request at the decision. No model runs, the answer is empty, and `meta.router.routed` is `false`, so your code decides what to do. Only the judgement is charged.
* **A single bucket** is a plain fallback chain. Every request goes to it, nothing is judged, and nothing is charged for a judgement.

## API Schema

## POST /v1/chat/completions

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v1/chat/completions":{"post":{"operationId":"_v1_chat_completions","requestBody":{"required":true,"content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"model":{"type":"string","enum":["aimlapi/dynamic-router"]},"provider":{"type":"string","description":"Provider routing override. Use a source key such as `openai`, `opentree`, `xai`, `google`, `alibaba`, `minimax`, `moonshot`, `baidu`, or `togetherai` to run that provider with no fallback; `auto` (default) uses the full fallback chain. Case-insensitive."},"messages":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"role":{"type":"string","enum":["user"],"description":"The role of the author of the message — in this case, the user"},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["image_url"]},"image_url":{"type":"object","properties":{"url":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"}],"description":"Either a URL of the image or the base64 encoded image data. "},"detail":{"type":"string","enum":["low","high","auto"],"description":"Specifies the detail level of the image. Currently supports JPG/JPEG, PNG, GIF, and WEBP formats."}},"required":["url"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","image_url"]},{"type":"object","properties":{"type":{"type":"string","enum":["file"],"description":"The type of the content part."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]},"file":{"type":"object","properties":{"file_data":{"type":"string","description":"The file data, encoded in base64 and passed to the model as a string. Only PDF format is supported.\n        - Maximum size per file: Up to 512 MB and up to 2 million tokens.\n        - Maximum number of files: Up to 20 files can be attached to a single GPT application or Assistant. This limit applies throughout the application's lifetime.\n        - Maximum total file storage per user: 10 GB."},"file_id":{"type":"string"},"filename":{"type":"string","description":"The file name specified by the user. This name can be used to reference the file when interacting with the model, especially if multiple files are uploaded."}}}},"required":["type","file"]}]}}],"description":"The contents of the user message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the developer message."},"role":{"type":"string","enum":["developer"],"description":"The role of the author of the message — in this case, the developer."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["content","role"]},{"type":"object","properties":{"role":{"type":"string","enum":["system"],"description":"The role of the author of the message — in this case, the system."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the system message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the tool message."},"tool_call_id":{"type":"string","description":"Tool call that this message is responding to."},"name":{"type":"string","nullable":true,"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content","tool_call_id"]},{"type":"object","properties":{"role":{"type":"string","enum":["assistant"],"description":"The role of the author of the message — in this case, the Assistant."},"content":{"anyOf":[{"type":"string","description":"The contents of the Assistant message."},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"refusal":{"type":"string","description":"The refusal message generated by the model."},"type":{"type":"string","enum":["refusal"],"description":"The type of the content part."}},"required":["refusal","type"]}]},"description":"An array of content parts with a defined type. Can be one or more of type text, or exactly one of type refusal."},{"nullable":true}],"description":"The contents of the Assistant message. Required unless tool_calls or function_call is specified."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."},"tool_calls":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."},"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."}},"required":["name","arguments"],"description":"The function that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","function"]},{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool to call."},"input":{"type":"string","description":"The input for the custom tool call generated by the model."}},"required":["name","input"],"description":"The custom tool that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","custom"]}]},"description":"The tool calls generated by the model, such as function calls."},"refusal":{"type":"string","nullable":true,"description":"The refusal message by the Assistant."}},"required":["role"]}]},"description":"A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, documents (txt, pdf), images, and audio."},"max_tokens":{"type":"number","minimum":1,"description":"The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API."},"stream":{"type":"boolean","default":false,"description":"If set to True, the model response data will be streamed to the client as it is generated using server-sent events."},"stream_options":{"type":"object","properties":{"include_usage":{"type":"boolean"}},"required":["include_usage"]},"tools":{"type":"array","items":{"anyOf":[{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"description":{"type":"string","description":"A description of what the function does, used by the model to choose when and how to call the function."},"name":{"type":"string","description":"The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"parameters":{"type":"object","additionalProperties":{"nullable":true,"description":"The parameters the functions accepts, described as a JSON Schema object."}},"strict":{"type":"boolean","nullable":true,"description":"Whether to enable strict schema adherence when generating the function call. If set to True, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is True."}},"required":["name"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","function"]},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool, used to identify it in tool calls."},"description":{"type":"string","description":"Optional description of the custom tool, used to provide more context."},"format":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["grammar"]},"grammar":{"type":"object","properties":{"definition":{"type":"string","description":"The grammar definition."},"syntax":{"type":"string","enum":["lark","regex"],"description":"The syntax of the grammar definition."}},"required":["definition","syntax"]}},"required":["type","grammar"]}],"description":"The input format for the custom tool. Default is unconstrained text."}},"required":["name","format"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","custom"]}]},{"type":"object","properties":{"type":{"type":"string","minLength":1}},"required":["type"]}]},"description":"A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported."},"tool_choice":{"anyOf":[{"type":"string","enum":["none","auto","required"],"description":"none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."}},"required":["name"]}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["allowed_tools"],"description":"The type of the tool. Currently, only function is supported."},"allowed_tools":{"type":"object","properties":{"mode":{"type":"string","enum":["auto","required"],"description":"Constrains the tools available to the model to a pre-defined set.\n- auto allows the model to pick from among the allowed tools and generate a message.\n- required requires the model to call one or more of the allowed tools."},"tools":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}},"description":"A list of tool definitions that the model should be allowed to call."}},"required":["mode","tools"]}},"required":["type","allowed_tools"],"description":"Constrains the tools available to the model to a pre-defined set."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"string","enum":["name"],"description":"The name of the function to call."}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"string","enum":["name"],"description":"The name of the custom tool to call."}},"required":["type","custom"],"description":"Specifies a tool the model should use. Use to force the model to call a specific custom tool."}],"description":"Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {\"type\": \"function\", \"function\": {\"name\": \"my_function\"}} forces the model to call that tool.\n  none is the default when no tools are present. auto is the default if tools are present."},"normalize_tool_schemas":{"type":"boolean","description":"Enable provider compatibility normalization for tool function JSON schemas."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"n":{"type":"integer","nullable":true,"minimum":1,"description":"How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs."},"seed":{"type":"integer","minimum":1,"description":"This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result."},"reasoning_effort":{"type":"string","enum":["none","low","medium","high"],"description":"Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response."},"response_format":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of response format being defined. Always text."}},"required":["type"],"additionalProperties":false,"description":"Default response format. Used to generate text responses."},{"type":"object","properties":{"type":{"type":"string","enum":["json_object"],"description":"The type of response format being defined. Always json_object."}},"required":["type"],"additionalProperties":false,"description":"An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so."},{"type":"object","properties":{"type":{"type":"string","enum":["json_schema"],"description":"The type of response format being defined. Always json_schema."},"json_schema":{"type":"object","properties":{"name":{"type":"string","description":"The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"schema":{"type":"object","additionalProperties":{"nullable":true},"description":"The schema for the response format, described as a JSON Schema object."},"strict":{"type":"boolean","nullable":true,"description":"Whether to enable strict schema adherence when generating the output. If set to True, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is True."},"description":{"type":"string","description":"A description of what the response format is for, used by the model to determine how to respond in the format."}},"required":["name"],"additionalProperties":false,"description":"JSON Schema response format. Used to generate structured JSON responses."}},"required":["type","json_schema"],"additionalProperties":false,"description":"JSON Schema response format. Used to generate structured JSON responses."}],"description":"An object specifying the format that the model must output."},"router":{"type":"object","properties":{"decision_model":{"type":"string","enum":["typesafe/jev-1.14","typesafe/jev-1.13","typesafe/jev","liquid/d1","liquid/d1.1","liquid/d1-ultra"],"description":"The decision model that picks each request's bucket. Default `typesafe/jev-1.14`. `typesafe/jev` is always the newest Jev; name a version to stay on it. Only decision models are accepted here, never a model that answers. Every judgement is billed at that model's catalogue price and listed as its own request in your usage; turns that need none (tool results, a forced bucket, a single bucket) pay nothing for it. It is shown the request's images, up to 8 — billed as its input tokens — and never resizes one: Jev reads PNG or JPEG of 280 to 1568 px a side; the Liquid models JPEG, PNG or WebP, up to 10,000 patches of 32 × 32 px in all and 4.5 MiB per request. A request whose own images do not fit is refused with a 400 that says what to change, before anything is charged."},"buckets":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","maxLength":32,"pattern":"^[A-Za-z0-9][A-Za-z0-9_.-]*$","description":"The bucket's name, unique in the router: 1 to 32 letters, digits, `-`, `_` or `.`. Name it in `default_bucket` and `force_bucket`; the response's `meta.router.bucket` says which one answered."},"when":{"type":"string","minLength":1,"maxLength":500,"description":"What the requests this bucket takes look like, in your words (1 to 500 characters) — for example \"unsolicited advertising, prize claims or phishing\". The decision model picks the bucket whose `when` fits each request best. Required on every bucket when there are two or more; a single bucket has none."},"models":{"type":"array","items":{"anyOf":[{"type":"string","description":"A model id, as you would pass it in `model` (see `GET /v1/models`): a chat, image or video model."},{"type":"object","properties":{"model":{"type":"string"}},"required":["model"],"additionalProperties":false,"description":"The same model id, as an object: `{ \"model\": \"<id>\" }`."}],"description":"A model this bucket may answer with."},"maxItems":10,"description":"1 to 10 models, in the order to try them: the first one that can take the request (its tools, images, JSON schema and context size; on image and video generation, every input image field it sets) answers, and if it fails the next one does. Chat, image and video models side by side: a request takes the bucket's models of its own kind — a chat completion its chat models, an image generation its image models — and a bucket with none of its kind sends it on to the next bucket that has one (`meta.router.spilled_from`). Only models we serve — not routers, not decision models. Models you list run with your request's own settings, reasoning included. Or none (`[]`): a request the decision model puts in this bucket ends at the decision — no model is called, and the response is empty in its endpoint's shape (an assistant message with `content: \"\"` and `finish_reason: \"stop\"`; `data: []` for images; a video generation `completed` with `video: null`) and its `meta.router` says `\"routed\": false` and names the bucket, so your code acts on it. Only the judgement is charged. Not on a single bucket, which is never judged."}},"required":["name","models"],"additionalProperties":false,"description":"One bucket: its name, what it takes, and its models."},"minItems":1,"maxItems":10,"description":"Your buckets, 1 to 10: they replace the default buckets entirely. With two or more, each needs a `when`, and the decision model picks the one that fits each request. A single bucket is a fallback chain — every request goes to it, with no judgement. Left out: the default buckets — `light` (\"Needs little capability: greetings and small talk, one-line or lookup answers, common knowledge, short routine tasks such as a short piece of writing, a quick rewrite or simple arithmetic — a small, fast model answers it well\"): `openai/gpt-6-luna`, `anthropic/claude-haiku-5.5`, `deepseek/deepseek-v4.1-flash`, `google/gemini-3-1-flash-lite`, `google/gemini-3-5-flash-lite`; `standard` (\"Needs a capable model: multi-step tasks that need care and accuracy\"): `openai/gpt-6.1-sol`, `anthropic/claude-sonnet-5.5`; `heavy` (\"Needs the strongest model: complex reasoning, hard math or proofs, large or tricky code, expert-level or research-grade knowledge\"): `anthropic/claude-opus-5.5`, `openai/gpt-6-astra` — which route conversations only (chat completions, the Responses API, the Messages API: on each, the models of a bucket served there); image and video requests need buckets of your own."},"default_bucket":{"type":"string","description":"Where a request goes when it is not judged — the decision model failed, timed out or named no bucket, or the request has no text — and where one goes when none of its bucket's models can take it, before the others are tried. Default: your first bucket; `standard` for the default buckets. Required when your first bucket lists no models: a request that is not judged would otherwise end there, unanswered by any model."},"force_bucket":{"type":"string","description":"Send the request to this bucket without judging it (nothing is charged for a judgement)."},"min_confidence":{"type":"number","minimum":0,"maximum":1,"description":"Below this confidence in its answer (0 to 1), a request goes to `default_bucket` instead (`meta.router.reason`: `unsure`) — for example, send what the decision model is unsure about to your strongest bucket. The judgement is still paid for. On a ladder an unsure turn never moves the conversation up, so a high value keeps conversations on the first rung: measured at 0.9, 40–45% of explicit conversations stayed there."},"ladder":{"type":"boolean","description":"Your buckets are a ladder's rungs: the first is the strictest, each next one more relaxed, and a last one may list no models (`models: []`), where a conversation ends. A conversation only moves down: each new turn — the previous reply and the new message — is judged against every rung, and the conversation goes to the lowest one it needs, and stays — never up: a rung above it keeps it where it is. It climbs back only once what moved it is gone from its history. Send each answer's `meta.router.state` back as `router.state`: with it only what is new is judged, and the conversation stays on its rung's model; without it, or when it does not fit the conversation, the whole conversation is judged again, two windows of 2,000 characters at a time, the newest first, at most 24 judgements — each billed as its own request; a conversation takes up to 5,000 messages, and a turn up to about 288,000 characters of new text. An unsure or failed judgement takes `default_bucket` but never moves a conversation up: name your last rung as `default_bucket` to fail closed. A turn returning tool results goes back to the model that made the calls, unjudged, while nothing new but the model's own calls comes with it. A model that cannot take a turn is passed over for one of a rung below, never above. `force_bucket` is not allowed. Only the user’s and the assistant’s messages are judged — their text and images — never your instructions (`system`) or tool results; an image the decision model cannot be shown (past its limits, or a link we could not store) takes `default_bucket`. A judgement that fails moves nothing for good: what it was to judge is judged again with the next turns, and given up on, at `default_bucket`, only after failing on its own three turns running."},"state":{"type":"string","maxLength":1024,"description":"With `ladder: true`: the previous answer's `meta.router.state`, unchanged. A Responses turn that continues a stored response (`previous_response_id`) needs none: the response keeps its own."}},"additionalProperties":false,"description":"How `aimlapi/dynamic-router` routes this request. Every setting is optional: left out, or `{}`, a conversation — chat completions, Responses, Messages — routes by the default buckets, like `typesafe/jev-router`; a setting you leave out keeps its default, and `buckets`, when given, are the whole table. The same `router` serves chat completions, the Responses API, the Messages API, image generation and editing, and video generation: the decision model judges the request's text — on media, its prompt — and its images, and the request takes the models of its own kind from the bucket. A conversation stays on its model while its turns land in the same bucket, and a turn returning tool results always goes back to the model that made the calls. A Responses turn that continues a stored response (`previous_response_id`) is judged like any other turn and runs only on a model served where that response is kept: it stays with the model that wrote it while it lands in that model's bucket, and a bucket with no models ends it at the decision. The response says where the request went in `meta.router` (`routed`, bucket, reason, the decision model's choice and confidence, the judgement, its charge and the images it was shown) and which model answered in `meta.model` — the router itself when the bucket lists no models; on video, on the submit's response; on a Messages stream, on its `message_stop` event. An invalid configuration is answered with a 400 that names each setting to fix, before anything is charged. In a multipart request (an image edit sending its picture as a file), send `router` as its JSON, in one text field."}},"required":["model","messages"],"title":"aimlapi/dynamic-router"},{"type":"object","properties":{"model":{"type":"string","enum":["aimlapi/dynamic-router"]},"provider":{"type":"string","description":"Provider routing override. Use a source key such as `openai`, `opentree`, `xai`, `google`, `alibaba`, `minimax`, `moonshot`, `baidu`, or `togetherai` to run that provider with no fallback; `auto` (default) uses the full fallback chain. Case-insensitive."},"messages":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"role":{"type":"string","enum":["user"],"description":"The role of the author of the message — in this case, the user"},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["image_url"]},"image_url":{"type":"object","properties":{"url":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"}],"description":"Either a URL of the image or the base64 encoded image data. "},"detail":{"type":"string","enum":["low","high","auto"],"description":"Specifies the detail level of the image. Currently supports JPG/JPEG, PNG, GIF, and WEBP formats."}},"required":["url"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","image_url"]}]}}],"description":"The contents of the user message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"role":{"type":"string","enum":["system"],"description":"The role of the author of the message — in this case, the system."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the system message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the tool message."},"tool_call_id":{"type":"string","description":"Tool call that this message is responding to."},"name":{"type":"string","nullable":true,"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content","tool_call_id"]},{"type":"object","properties":{"role":{"type":"string","enum":["assistant"],"description":"The role of the author of the message — in this case, the Assistant."},"content":{"anyOf":[{"type":"string","description":"The contents of the Assistant message."},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"refusal":{"type":"string","description":"The refusal message generated by the model."},"type":{"type":"string","enum":["refusal"],"description":"The type of the content part."}},"required":["refusal","type"]}]},"description":"An array of content parts with a defined type. Can be one or more of type text, or exactly one of type refusal."},{"nullable":true}],"description":"The contents of the Assistant message. Required unless tool_calls or function_call is specified."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."},"tool_calls":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."},"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."}},"required":["name","arguments"],"description":"The function that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","function"]},{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool to call."},"input":{"type":"string","description":"The input for the custom tool call generated by the model."}},"required":["name","input"],"description":"The custom tool that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","custom"]}]},"description":"The tool calls generated by the model, such as function calls."},"refusal":{"type":"string","nullable":true,"description":"The refusal message by the Assistant."}},"required":["role"]}]},"description":"A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, documents (txt, pdf), images, and audio."},"max_completion_tokens":{"type":"integer","minimum":1,"description":"An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens."},"max_tokens":{"type":"number","minimum":1,"description":"The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API."},"stream":{"type":"boolean","default":false,"description":"If set to True, the model response data will be streamed to the client as it is generated using server-sent events."},"stream_options":{"type":"object","properties":{"include_usage":{"type":"boolean"}},"required":["include_usage"]},"tools":{"type":"array","items":{"anyOf":[{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"description":{"type":"string","description":"A description of what the function does, used by the model to choose when and how to call the function."},"name":{"type":"string","description":"The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"parameters":{"type":"object","additionalProperties":{"nullable":true,"description":"The parameters the functions accepts, described as a JSON Schema object."}},"strict":{"type":"boolean","nullable":true,"description":"Whether to enable strict schema adherence when generating the function call. If set to True, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is True."}},"required":["name"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","function"]},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool, used to identify it in tool calls."},"description":{"type":"string","description":"Optional description of the custom tool, used to provide more context."},"format":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["grammar"]},"grammar":{"type":"object","properties":{"definition":{"type":"string","description":"The grammar definition."},"syntax":{"type":"string","enum":["lark","regex"],"description":"The syntax of the grammar definition."}},"required":["definition","syntax"]}},"required":["type","grammar"]}],"description":"The input format for the custom tool. Default is unconstrained text."}},"required":["name","format"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","custom"]}]},{"type":"object","properties":{"type":{"type":"string","minLength":1}},"required":["type"]}]},"description":"A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported."},"tool_choice":{"anyOf":[{"type":"string","enum":["none","auto","required"],"description":"none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."}},"required":["name"]}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["allowed_tools"],"description":"The type of the tool. Currently, only function is supported."},"allowed_tools":{"type":"object","properties":{"mode":{"type":"string","enum":["auto","required"],"description":"Constrains the tools available to the model to a pre-defined set.\n- auto allows the model to pick from among the allowed tools and generate a message.\n- required requires the model to call one or more of the allowed tools."},"tools":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}},"description":"A list of tool definitions that the model should be allowed to call."}},"required":["mode","tools"]}},"required":["type","allowed_tools"],"description":"Constrains the tools available to the model to a pre-defined set."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"string","enum":["name"],"description":"The name of the function to call."}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"string","enum":["name"],"description":"The name of the custom tool to call."}},"required":["type","custom"],"description":"Specifies a tool the model should use. Use to force the model to call a specific custom tool."}],"description":"Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {\"type\": \"function\", \"function\": {\"name\": \"my_function\"}} forces the model to call that tool.\n  none is the default when no tools are present. auto is the default if tools are present."},"normalize_tool_schemas":{"type":"boolean","description":"Enable provider compatibility normalization for tool function JSON schemas."},"temperature":{"type":"number","minimum":0,"maximum":2,"description":"What sampling temperature to use. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both."},"top_p":{"type":"number","minimum":0.01,"maximum":1,"description":"An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n  We generally recommend altering this or temperature but not both."},"stop":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}},{"nullable":true}],"description":"Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence."},"logprobs":{"type":"boolean","nullable":true,"description":"Whether to return log probabilities of the output tokens or not. If True, returns the log probabilities of each output token returned in the content of message."},"top_logprobs":{"type":"number","nullable":true,"minimum":0,"maximum":20,"description":"An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to True if this parameter is used."},"frequency_penalty":{"type":"number","nullable":true,"minimum":-2,"maximum":2,"description":"Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim."},"presence_penalty":{"type":"number","nullable":true,"minimum":-2,"maximum":2,"description":"Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics."},"reasoning_effort":{"type":"string","enum":["none","low","medium","high"],"description":"Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response."},"reasoning":{"type":"object","properties":{"effort":{"type":"string","enum":["low","medium","high"],"description":"Reasoning effort setting"},"max_tokens":{"type":"integer","minimum":1,"description":"Max tokens of reasoning content. Cannot be used simultaneously with effort."},"exclude":{"type":"boolean","description":"Whether to exclude reasoning from the response"}},"description":"Configuration for model reasoning/thinking tokens"},"response_format":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of response format being defined. Always text."}},"required":["type"],"additionalProperties":false,"description":"Default response format. Used to generate text responses."},{"type":"object","properties":{"type":{"type":"string","enum":["json_object"],"description":"The type of response format being defined. Always json_object."}},"required":["type"],"additionalProperties":false,"description":"An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so."}],"description":"An object specifying the format that the model must output."},"router":{"type":"object","properties":{"decision_model":{"type":"string","enum":["typesafe/jev-1.14","typesafe/jev-1.13","typesafe/jev","liquid/d1","liquid/d1.1","liquid/d1-ultra"],"description":"The decision model that picks each request's bucket. Default `typesafe/jev-1.14`. `typesafe/jev` is always the newest Jev; name a version to stay on it. Only decision models are accepted here, never a model that answers. Every judgement is billed at that model's catalogue price and listed as its own request in your usage; turns that need none (tool results, a forced bucket, a single bucket) pay nothing for it. It is shown the request's images, up to 8 — billed as its input tokens — and never resizes one: Jev reads PNG or JPEG of 280 to 1568 px a side; the Liquid models JPEG, PNG or WebP, up to 10,000 patches of 32 × 32 px in all and 4.5 MiB per request. A request whose own images do not fit is refused with a 400 that says what to change, before anything is charged."},"buckets":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","maxLength":32,"pattern":"^[A-Za-z0-9][A-Za-z0-9_.-]*$","description":"The bucket's name, unique in the router: 1 to 32 letters, digits, `-`, `_` or `.`. Name it in `default_bucket` and `force_bucket`; the response's `meta.router.bucket` says which one answered."},"when":{"type":"string","minLength":1,"maxLength":500,"description":"What the requests this bucket takes look like, in your words (1 to 500 characters) — for example \"unsolicited advertising, prize claims or phishing\". The decision model picks the bucket whose `when` fits each request best. Required on every bucket when there are two or more; a single bucket has none."},"models":{"type":"array","items":{"anyOf":[{"type":"string","description":"A model id, as you would pass it in `model` (see `GET /v1/models`): a chat, image or video model."},{"type":"object","properties":{"model":{"type":"string"}},"required":["model"],"additionalProperties":false,"description":"The same model id, as an object: `{ \"model\": \"<id>\" }`."}],"description":"A model this bucket may answer with."},"maxItems":10,"description":"1 to 10 models, in the order to try them: the first one that can take the request (its tools, images, JSON schema and context size; on image and video generation, every input image field it sets) answers, and if it fails the next one does. Chat, image and video models side by side: a request takes the bucket's models of its own kind — a chat completion its chat models, an image generation its image models — and a bucket with none of its kind sends it on to the next bucket that has one (`meta.router.spilled_from`). Only models we serve — not routers, not decision models. Models you list run with your request's own settings, reasoning included. Or none (`[]`): a request the decision model puts in this bucket ends at the decision — no model is called, and the response is empty in its endpoint's shape (an assistant message with `content: \"\"` and `finish_reason: \"stop\"`; `data: []` for images; a video generation `completed` with `video: null`) and its `meta.router` says `\"routed\": false` and names the bucket, so your code acts on it. Only the judgement is charged. Not on a single bucket, which is never judged."}},"required":["name","models"],"additionalProperties":false,"description":"One bucket: its name, what it takes, and its models."},"minItems":1,"maxItems":10,"description":"Your buckets, 1 to 10: they replace the default buckets entirely. With two or more, each needs a `when`, and the decision model picks the one that fits each request. A single bucket is a fallback chain — every request goes to it, with no judgement. Left out: the default buckets — `light` (\"Needs little capability: greetings and small talk, one-line or lookup answers, common knowledge, short routine tasks such as a short piece of writing, a quick rewrite or simple arithmetic — a small, fast model answers it well\"): `openai/gpt-6-luna`, `anthropic/claude-haiku-5.5`, `deepseek/deepseek-v4.1-flash`, `google/gemini-3-1-flash-lite`, `google/gemini-3-5-flash-lite`; `standard` (\"Needs a capable model: multi-step tasks that need care and accuracy\"): `openai/gpt-6.1-sol`, `anthropic/claude-sonnet-5.5`; `heavy` (\"Needs the strongest model: complex reasoning, hard math or proofs, large or tricky code, expert-level or research-grade knowledge\"): `anthropic/claude-opus-5.5`, `openai/gpt-6-astra` — which route conversations only (chat completions, the Responses API, the Messages API: on each, the models of a bucket served there); image and video requests need buckets of your own."},"default_bucket":{"type":"string","description":"Where a request goes when it is not judged — the decision model failed, timed out or named no bucket, or the request has no text — and where one goes when none of its bucket's models can take it, before the others are tried. Default: your first bucket; `standard` for the default buckets. Required when your first bucket lists no models: a request that is not judged would otherwise end there, unanswered by any model."},"force_bucket":{"type":"string","description":"Send the request to this bucket without judging it (nothing is charged for a judgement)."},"min_confidence":{"type":"number","minimum":0,"maximum":1,"description":"Below this confidence in its answer (0 to 1), a request goes to `default_bucket` instead (`meta.router.reason`: `unsure`) — for example, send what the decision model is unsure about to your strongest bucket. The judgement is still paid for. On a ladder an unsure turn never moves the conversation up, so a high value keeps conversations on the first rung: measured at 0.9, 40–45% of explicit conversations stayed there."},"ladder":{"type":"boolean","description":"Your buckets are a ladder's rungs: the first is the strictest, each next one more relaxed, and a last one may list no models (`models: []`), where a conversation ends. A conversation only moves down: each new turn — the previous reply and the new message — is judged against every rung, and the conversation goes to the lowest one it needs, and stays — never up: a rung above it keeps it where it is. It climbs back only once what moved it is gone from its history. Send each answer's `meta.router.state` back as `router.state`: with it only what is new is judged, and the conversation stays on its rung's model; without it, or when it does not fit the conversation, the whole conversation is judged again, two windows of 2,000 characters at a time, the newest first, at most 24 judgements — each billed as its own request; a conversation takes up to 5,000 messages, and a turn up to about 288,000 characters of new text. An unsure or failed judgement takes `default_bucket` but never moves a conversation up: name your last rung as `default_bucket` to fail closed. A turn returning tool results goes back to the model that made the calls, unjudged, while nothing new but the model's own calls comes with it. A model that cannot take a turn is passed over for one of a rung below, never above. `force_bucket` is not allowed. Only the user’s and the assistant’s messages are judged — their text and images — never your instructions (`system`) or tool results; an image the decision model cannot be shown (past its limits, or a link we could not store) takes `default_bucket`. A judgement that fails moves nothing for good: what it was to judge is judged again with the next turns, and given up on, at `default_bucket`, only after failing on its own three turns running."},"state":{"type":"string","maxLength":1024,"description":"With `ladder: true`: the previous answer's `meta.router.state`, unchanged. A Responses turn that continues a stored response (`previous_response_id`) needs none: the response keeps its own."}},"additionalProperties":false,"description":"How `aimlapi/dynamic-router` routes this request. Every setting is optional: left out, or `{}`, a conversation — chat completions, Responses, Messages — routes by the default buckets, like `typesafe/jev-router`; a setting you leave out keeps its default, and `buckets`, when given, are the whole table. The same `router` serves chat completions, the Responses API, the Messages API, image generation and editing, and video generation: the decision model judges the request's text — on media, its prompt — and its images, and the request takes the models of its own kind from the bucket. A conversation stays on its model while its turns land in the same bucket, and a turn returning tool results always goes back to the model that made the calls. A Responses turn that continues a stored response (`previous_response_id`) is judged like any other turn and runs only on a model served where that response is kept: it stays with the model that wrote it while it lands in that model's bucket, and a bucket with no models ends it at the decision. The response says where the request went in `meta.router` (`routed`, bucket, reason, the decision model's choice and confidence, the judgement, its charge and the images it was shown) and which model answered in `meta.model` — the router itself when the bucket lists no models; on video, on the submit's response; on a Messages stream, on its `message_stop` event. An invalid configuration is answered with a 400 that names each setting to fix, before anything is charged. In a multipart request (an image edit sending its picture as a file), send `router` as its JSON, in one text field."}},"required":["model","messages"],"title":"aimlapi/dynamic-router"},{"type":"object","properties":{"model":{"type":"string","enum":["aimlapi/dynamic-router"]},"provider":{"type":"string","description":"Provider routing override. Use a source key such as `openai`, `opentree`, `xai`, `google`, `alibaba`, `minimax`, `moonshot`, `baidu`, or `togetherai` to run that provider with no fallback; `auto` (default) uses the full fallback chain. Case-insensitive."},"messages":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"role":{"type":"string","enum":["user"],"description":"The role of the author of the message — in this case, the user"},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["image_url"]},"image_url":{"type":"object","properties":{"url":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"}],"description":"Either a URL of the image or the base64 encoded image data. "},"detail":{"type":"string","enum":["low","high","auto"],"description":"Specifies the detail level of the image. Currently supports JPG/JPEG, PNG, GIF, and WEBP formats."}},"required":["url"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","image_url"]},{"type":"object","properties":{"type":{"type":"string","enum":["video_url"]},"video_url":{"type":"object","properties":{"url":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"}],"description":"Base64-encoded local video file."}},"required":["url"]}},"required":["type","video_url"]},{"type":"object","properties":{"type":{"type":"string","enum":["file"],"description":"The type of the content part."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]},"file":{"type":"object","properties":{"file_data":{"type":"string","description":"The file data, encoded in base64 and passed to the model as a string. Only PDF format is supported.\n        - Maximum size per file: Up to 512 MB and up to 2 million tokens.\n        - Maximum number of files: Up to 20 files can be attached to a single GPT application or Assistant. This limit applies throughout the application's lifetime.\n        - Maximum total file storage per user: 10 GB."},"file_id":{"type":"string"},"filename":{"type":"string","description":"The file name specified by the user. This name can be used to reference the file when interacting with the model, especially if multiple files are uploaded."}}}},"required":["type","file"]},{"type":"object","properties":{"type":{"type":"string","enum":["input_audio"],"description":"The type of the content part."},"input_audio":{"type":"object","properties":{"data":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"},{"type":"string"}],"description":"Either a URL of the audio or the base64 encoded audio data."},"format":{"type":"string","enum":["wav","mp3","audio/x-aac","audio/flac","audio/mp3","audio/m4a","audio/mpeg","audio/mpga","audio/mp4","audio/ogg","audio/pcm","audio/webm"],"description":"The format of the encoded audio data. Currently supports \"wav\" and \"mp3\"."}},"required":["data","format"]}},"required":["type","input_audio"]}]}}],"description":"The contents of the user message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"role":{"type":"string","enum":["system"],"description":"The role of the author of the message — in this case, the system."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the system message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the tool message."},"tool_call_id":{"type":"string","description":"Tool call that this message is responding to."},"name":{"type":"string","nullable":true,"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content","tool_call_id"]},{"type":"object","properties":{"role":{"type":"string","enum":["assistant"],"description":"The role of the author of the message — in this case, the Assistant."},"content":{"anyOf":[{"type":"string","description":"The contents of the Assistant message."},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"refusal":{"type":"string","description":"The refusal message generated by the model."},"type":{"type":"string","enum":["refusal"],"description":"The type of the content part."}},"required":["refusal","type"]}]},"description":"An array of content parts with a defined type. Can be one or more of type text, or exactly one of type refusal."},{"nullable":true}],"description":"The contents of the Assistant message. Required unless tool_calls or function_call is specified."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."},"tool_calls":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."},"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."}},"required":["name","arguments"],"description":"The function that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","function"]},{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool to call."},"input":{"type":"string","description":"The input for the custom tool call generated by the model."}},"required":["name","input"],"description":"The custom tool that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","custom"]}]},"description":"The tool calls generated by the model, such as function calls."},"refusal":{"type":"string","nullable":true,"description":"The refusal message by the Assistant."},"audio":{"type":"object","nullable":true,"properties":{"id":{"type":"string","description":"Unique identifier for a previous audio response from the model."}},"required":["id"],"description":"Data about a previous audio response from the model."}},"required":["role"]}]},"description":"A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, documents (txt, pdf), images, and audio."},"max_completion_tokens":{"type":"integer","minimum":1,"description":"An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens."},"max_tokens":{"type":"number","minimum":1,"description":"The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API."},"stream":{"type":"boolean","default":false,"description":"If set to True, the model response data will be streamed to the client as it is generated using server-sent events."},"stream_options":{"type":"object","properties":{"include_usage":{"type":"boolean"}},"required":["include_usage"]},"audio":{"type":"object","nullable":true,"properties":{"format":{"type":"string","enum":["wav","mp3","flac","opus","pcm16"],"description":"Specifies the output audio format. Must be one of wav, mp3, flac, opus, or pcm16."},"voice":{"anyOf":[{"type":"string","enum":["alloy","ash","ballad","coral","echo","fable","nova","onyx","sage","shimmer"]},{"type":"string"}],"description":"The voice the model uses to respond. Supported voices are alloy, ash, ballad, coral, echo, fable, nova, onyx, sage, and shimmer."}},"required":["format","voice"],"description":"Parameters for audio output. Required when audio output is requested with modalities: [\"audio\"]."},"modalities":{"type":"array","nullable":true,"items":{"type":"string","enum":["text","audio"]},"description":"Output types that you would like the model to generate. Most models are capable of generating text, which is the default:\n  \n  [\"text\"]\n  \n  Model can also be used to generate audio. To request that this model generate both text and audio responses, you can use:\n  \n  [\"text\", \"audio\"]"},"n":{"type":"integer","nullable":true,"minimum":1,"description":"How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs."},"temperature":{"type":"number","minimum":0,"maximum":2,"description":"What sampling temperature to use. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both."},"top_p":{"type":"number","minimum":0.01,"maximum":1,"description":"An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n  We generally recommend altering this or temperature but not both."},"stop":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}},{"nullable":true}],"description":"Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence."},"frequency_penalty":{"type":"number","nullable":true,"minimum":-2,"maximum":2,"description":"Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim."},"prediction":{"type":"object","properties":{"type":{"type":"string","enum":["content"],"description":"The type of the predicted content you want to provide."},"content":{"anyOf":[{"type":"string","description":"The content used for a Predicted Output. This is often the text of a file you are regenerating with minor changes."},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."}},"required":["type","text"]},"description":"An array of content parts with a defined type. Supported options differ based on the model being used to generate the response. Can contain text inputs."}],"description":"The content that should be matched when generating a model response. If generated tokens would match this content, the entire model response can be returned much more quickly."}},"required":["type","content"],"description":"Configuration for a Predicted Output, which can greatly improve response times when large parts of the model response are known ahead of time."},"presence_penalty":{"type":"number","nullable":true,"minimum":-2,"maximum":2,"description":"Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics."},"seed":{"type":"integer","minimum":1,"description":"This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result."},"response_format":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of response format being defined. Always text."}},"required":["type"],"additionalProperties":false,"description":"Default response format. Used to generate text responses."},{"type":"object","properties":{"type":{"type":"string","enum":["json_object"],"description":"The type of response format being defined. Always json_object."}},"required":["type"],"additionalProperties":false,"description":"An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so."},{"type":"object","properties":{"type":{"type":"string","enum":["json_schema"],"description":"The type of response format being defined. Always json_schema."},"json_schema":{"type":"object","properties":{"name":{"type":"string","description":"The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"schema":{"type":"object","additionalProperties":{"nullable":true},"description":"The schema for the response format, described as a JSON Schema object."},"strict":{"type":"boolean","nullable":true,"description":"Whether to enable strict schema adherence when generating the output. If set to True, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is True."},"description":{"type":"string","description":"A description of what the response format is for, used by the model to determine how to respond in the format."}},"required":["name"],"additionalProperties":false,"description":"JSON Schema response format. Used to generate structured JSON responses."}},"required":["type","json_schema"],"additionalProperties":false,"description":"JSON Schema response format. Used to generate structured JSON responses."}],"description":"An object specifying the format that the model must output."},"tools":{"type":"array","items":{"anyOf":[{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"description":{"type":"string","description":"A description of what the function does, used by the model to choose when and how to call the function."},"name":{"type":"string","description":"The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"parameters":{"type":"object","additionalProperties":{"nullable":true,"description":"The parameters the functions accepts, described as a JSON Schema object."}},"strict":{"type":"boolean","nullable":true,"description":"Whether to enable strict schema adherence when generating the function call. If set to True, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is True."}},"required":["name"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","function"]},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool, used to identify it in tool calls."},"description":{"type":"string","description":"Optional description of the custom tool, used to provide more context."},"format":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["grammar"]},"grammar":{"type":"object","properties":{"definition":{"type":"string","description":"The grammar definition."},"syntax":{"type":"string","enum":["lark","regex"],"description":"The syntax of the grammar definition."}},"required":["definition","syntax"]}},"required":["type","grammar"]}],"description":"The input format for the custom tool. Default is unconstrained text."}},"required":["name","format"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","custom"]}]},{"type":"object","properties":{"type":{"type":"string","minLength":1}},"required":["type"]}]},"description":"A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported."},"tool_choice":{"anyOf":[{"type":"string","enum":["none","auto","required"],"description":"none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."}},"required":["name"]}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["allowed_tools"],"description":"The type of the tool. Currently, only function is supported."},"allowed_tools":{"type":"object","properties":{"mode":{"type":"string","enum":["auto","required"],"description":"Constrains the tools available to the model to a pre-defined set.\n- auto allows the model to pick from among the allowed tools and generate a message.\n- required requires the model to call one or more of the allowed tools."},"tools":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}},"description":"A list of tool definitions that the model should be allowed to call."}},"required":["mode","tools"]}},"required":["type","allowed_tools"],"description":"Constrains the tools available to the model to a pre-defined set."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"string","enum":["name"],"description":"The name of the function to call."}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"string","enum":["name"],"description":"The name of the custom tool to call."}},"required":["type","custom"],"description":"Specifies a tool the model should use. Use to force the model to call a specific custom tool."}],"description":"Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {\"type\": \"function\", \"function\": {\"name\": \"my_function\"}} forces the model to call that tool.\n  none is the default when no tools are present. auto is the default if tools are present."},"normalize_tool_schemas":{"type":"boolean","description":"Enable provider compatibility normalization for tool function JSON schemas."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"reasoning_effort":{"type":"string","enum":["minimal","low","medium","high","max"],"description":"Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response."},"router":{"type":"object","properties":{"decision_model":{"type":"string","enum":["typesafe/jev-1.14","typesafe/jev-1.13","typesafe/jev","liquid/d1","liquid/d1.1","liquid/d1-ultra"],"description":"The decision model that picks each request's bucket. Default `typesafe/jev-1.14`. `typesafe/jev` is always the newest Jev; name a version to stay on it. Only decision models are accepted here, never a model that answers. Every judgement is billed at that model's catalogue price and listed as its own request in your usage; turns that need none (tool results, a forced bucket, a single bucket) pay nothing for it. It is shown the request's images, up to 8 — billed as its input tokens — and never resizes one: Jev reads PNG or JPEG of 280 to 1568 px a side; the Liquid models JPEG, PNG or WebP, up to 10,000 patches of 32 × 32 px in all and 4.5 MiB per request. A request whose own images do not fit is refused with a 400 that says what to change, before anything is charged."},"buckets":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","maxLength":32,"pattern":"^[A-Za-z0-9][A-Za-z0-9_.-]*$","description":"The bucket's name, unique in the router: 1 to 32 letters, digits, `-`, `_` or `.`. Name it in `default_bucket` and `force_bucket`; the response's `meta.router.bucket` says which one answered."},"when":{"type":"string","minLength":1,"maxLength":500,"description":"What the requests this bucket takes look like, in your words (1 to 500 characters) — for example \"unsolicited advertising, prize claims or phishing\". The decision model picks the bucket whose `when` fits each request best. Required on every bucket when there are two or more; a single bucket has none."},"models":{"type":"array","items":{"anyOf":[{"type":"string","description":"A model id, as you would pass it in `model` (see `GET /v1/models`): a chat, image or video model."},{"type":"object","properties":{"model":{"type":"string"}},"required":["model"],"additionalProperties":false,"description":"The same model id, as an object: `{ \"model\": \"<id>\" }`."}],"description":"A model this bucket may answer with."},"maxItems":10,"description":"1 to 10 models, in the order to try them: the first one that can take the request (its tools, images, JSON schema and context size; on image and video generation, every input image field it sets) answers, and if it fails the next one does. Chat, image and video models side by side: a request takes the bucket's models of its own kind — a chat completion its chat models, an image generation its image models — and a bucket with none of its kind sends it on to the next bucket that has one (`meta.router.spilled_from`). Only models we serve — not routers, not decision models. Models you list run with your request's own settings, reasoning included. Or none (`[]`): a request the decision model puts in this bucket ends at the decision — no model is called, and the response is empty in its endpoint's shape (an assistant message with `content: \"\"` and `finish_reason: \"stop\"`; `data: []` for images; a video generation `completed` with `video: null`) and its `meta.router` says `\"routed\": false` and names the bucket, so your code acts on it. Only the judgement is charged. Not on a single bucket, which is never judged."}},"required":["name","models"],"additionalProperties":false,"description":"One bucket: its name, what it takes, and its models."},"minItems":1,"maxItems":10,"description":"Your buckets, 1 to 10: they replace the default buckets entirely. With two or more, each needs a `when`, and the decision model picks the one that fits each request. A single bucket is a fallback chain — every request goes to it, with no judgement. Left out: the default buckets — `light` (\"Needs little capability: greetings and small talk, one-line or lookup answers, common knowledge, short routine tasks such as a short piece of writing, a quick rewrite or simple arithmetic — a small, fast model answers it well\"): `openai/gpt-6-luna`, `anthropic/claude-haiku-5.5`, `deepseek/deepseek-v4.1-flash`, `google/gemini-3-1-flash-lite`, `google/gemini-3-5-flash-lite`; `standard` (\"Needs a capable model: multi-step tasks that need care and accuracy\"): `openai/gpt-6.1-sol`, `anthropic/claude-sonnet-5.5`; `heavy` (\"Needs the strongest model: complex reasoning, hard math or proofs, large or tricky code, expert-level or research-grade knowledge\"): `anthropic/claude-opus-5.5`, `openai/gpt-6-astra` — which route conversations only (chat completions, the Responses API, the Messages API: on each, the models of a bucket served there); image and video requests need buckets of your own."},"default_bucket":{"type":"string","description":"Where a request goes when it is not judged — the decision model failed, timed out or named no bucket, or the request has no text — and where one goes when none of its bucket's models can take it, before the others are tried. Default: your first bucket; `standard` for the default buckets. Required when your first bucket lists no models: a request that is not judged would otherwise end there, unanswered by any model."},"force_bucket":{"type":"string","description":"Send the request to this bucket without judging it (nothing is charged for a judgement)."},"min_confidence":{"type":"number","minimum":0,"maximum":1,"description":"Below this confidence in its answer (0 to 1), a request goes to `default_bucket` instead (`meta.router.reason`: `unsure`) — for example, send what the decision model is unsure about to your strongest bucket. The judgement is still paid for. On a ladder an unsure turn never moves the conversation up, so a high value keeps conversations on the first rung: measured at 0.9, 40–45% of explicit conversations stayed there."},"ladder":{"type":"boolean","description":"Your buckets are a ladder's rungs: the first is the strictest, each next one more relaxed, and a last one may list no models (`models: []`), where a conversation ends. A conversation only moves down: each new turn — the previous reply and the new message — is judged against every rung, and the conversation goes to the lowest one it needs, and stays — never up: a rung above it keeps it where it is. It climbs back only once what moved it is gone from its history. Send each answer's `meta.router.state` back as `router.state`: with it only what is new is judged, and the conversation stays on its rung's model; without it, or when it does not fit the conversation, the whole conversation is judged again, two windows of 2,000 characters at a time, the newest first, at most 24 judgements — each billed as its own request; a conversation takes up to 5,000 messages, and a turn up to about 288,000 characters of new text. An unsure or failed judgement takes `default_bucket` but never moves a conversation up: name your last rung as `default_bucket` to fail closed. A turn returning tool results goes back to the model that made the calls, unjudged, while nothing new but the model's own calls comes with it. A model that cannot take a turn is passed over for one of a rung below, never above. `force_bucket` is not allowed. Only the user’s and the assistant’s messages are judged — their text and images — never your instructions (`system`) or tool results; an image the decision model cannot be shown (past its limits, or a link we could not store) takes `default_bucket`. A judgement that fails moves nothing for good: what it was to judge is judged again with the next turns, and given up on, at `default_bucket`, only after failing on its own three turns running."},"state":{"type":"string","maxLength":1024,"description":"With `ladder: true`: the previous answer's `meta.router.state`, unchanged. A Responses turn that continues a stored response (`previous_response_id`) needs none: the response keeps its own."}},"additionalProperties":false,"description":"How `aimlapi/dynamic-router` routes this request. Every setting is optional: left out, or `{}`, a conversation — chat completions, Responses, Messages — routes by the default buckets, like `typesafe/jev-router`; a setting you leave out keeps its default, and `buckets`, when given, are the whole table. The same `router` serves chat completions, the Responses API, the Messages API, image generation and editing, and video generation: the decision model judges the request's text — on media, its prompt — and its images, and the request takes the models of its own kind from the bucket. A conversation stays on its model while its turns land in the same bucket, and a turn returning tool results always goes back to the model that made the calls. A Responses turn that continues a stored response (`previous_response_id`) is judged like any other turn and runs only on a model served where that response is kept: it stays with the model that wrote it while it lands in that model's bucket, and a bucket with no models ends it at the decision. The response says where the request went in `meta.router` (`routed`, bucket, reason, the decision model's choice and confidence, the judgement, its charge and the images it was shown) and which model answered in `meta.model` — the router itself when the bucket lists no models; on video, on the submit's response; on a Messages stream, on its `message_stop` event. An invalid configuration is answered with a 400 that names each setting to fix, before anything is charged. In a multipart request (an image edit sending its picture as a file), send `router` as its JSON, in one text field."}},"required":["model","messages"],"title":"aimlapi/dynamic-router"},{"type":"object","properties":{"model":{"type":"string","enum":["aimlapi/dynamic-router"]},"provider":{"type":"string","description":"Provider routing override. Use a source key such as `openai`, `opentree`, `xai`, `google`, `alibaba`, `minimax`, `moonshot`, `baidu`, or `togetherai` to run that provider with no fallback; `auto` (default) uses the full fallback chain. Case-insensitive."},"messages":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"role":{"type":"string","enum":["user"],"description":"The role of the author of the message — in this case, the user"},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["image_url"]},"image_url":{"type":"object","properties":{"url":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"}],"description":"Either a URL of the image or the base64 encoded image data. "},"detail":{"type":"string","enum":["low","high","auto"],"description":"Specifies the detail level of the image. Currently supports JPG/JPEG, PNG, GIF, and WEBP formats."}},"required":["url"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","image_url"]},{"type":"object","properties":{"type":{"type":"string","enum":["video_url"]},"video_url":{"type":"object","properties":{"url":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"}],"description":"Base64-encoded local video file."}},"required":["url"]}},"required":["type","video_url"]},{"type":"object","properties":{"type":{"type":"string","enum":["file"],"description":"The type of the content part."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]},"file":{"type":"object","properties":{"file_data":{"type":"string","description":"The file data, encoded in base64 and passed to the model as a string. Only PDF format is supported.\n        - Maximum size per file: Up to 512 MB and up to 2 million tokens.\n        - Maximum number of files: Up to 20 files can be attached to a single GPT application or Assistant. This limit applies throughout the application's lifetime.\n        - Maximum total file storage per user: 10 GB."},"file_id":{"type":"string"},"filename":{"type":"string","description":"The file name specified by the user. This name can be used to reference the file when interacting with the model, especially if multiple files are uploaded."}}}},"required":["type","file"]},{"type":"object","properties":{"type":{"type":"string","enum":["input_audio"],"description":"The type of the content part."},"input_audio":{"type":"object","properties":{"data":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"},{"type":"string"}],"description":"Either a URL of the audio or the base64 encoded audio data."},"format":{"type":"string","enum":["wav","mp3","audio/x-aac","audio/flac","audio/mp3","audio/m4a","audio/mpeg","audio/mpga","audio/mp4","audio/ogg","audio/pcm","audio/webm"],"description":"The format of the encoded audio data. Currently supports \"wav\" and \"mp3\"."}},"required":["data","format"]}},"required":["type","input_audio"]}]}}],"description":"The contents of the user message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"role":{"type":"string","enum":["system"],"description":"The role of the author of the message — in this case, the system."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the system message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the tool message."},"tool_call_id":{"type":"string","description":"Tool call that this message is responding to."},"name":{"type":"string","nullable":true,"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content","tool_call_id"]},{"type":"object","properties":{"role":{"type":"string","enum":["assistant"],"description":"The role of the author of the message — in this case, the Assistant."},"content":{"anyOf":[{"type":"string","description":"The contents of the Assistant message."},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"refusal":{"type":"string","description":"The refusal message generated by the model."},"type":{"type":"string","enum":["refusal"],"description":"The type of the content part."}},"required":["refusal","type"]}]},"description":"An array of content parts with a defined type. Can be one or more of type text, or exactly one of type refusal."},{"nullable":true}],"description":"The contents of the Assistant message. Required unless tool_calls or function_call is specified."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."},"tool_calls":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."},"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."}},"required":["name","arguments"],"description":"The function that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","function"]},{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool to call."},"input":{"type":"string","description":"The input for the custom tool call generated by the model."}},"required":["name","input"],"description":"The custom tool that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","custom"]}]},"description":"The tool calls generated by the model, such as function calls."},"refusal":{"type":"string","nullable":true,"description":"The refusal message by the Assistant."},"audio":{"type":"object","nullable":true,"properties":{"id":{"type":"string","description":"Unique identifier for a previous audio response from the model."}},"required":["id"],"description":"Data about a previous audio response from the model."}},"required":["role"]}]},"description":"A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, documents (txt, pdf), images, and audio."},"max_completion_tokens":{"type":"integer","minimum":1,"description":"An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens."},"max_tokens":{"type":"number","minimum":1,"description":"The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API."},"stream":{"type":"boolean","default":false,"description":"If set to True, the model response data will be streamed to the client as it is generated using server-sent events."},"stream_options":{"type":"object","properties":{"include_usage":{"type":"boolean"}},"required":["include_usage"]},"audio":{"type":"object","nullable":true,"properties":{"format":{"type":"string","enum":["wav","mp3","flac","opus","pcm16"],"description":"Specifies the output audio format. Must be one of wav, mp3, flac, opus, or pcm16."},"voice":{"anyOf":[{"type":"string","enum":["alloy","ash","ballad","coral","echo","fable","nova","onyx","sage","shimmer"]},{"type":"string"}],"description":"The voice the model uses to respond. Supported voices are alloy, ash, ballad, coral, echo, fable, nova, onyx, sage, and shimmer."}},"required":["format","voice"],"description":"Parameters for audio output. Required when audio output is requested with modalities: [\"audio\"]."},"modalities":{"type":"array","nullable":true,"items":{"type":"string","enum":["text","audio"]},"description":"Output types that you would like the model to generate. Most models are capable of generating text, which is the default:\n  \n  [\"text\"]\n  \n  Model can also be used to generate audio. To request that this model generate both text and audio responses, you can use:\n  \n  [\"text\", \"audio\"]"},"n":{"type":"integer","nullable":true,"minimum":1,"description":"How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs."},"temperature":{"type":"number","minimum":0,"maximum":2,"description":"What sampling temperature to use. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both."},"top_p":{"type":"number","minimum":0.01,"maximum":1,"description":"An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.\n  We generally recommend altering this or temperature but not both."},"stop":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"string"}},{"nullable":true}],"description":"Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence."},"prediction":{"type":"object","properties":{"type":{"type":"string","enum":["content"],"description":"The type of the predicted content you want to provide."},"content":{"anyOf":[{"type":"string","description":"The content used for a Predicted Output. This is often the text of a file you are regenerating with minor changes."},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."}},"required":["type","text"]},"description":"An array of content parts with a defined type. Supported options differ based on the model being used to generate the response. Can contain text inputs."}],"description":"The content that should be matched when generating a model response. If generated tokens would match this content, the entire model response can be returned much more quickly."}},"required":["type","content"],"description":"Configuration for a Predicted Output, which can greatly improve response times when large parts of the model response are known ahead of time."},"seed":{"type":"integer","minimum":1,"description":"This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result."},"response_format":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of response format being defined. Always text."}},"required":["type"],"additionalProperties":false,"description":"Default response format. Used to generate text responses."},{"type":"object","properties":{"type":{"type":"string","enum":["json_object"],"description":"The type of response format being defined. Always json_object."}},"required":["type"],"additionalProperties":false,"description":"An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so."},{"type":"object","properties":{"type":{"type":"string","enum":["json_schema"],"description":"The type of response format being defined. Always json_schema."},"json_schema":{"type":"object","properties":{"name":{"type":"string","description":"The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"schema":{"type":"object","additionalProperties":{"nullable":true},"description":"The schema for the response format, described as a JSON Schema object."},"strict":{"type":"boolean","nullable":true,"description":"Whether to enable strict schema adherence when generating the output. If set to True, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is True."},"description":{"type":"string","description":"A description of what the response format is for, used by the model to determine how to respond in the format."}},"required":["name"],"additionalProperties":false,"description":"JSON Schema response format. Used to generate structured JSON responses."}},"required":["type","json_schema"],"additionalProperties":false,"description":"JSON Schema response format. Used to generate structured JSON responses."}],"description":"An object specifying the format that the model must output."},"tools":{"type":"array","items":{"anyOf":[{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"description":{"type":"string","description":"A description of what the function does, used by the model to choose when and how to call the function."},"name":{"type":"string","description":"The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"parameters":{"type":"object","additionalProperties":{"nullable":true,"description":"The parameters the functions accepts, described as a JSON Schema object."}},"strict":{"type":"boolean","nullable":true,"description":"Whether to enable strict schema adherence when generating the function call. If set to True, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is True."}},"required":["name"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","function"]},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool, used to identify it in tool calls."},"description":{"type":"string","description":"Optional description of the custom tool, used to provide more context."},"format":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["grammar"]},"grammar":{"type":"object","properties":{"definition":{"type":"string","description":"The grammar definition."},"syntax":{"type":"string","enum":["lark","regex"],"description":"The syntax of the grammar definition."}},"required":["definition","syntax"]}},"required":["type","grammar"]}],"description":"The input format for the custom tool. Default is unconstrained text."}},"required":["name","format"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","custom"]}]},{"type":"object","properties":{"type":{"type":"string","minLength":1}},"required":["type"]}]},"description":"A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported."},"tool_choice":{"anyOf":[{"type":"string","enum":["none","auto","required"],"description":"none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."}},"required":["name"]}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["allowed_tools"],"description":"The type of the tool. Currently, only function is supported."},"allowed_tools":{"type":"object","properties":{"mode":{"type":"string","enum":["auto","required"],"description":"Constrains the tools available to the model to a pre-defined set.\n- auto allows the model to pick from among the allowed tools and generate a message.\n- required requires the model to call one or more of the allowed tools."},"tools":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}},"description":"A list of tool definitions that the model should be allowed to call."}},"required":["mode","tools"]}},"required":["type","allowed_tools"],"description":"Constrains the tools available to the model to a pre-defined set."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"string","enum":["name"],"description":"The name of the function to call."}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"string","enum":["name"],"description":"The name of the custom tool to call."}},"required":["type","custom"],"description":"Specifies a tool the model should use. Use to force the model to call a specific custom tool."}],"description":"Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {\"type\": \"function\", \"function\": {\"name\": \"my_function\"}} forces the model to call that tool.\n  none is the default when no tools are present. auto is the default if tools are present."},"normalize_tool_schemas":{"type":"boolean","description":"Enable provider compatibility normalization for tool function JSON schemas."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"reasoning_effort":{"type":"string","enum":["minimal","low","medium","high","max"],"description":"Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response."},"router":{"type":"object","properties":{"decision_model":{"type":"string","enum":["typesafe/jev-1.14","typesafe/jev-1.13","typesafe/jev","liquid/d1","liquid/d1.1","liquid/d1-ultra"],"description":"The decision model that picks each request's bucket. Default `typesafe/jev-1.14`. `typesafe/jev` is always the newest Jev; name a version to stay on it. Only decision models are accepted here, never a model that answers. Every judgement is billed at that model's catalogue price and listed as its own request in your usage; turns that need none (tool results, a forced bucket, a single bucket) pay nothing for it. It is shown the request's images, up to 8 — billed as its input tokens — and never resizes one: Jev reads PNG or JPEG of 280 to 1568 px a side; the Liquid models JPEG, PNG or WebP, up to 10,000 patches of 32 × 32 px in all and 4.5 MiB per request. A request whose own images do not fit is refused with a 400 that says what to change, before anything is charged."},"buckets":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","maxLength":32,"pattern":"^[A-Za-z0-9][A-Za-z0-9_.-]*$","description":"The bucket's name, unique in the router: 1 to 32 letters, digits, `-`, `_` or `.`. Name it in `default_bucket` and `force_bucket`; the response's `meta.router.bucket` says which one answered."},"when":{"type":"string","minLength":1,"maxLength":500,"description":"What the requests this bucket takes look like, in your words (1 to 500 characters) — for example \"unsolicited advertising, prize claims or phishing\". The decision model picks the bucket whose `when` fits each request best. Required on every bucket when there are two or more; a single bucket has none."},"models":{"type":"array","items":{"anyOf":[{"type":"string","description":"A model id, as you would pass it in `model` (see `GET /v1/models`): a chat, image or video model."},{"type":"object","properties":{"model":{"type":"string"}},"required":["model"],"additionalProperties":false,"description":"The same model id, as an object: `{ \"model\": \"<id>\" }`."}],"description":"A model this bucket may answer with."},"maxItems":10,"description":"1 to 10 models, in the order to try them: the first one that can take the request (its tools, images, JSON schema and context size; on image and video generation, every input image field it sets) answers, and if it fails the next one does. Chat, image and video models side by side: a request takes the bucket's models of its own kind — a chat completion its chat models, an image generation its image models — and a bucket with none of its kind sends it on to the next bucket that has one (`meta.router.spilled_from`). Only models we serve — not routers, not decision models. Models you list run with your request's own settings, reasoning included. Or none (`[]`): a request the decision model puts in this bucket ends at the decision — no model is called, and the response is empty in its endpoint's shape (an assistant message with `content: \"\"` and `finish_reason: \"stop\"`; `data: []` for images; a video generation `completed` with `video: null`) and its `meta.router` says `\"routed\": false` and names the bucket, so your code acts on it. Only the judgement is charged. Not on a single bucket, which is never judged."}},"required":["name","models"],"additionalProperties":false,"description":"One bucket: its name, what it takes, and its models."},"minItems":1,"maxItems":10,"description":"Your buckets, 1 to 10: they replace the default buckets entirely. With two or more, each needs a `when`, and the decision model picks the one that fits each request. A single bucket is a fallback chain — every request goes to it, with no judgement. Left out: the default buckets — `light` (\"Needs little capability: greetings and small talk, one-line or lookup answers, common knowledge, short routine tasks such as a short piece of writing, a quick rewrite or simple arithmetic — a small, fast model answers it well\"): `openai/gpt-6-luna`, `anthropic/claude-haiku-5.5`, `deepseek/deepseek-v4.1-flash`, `google/gemini-3-1-flash-lite`, `google/gemini-3-5-flash-lite`; `standard` (\"Needs a capable model: multi-step tasks that need care and accuracy\"): `openai/gpt-6.1-sol`, `anthropic/claude-sonnet-5.5`; `heavy` (\"Needs the strongest model: complex reasoning, hard math or proofs, large or tricky code, expert-level or research-grade knowledge\"): `anthropic/claude-opus-5.5`, `openai/gpt-6-astra` — which route conversations only (chat completions, the Responses API, the Messages API: on each, the models of a bucket served there); image and video requests need buckets of your own."},"default_bucket":{"type":"string","description":"Where a request goes when it is not judged — the decision model failed, timed out or named no bucket, or the request has no text — and where one goes when none of its bucket's models can take it, before the others are tried. Default: your first bucket; `standard` for the default buckets. Required when your first bucket lists no models: a request that is not judged would otherwise end there, unanswered by any model."},"force_bucket":{"type":"string","description":"Send the request to this bucket without judging it (nothing is charged for a judgement)."},"min_confidence":{"type":"number","minimum":0,"maximum":1,"description":"Below this confidence in its answer (0 to 1), a request goes to `default_bucket` instead (`meta.router.reason`: `unsure`) — for example, send what the decision model is unsure about to your strongest bucket. The judgement is still paid for. On a ladder an unsure turn never moves the conversation up, so a high value keeps conversations on the first rung: measured at 0.9, 40–45% of explicit conversations stayed there."},"ladder":{"type":"boolean","description":"Your buckets are a ladder's rungs: the first is the strictest, each next one more relaxed, and a last one may list no models (`models: []`), where a conversation ends. A conversation only moves down: each new turn — the previous reply and the new message — is judged against every rung, and the conversation goes to the lowest one it needs, and stays — never up: a rung above it keeps it where it is. It climbs back only once what moved it is gone from its history. Send each answer's `meta.router.state` back as `router.state`: with it only what is new is judged, and the conversation stays on its rung's model; without it, or when it does not fit the conversation, the whole conversation is judged again, two windows of 2,000 characters at a time, the newest first, at most 24 judgements — each billed as its own request; a conversation takes up to 5,000 messages, and a turn up to about 288,000 characters of new text. An unsure or failed judgement takes `default_bucket` but never moves a conversation up: name your last rung as `default_bucket` to fail closed. A turn returning tool results goes back to the model that made the calls, unjudged, while nothing new but the model's own calls comes with it. A model that cannot take a turn is passed over for one of a rung below, never above. `force_bucket` is not allowed. Only the user’s and the assistant’s messages are judged — their text and images — never your instructions (`system`) or tool results; an image the decision model cannot be shown (past its limits, or a link we could not store) takes `default_bucket`. A judgement that fails moves nothing for good: what it was to judge is judged again with the next turns, and given up on, at `default_bucket`, only after failing on its own three turns running."},"state":{"type":"string","maxLength":1024,"description":"With `ladder: true`: the previous answer's `meta.router.state`, unchanged. A Responses turn that continues a stored response (`previous_response_id`) needs none: the response keeps its own."}},"additionalProperties":false,"description":"How `aimlapi/dynamic-router` routes this request. Every setting is optional: left out, or `{}`, a conversation — chat completions, Responses, Messages — routes by the default buckets, like `typesafe/jev-router`; a setting you leave out keeps its default, and `buckets`, when given, are the whole table. The same `router` serves chat completions, the Responses API, the Messages API, image generation and editing, and video generation: the decision model judges the request's text — on media, its prompt — and its images, and the request takes the models of its own kind from the bucket. A conversation stays on its model while its turns land in the same bucket, and a turn returning tool results always goes back to the model that made the calls. A Responses turn that continues a stored response (`previous_response_id`) is judged like any other turn and runs only on a model served where that response is kept: it stays with the model that wrote it while it lands in that model's bucket, and a bucket with no models ends it at the decision. The response says where the request went in `meta.router` (`routed`, bucket, reason, the decision model's choice and confidence, the judgement, its charge and the images it was shown) and which model answered in `meta.model` — the router itself when the bucket lists no models; on video, on the submit's response; on a Messages stream, on its `message_stop` event. An invalid configuration is answered with a 400 that names each setting to fix, before anything is charged. In a multipart request (an image edit sending its picture as a file), send `router` as its JSON, in one text field."}},"required":["model","messages"],"title":"aimlapi/dynamic-router"},{"type":"object","properties":{"model":{"type":"string","enum":["aimlapi/dynamic-router"]},"provider":{"type":"string","description":"Provider routing override. Use a source key such as `openai`, `opentree`, `xai`, `google`, `alibaba`, `minimax`, `moonshot`, `baidu`, or `togetherai` to run that provider with no fallback; `auto` (default) uses the full fallback chain. Case-insensitive."},"messages":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"role":{"type":"string","enum":["user"],"description":"The role of the author of the message — in this case, the user"},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["image_url"]},"image_url":{"type":"object","properties":{"url":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"}],"description":"Either a URL of the image or the base64 encoded image data. "},"detail":{"type":"string","enum":["low","high","auto"],"description":"Specifies the detail level of the image. Currently supports JPG/JPEG, PNG, GIF, and WEBP formats."}},"required":["url"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","image_url"]},{"type":"object","properties":{"type":{"type":"string","enum":["file"],"description":"The type of the content part."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]},"file":{"type":"object","properties":{"file_data":{"type":"string","description":"The file data, encoded in base64 and passed to the model as a string. Only PDF format is supported.\n        - Maximum size per file: Up to 512 MB and up to 2 million tokens.\n        - Maximum number of files: Up to 20 files can be attached to a single GPT application or Assistant. This limit applies throughout the application's lifetime.\n        - Maximum total file storage per user: 10 GB."},"file_id":{"type":"string"},"filename":{"type":"string","description":"The file name specified by the user. This name can be used to reference the file when interacting with the model, especially if multiple files are uploaded."}}}},"required":["type","file"]}]}}],"description":"The contents of the user message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the developer message."},"role":{"type":"string","enum":["developer"],"description":"The role of the author of the message — in this case, the developer."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["content","role"]},{"type":"object","properties":{"role":{"type":"string","enum":["system"],"description":"The role of the author of the message — in this case, the system."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the system message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the tool message."},"tool_call_id":{"type":"string","description":"Tool call that this message is responding to."},"name":{"type":"string","nullable":true,"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content","tool_call_id"]},{"type":"object","properties":{"role":{"type":"string","enum":["assistant"],"description":"The role of the author of the message — in this case, the Assistant."},"content":{"anyOf":[{"type":"string","description":"The contents of the Assistant message."},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"refusal":{"type":"string","description":"The refusal message generated by the model."},"type":{"type":"string","enum":["refusal"],"description":"The type of the content part."}},"required":["refusal","type"]}]},"description":"An array of content parts with a defined type. Can be one or more of type text, or exactly one of type refusal."},{"nullable":true}],"description":"The contents of the Assistant message. Required unless tool_calls or function_call is specified."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."},"tool_calls":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."},"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."}},"required":["name","arguments"],"description":"The function that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","function"]},{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool to call."},"input":{"type":"string","description":"The input for the custom tool call generated by the model."}},"required":["name","input"],"description":"The custom tool that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","custom"]}]},"description":"The tool calls generated by the model, such as function calls."},"refusal":{"type":"string","nullable":true,"description":"The refusal message by the Assistant."}},"required":["role"]}]},"description":"A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, documents (txt, pdf), images, and audio."},"max_tokens":{"type":"number","minimum":1,"description":"The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API."},"stream":{"type":"boolean","default":false,"description":"If set to True, the model response data will be streamed to the client as it is generated using server-sent events."},"stream_options":{"type":"object","properties":{"include_usage":{"type":"boolean"}},"required":["include_usage"]},"tools":{"type":"array","items":{"anyOf":[{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"description":{"type":"string","description":"A description of what the function does, used by the model to choose when and how to call the function."},"name":{"type":"string","description":"The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"parameters":{"type":"object","additionalProperties":{"nullable":true,"description":"The parameters the functions accepts, described as a JSON Schema object."}},"strict":{"type":"boolean","nullable":true,"description":"Whether to enable strict schema adherence when generating the function call. If set to True, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is True."}},"required":["name"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","function"]},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool, used to identify it in tool calls."},"description":{"type":"string","description":"Optional description of the custom tool, used to provide more context."},"format":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["grammar"]},"grammar":{"type":"object","properties":{"definition":{"type":"string","description":"The grammar definition."},"syntax":{"type":"string","enum":["lark","regex"],"description":"The syntax of the grammar definition."}},"required":["definition","syntax"]}},"required":["type","grammar"]}],"description":"The input format for the custom tool. Default is unconstrained text."}},"required":["name","format"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","custom"]}]},{"type":"object","properties":{"type":{"type":"string","minLength":1}},"required":["type"]}]},"description":"A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported."},"tool_choice":{"anyOf":[{"type":"string","enum":["none","auto","required"],"description":"none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."}},"required":["name"]}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["allowed_tools"],"description":"The type of the tool. Currently, only function is supported."},"allowed_tools":{"type":"object","properties":{"mode":{"type":"string","enum":["auto","required"],"description":"Constrains the tools available to the model to a pre-defined set.\n- auto allows the model to pick from among the allowed tools and generate a message.\n- required requires the model to call one or more of the allowed tools."},"tools":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}},"description":"A list of tool definitions that the model should be allowed to call."}},"required":["mode","tools"]}},"required":["type","allowed_tools"],"description":"Constrains the tools available to the model to a pre-defined set."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"string","enum":["name"],"description":"The name of the function to call."}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"string","enum":["name"],"description":"The name of the custom tool to call."}},"required":["type","custom"],"description":"Specifies a tool the model should use. Use to force the model to call a specific custom tool."}],"description":"Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {\"type\": \"function\", \"function\": {\"name\": \"my_function\"}} forces the model to call that tool.\n  none is the default when no tools are present. auto is the default if tools are present."},"normalize_tool_schemas":{"type":"boolean","description":"Enable provider compatibility normalization for tool function JSON schemas."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"n":{"type":"integer","nullable":true,"minimum":1,"description":"How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs."},"seed":{"type":"integer","minimum":1,"description":"This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result."},"reasoning_effort":{"type":"string","enum":["low","medium","high"],"description":"Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response."},"response_format":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of response format being defined. Always text."}},"required":["type"],"additionalProperties":false,"description":"Default response format. Used to generate text responses."},{"type":"object","properties":{"type":{"type":"string","enum":["json_object"],"description":"The type of response format being defined. Always json_object."}},"required":["type"],"additionalProperties":false,"description":"An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so."},{"type":"object","properties":{"type":{"type":"string","enum":["json_schema"],"description":"The type of response format being defined. Always json_schema."},"json_schema":{"type":"object","properties":{"name":{"type":"string","description":"The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"schema":{"type":"object","additionalProperties":{"nullable":true},"description":"The schema for the response format, described as a JSON Schema object."},"strict":{"type":"boolean","nullable":true,"description":"Whether to enable strict schema adherence when generating the output. If set to True, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is True."},"description":{"type":"string","description":"A description of what the response format is for, used by the model to determine how to respond in the format."}},"required":["name"],"additionalProperties":false,"description":"JSON Schema response format. Used to generate structured JSON responses."}},"required":["type","json_schema"],"additionalProperties":false,"description":"JSON Schema response format. Used to generate structured JSON responses."}],"description":"An object specifying the format that the model must output."},"router":{"type":"object","properties":{"decision_model":{"type":"string","enum":["typesafe/jev-1.14","typesafe/jev-1.13","typesafe/jev","liquid/d1","liquid/d1.1","liquid/d1-ultra"],"description":"The decision model that picks each request's bucket. Default `typesafe/jev-1.14`. `typesafe/jev` is always the newest Jev; name a version to stay on it. Only decision models are accepted here, never a model that answers. Every judgement is billed at that model's catalogue price and listed as its own request in your usage; turns that need none (tool results, a forced bucket, a single bucket) pay nothing for it. It is shown the request's images, up to 8 — billed as its input tokens — and never resizes one: Jev reads PNG or JPEG of 280 to 1568 px a side; the Liquid models JPEG, PNG or WebP, up to 10,000 patches of 32 × 32 px in all and 4.5 MiB per request. A request whose own images do not fit is refused with a 400 that says what to change, before anything is charged."},"buckets":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","maxLength":32,"pattern":"^[A-Za-z0-9][A-Za-z0-9_.-]*$","description":"The bucket's name, unique in the router: 1 to 32 letters, digits, `-`, `_` or `.`. Name it in `default_bucket` and `force_bucket`; the response's `meta.router.bucket` says which one answered."},"when":{"type":"string","minLength":1,"maxLength":500,"description":"What the requests this bucket takes look like, in your words (1 to 500 characters) — for example \"unsolicited advertising, prize claims or phishing\". The decision model picks the bucket whose `when` fits each request best. Required on every bucket when there are two or more; a single bucket has none."},"models":{"type":"array","items":{"anyOf":[{"type":"string","description":"A model id, as you would pass it in `model` (see `GET /v1/models`): a chat, image or video model."},{"type":"object","properties":{"model":{"type":"string"}},"required":["model"],"additionalProperties":false,"description":"The same model id, as an object: `{ \"model\": \"<id>\" }`."}],"description":"A model this bucket may answer with."},"maxItems":10,"description":"1 to 10 models, in the order to try them: the first one that can take the request (its tools, images, JSON schema and context size; on image and video generation, every input image field it sets) answers, and if it fails the next one does. Chat, image and video models side by side: a request takes the bucket's models of its own kind — a chat completion its chat models, an image generation its image models — and a bucket with none of its kind sends it on to the next bucket that has one (`meta.router.spilled_from`). Only models we serve — not routers, not decision models. Models you list run with your request's own settings, reasoning included. Or none (`[]`): a request the decision model puts in this bucket ends at the decision — no model is called, and the response is empty in its endpoint's shape (an assistant message with `content: \"\"` and `finish_reason: \"stop\"`; `data: []` for images; a video generation `completed` with `video: null`) and its `meta.router` says `\"routed\": false` and names the bucket, so your code acts on it. Only the judgement is charged. Not on a single bucket, which is never judged."}},"required":["name","models"],"additionalProperties":false,"description":"One bucket: its name, what it takes, and its models."},"minItems":1,"maxItems":10,"description":"Your buckets, 1 to 10: they replace the default buckets entirely. With two or more, each needs a `when`, and the decision model picks the one that fits each request. A single bucket is a fallback chain — every request goes to it, with no judgement. Left out: the default buckets — `light` (\"Needs little capability: greetings and small talk, one-line or lookup answers, common knowledge, short routine tasks such as a short piece of writing, a quick rewrite or simple arithmetic — a small, fast model answers it well\"): `openai/gpt-6-luna`, `anthropic/claude-haiku-5.5`, `deepseek/deepseek-v4.1-flash`, `google/gemini-3-1-flash-lite`, `google/gemini-3-5-flash-lite`; `standard` (\"Needs a capable model: multi-step tasks that need care and accuracy\"): `openai/gpt-6.1-sol`, `anthropic/claude-sonnet-5.5`; `heavy` (\"Needs the strongest model: complex reasoning, hard math or proofs, large or tricky code, expert-level or research-grade knowledge\"): `anthropic/claude-opus-5.5`, `openai/gpt-6-astra` — which route conversations only (chat completions, the Responses API, the Messages API: on each, the models of a bucket served there); image and video requests need buckets of your own."},"default_bucket":{"type":"string","description":"Where a request goes when it is not judged — the decision model failed, timed out or named no bucket, or the request has no text — and where one goes when none of its bucket's models can take it, before the others are tried. Default: your first bucket; `standard` for the default buckets. Required when your first bucket lists no models: a request that is not judged would otherwise end there, unanswered by any model."},"force_bucket":{"type":"string","description":"Send the request to this bucket without judging it (nothing is charged for a judgement)."},"min_confidence":{"type":"number","minimum":0,"maximum":1,"description":"Below this confidence in its answer (0 to 1), a request goes to `default_bucket` instead (`meta.router.reason`: `unsure`) — for example, send what the decision model is unsure about to your strongest bucket. The judgement is still paid for. On a ladder an unsure turn never moves the conversation up, so a high value keeps conversations on the first rung: measured at 0.9, 40–45% of explicit conversations stayed there."},"ladder":{"type":"boolean","description":"Your buckets are a ladder's rungs: the first is the strictest, each next one more relaxed, and a last one may list no models (`models: []`), where a conversation ends. A conversation only moves down: each new turn — the previous reply and the new message — is judged against every rung, and the conversation goes to the lowest one it needs, and stays — never up: a rung above it keeps it where it is. It climbs back only once what moved it is gone from its history. Send each answer's `meta.router.state` back as `router.state`: with it only what is new is judged, and the conversation stays on its rung's model; without it, or when it does not fit the conversation, the whole conversation is judged again, two windows of 2,000 characters at a time, the newest first, at most 24 judgements — each billed as its own request; a conversation takes up to 5,000 messages, and a turn up to about 288,000 characters of new text. An unsure or failed judgement takes `default_bucket` but never moves a conversation up: name your last rung as `default_bucket` to fail closed. A turn returning tool results goes back to the model that made the calls, unjudged, while nothing new but the model's own calls comes with it. A model that cannot take a turn is passed over for one of a rung below, never above. `force_bucket` is not allowed. Only the user’s and the assistant’s messages are judged — their text and images — never your instructions (`system`) or tool results; an image the decision model cannot be shown (past its limits, or a link we could not store) takes `default_bucket`. A judgement that fails moves nothing for good: what it was to judge is judged again with the next turns, and given up on, at `default_bucket`, only after failing on its own three turns running."},"state":{"type":"string","maxLength":1024,"description":"With `ladder: true`: the previous answer's `meta.router.state`, unchanged. A Responses turn that continues a stored response (`previous_response_id`) needs none: the response keeps its own."}},"additionalProperties":false,"description":"How `aimlapi/dynamic-router` routes this request. Every setting is optional: left out, or `{}`, a conversation — chat completions, Responses, Messages — routes by the default buckets, like `typesafe/jev-router`; a setting you leave out keeps its default, and `buckets`, when given, are the whole table. The same `router` serves chat completions, the Responses API, the Messages API, image generation and editing, and video generation: the decision model judges the request's text — on media, its prompt — and its images, and the request takes the models of its own kind from the bucket. A conversation stays on its model while its turns land in the same bucket, and a turn returning tool results always goes back to the model that made the calls. A Responses turn that continues a stored response (`previous_response_id`) is judged like any other turn and runs only on a model served where that response is kept: it stays with the model that wrote it while it lands in that model's bucket, and a bucket with no models ends it at the decision. The response says where the request went in `meta.router` (`routed`, bucket, reason, the decision model's choice and confidence, the judgement, its charge and the images it was shown) and which model answered in `meta.model` — the router itself when the bucket lists no models; on video, on the submit's response; on a Messages stream, on its `message_stop` event. An invalid configuration is answered with a 400 that names each setting to fix, before anything is charged. In a multipart request (an image edit sending its picture as a file), send `router` as its JSON, in one text field."}},"required":["model","messages"],"title":"aimlapi/dynamic-router"},{"type":"object","properties":{"model":{"type":"string","enum":["aimlapi/dynamic-router"]},"messages":{"anyOf":[{"type":"array","items":{"oneOf":[{"type":"object","properties":{"role":{"type":"string","enum":["user","assistant"]},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["base64"],"description":"The type of the image."},"media_type":{"type":"string","enum":["image/jpeg","image/png","image/gif","image/webp"],"description":"The media type of the image."},"data":{"type":"string","description":"The base64 encoded image data."}},"required":["type","media_type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["url"]},"url":{"type":"string","format":"uri"}},"required":["type","url"]}]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","source"]},{"type":"object","properties":{"type":{"type":"string","enum":["thinking"]},"thinking":{"type":"string"},"signature":{"type":"string"}},"required":["type","thinking","signature"]},{"type":"object","properties":{"type":{"type":"string","enum":["tool_result"]},"tool_use_id":{"type":"string"},"is_error":{"type":"boolean"},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["base64"],"description":"The type of the image."},"media_type":{"type":"string","enum":["image/jpeg","image/png","image/gif","image/webp"],"description":"The media type of the image."},"data":{"type":"string","description":"The base64 encoded image data."}},"required":["type","media_type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["url"]},"url":{"type":"string","format":"uri"}},"required":["type","url"]}]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","source"]},{"type":"object","properties":{"type":{"type":"string","enum":["search_result"]},"source":{"type":"string"},"title":{"type":"string"},"content":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","source","title","content"]},{"type":"object","properties":{"type":{"type":"string","enum":["document"]},"source":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["base64"]},"media_type":{"type":"string","enum":["application/pdf","text/plain"]},"data":{"type":"string"}},"required":["type","media_type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["text"]},"media_type":{"type":"string","enum":["text/plain"]},"data":{"type":"string"}},"required":["type","media_type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["url"]},"url":{"type":"string","format":"uri"}},"required":["type","url"]},{"type":"object","properties":{"type":{"type":"string","enum":["content"]},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"nullable":true}}]}},"required":["type","content"]}]},"title":{"type":"string"},"context":{"type":"string"},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","source"]},{"type":"object","properties":{"type":{"type":"string","enum":["tool_reference"]},"tool_name":{"type":"string"},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","tool_name"]}]}}]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","tool_use_id"]},{"type":"object","properties":{"type":{"type":"string","enum":["tool_use"]},"id":{"type":"string"},"name":{"type":"string"},"input":{"type":"object","additionalProperties":{"nullable":true}},"caller":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["direct"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["code_execution_20250825"]},"tool_id":{"type":"string"}},"required":["type","tool_id"]},{"type":"object","properties":{"type":{"type":"string","enum":["code_execution_20260120"]},"tool_id":{"type":"string"}},"required":["type","tool_id"]}]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","id","name","input"]},{"type":"object","properties":{"type":{"type":"string","enum":["server_tool_use"]},"id":{"type":"string"},"name":{"type":"string","enum":["web_search","web_fetch","code_execution","bash_code_execution","text_editor_code_execution","tool_search_tool_regex","tool_search_tool_bm25"]},"input":{"type":"object","additionalProperties":{"nullable":true}},"caller":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["direct"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["code_execution_20250825"]},"tool_id":{"type":"string"}},"required":["type","tool_id"]},{"type":"object","properties":{"type":{"type":"string","enum":["code_execution_20260120"]},"tool_id":{"type":"string"}},"required":["type","tool_id"]}]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","id","name","input"]},{"type":"object","properties":{"type":{"type":"string","enum":["search_result"]},"source":{"type":"string"},"title":{"type":"string"},"content":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","source","title","content"]},{"type":"object","properties":{"type":{"type":"string","enum":["web_search_tool_result"]},"tool_use_id":{"type":"string"},"content":{"anyOf":[{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["web_search_result"]},"title":{"type":"string"},"url":{"type":"string"},"page_age":{"type":"string"},"encrypted_content":{"type":"string"}},"required":["type","title","url","encrypted_content"]}},{"type":"object","properties":{"type":{"type":"string","enum":["web_search_tool_result_error"]},"error_code":{"type":"string","enum":["invalid_tool_input","unavailable","max_uses_exceeded","too_many_requests","query_too_long","request_too_large"]}},"required":["type","error_code"]}]},"caller":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["direct"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["code_execution_20250825"]},"tool_id":{"type":"string"}},"required":["type","tool_id"]},{"type":"object","properties":{"type":{"type":"string","enum":["code_execution_20260120"]},"tool_id":{"type":"string"}},"required":["type","tool_id"]}]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","tool_use_id","content"]},{"type":"object","properties":{"type":{"type":"string","enum":["web_fetch_tool_result"]},"tool_use_id":{"type":"string"},"content":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["web_fetch_tool_result_error"]},"error_code":{"type":"string","enum":["invalid_tool_input","url_too_long","url_not_allowed","url_not_accessible","unsupported_content_type","too_many_requests","max_uses_exceeded","unavailable"]}},"required":["type","error_code"]},{"type":"object","properties":{"type":{"type":"string","enum":["web_fetch_result"]},"url":{"type":"string"},"retrieved_at":{"type":"string"},"content":{"type":"object","properties":{"type":{"type":"string","enum":["document"]},"source":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["base64"]},"media_type":{"type":"string","enum":["application/pdf","text/plain"]},"data":{"type":"string"}},"required":["type","media_type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["text"]},"media_type":{"type":"string","enum":["text/plain"]},"data":{"type":"string"}},"required":["type","media_type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["url"]},"url":{"type":"string","format":"uri"}},"required":["type","url"]},{"type":"object","properties":{"type":{"type":"string","enum":["content"]},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"nullable":true}}]}},"required":["type","content"]}]},"title":{"type":"string"},"context":{"type":"string"},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","source"]}},"required":["type","url","content"]}]},"caller":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["direct"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["code_execution_20250825"]},"tool_id":{"type":"string"}},"required":["type","tool_id"]},{"type":"object","properties":{"type":{"type":"string","enum":["code_execution_20260120"]},"tool_id":{"type":"string"}},"required":["type","tool_id"]}]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","tool_use_id","content"]},{"type":"object","properties":{"type":{"type":"string","enum":["code_execution_tool_result"]},"tool_use_id":{"type":"string"},"content":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["code_execution_tool_result_error"]},"error_code":{"type":"string","enum":["invalid_tool_input","unavailable","too_many_requests","execution_time_exceeded"]}},"required":["type","error_code"]},{"type":"object","properties":{"type":{"type":"string","enum":["code_execution_result"]},"stdout":{"type":"string"},"stderr":{"type":"string"},"return_code":{"type":"number"},"content":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["code_execution_output"]},"file_id":{"type":"string"}},"required":["type","file_id"]}}},"required":["type","stdout","stderr","return_code"]},{"type":"object","properties":{"type":{"type":"string","enum":["encrypted_code_execution_result"]},"encrypted_stdout":{"type":"string"},"stderr":{"type":"string"},"return_code":{"type":"number"},"content":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["code_execution_output"]},"file_id":{"type":"string"}},"required":["type","file_id"]}}},"required":["type","encrypted_stdout","stderr","return_code"]}]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","tool_use_id","content"]},{"type":"object","properties":{"type":{"type":"string","enum":["bash_code_execution_tool_result"]},"tool_use_id":{"type":"string"},"content":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["bash_code_execution_tool_result_error"]},"error_code":{"type":"string","enum":["invalid_tool_input","unavailable","too_many_requests","execution_time_exceeded","output_file_too_large"]}},"required":["type","error_code"]},{"type":"object","properties":{"type":{"type":"string","enum":["bash_code_execution_result"]},"stdout":{"type":"string"},"stderr":{"type":"string"},"return_code":{"type":"number"},"content":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["bash_code_execution_output"]},"file_id":{"type":"string"}},"required":["type","file_id"]}}},"required":["type","stdout","stderr","return_code"]}]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","tool_use_id","content"]},{"type":"object","properties":{"type":{"type":"string","enum":["text_editor_code_execution_tool_result"]},"tool_use_id":{"type":"string"},"content":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text_editor_code_execution_tool_result_error"]},"error_code":{"type":"string","enum":["invalid_tool_input","unavailable","too_many_requests","execution_time_exceeded","file_not_found"]},"error_message":{"type":"string"}},"required":["type","error_code"]},{"type":"object","properties":{"type":{"type":"string","enum":["text_editor_code_execution_view_result"]},"content":{"type":"string"},"file_type":{"type":"string","enum":["text","image","pdf"]},"start_line":{"type":"number"},"num_lines":{"type":"number"},"total_lines":{"type":"number"}},"required":["type","content","file_type"]},{"type":"object","properties":{"type":{"type":"string","enum":["text_editor_code_execution_create_result"]},"is_file_update":{"type":"boolean"}},"required":["type","is_file_update"]},{"type":"object","properties":{"type":{"type":"string","enum":["text_editor_code_execution_str_replace_result"]},"old_start":{"type":"number"},"old_lines":{"type":"number"},"new_start":{"type":"number"},"new_lines":{"type":"number"},"lines":{"type":"array","items":{"type":"string"}}},"required":["type"]}]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","tool_use_id","content"]},{"type":"object","properties":{"type":{"type":"string","enum":["tool_search_tool_result"]},"tool_use_id":{"type":"string"},"content":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["tool_search_tool_result_error"]},"error_code":{"type":"string","enum":["invalid_tool_input","unavailable","too_many_requests","execution_time_exceeded"]}},"required":["type","error_code"]},{"type":"object","properties":{"type":{"type":"string","enum":["tool_search_tool_search_result"]},"tool_references":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["tool_reference"]},"tool_name":{"type":"string"},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","tool_name"]}}},"required":["type","tool_references"]}]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","tool_use_id","content"]},{"type":"object","properties":{"type":{"type":"string","enum":["redacted_thinking"]},"data":{"type":"string"}},"required":["type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["document"]},"source":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["base64"]},"media_type":{"type":"string","enum":["application/pdf","text/plain"]},"data":{"type":"string"}},"required":["type","media_type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["text"]},"media_type":{"type":"string","enum":["text/plain"]},"data":{"type":"string"}},"required":["type","media_type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["url"]},"url":{"type":"string","format":"uri"}},"required":["type","url"]},{"type":"object","properties":{"type":{"type":"string","enum":["content"]},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"nullable":true}}]}},"required":["type","content"]}]},"title":{"type":"string"},"context":{"type":"string"},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","source"]}]}}]}},"required":["role","content"]},{"type":"object","properties":{"role":{"type":"string","enum":["system"]},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}]}},"required":["role","content"]}]}},{"type":"array","items":{"oneOf":[{"type":"object","properties":{"role":{"type":"string","enum":["system"],"description":"The role of the author of the message — in this case, the system."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the system message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"role":{"type":"string","enum":["user"],"description":"The role of the author of the message — in this case, the user"},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["image_url"]},"image_url":{"type":"object","properties":{"url":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"}],"description":"Either a URL of the image or the base64 encoded image data. "},"detail":{"type":"string","enum":["low","high","auto"],"description":"Specifies the detail level of the image. Currently supports JPG/JPEG, PNG, GIF, and WEBP formats."}},"required":["url"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","image_url"]},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"type":"object","properties":{"type":{"type":"string","enum":["base64"]},"media_type":{"type":"string","enum":["image/jpeg","image/png","image/gif","image/webp"]},"data":{"type":"string"}},"required":["type","media_type","data"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","source"]},{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["input_audio"],"description":"The type of the content part."},"input_audio":{"type":"object","properties":{"data":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"},{"type":"string"}],"description":"Either a URL of the audio or the base64 encoded audio data."},"format":{"type":"string","enum":["wav","mp3","audio/x-aac","audio/flac","audio/mp3","audio/m4a","audio/mpeg","audio/mpga","audio/mp4","audio/ogg","audio/pcm","audio/webm"],"description":"The format of the encoded audio data. Currently supports \"wav\" and \"mp3\"."}},"required":["data","format"]}},"required":["type","input_audio"]},{"type":"object","properties":{"type":{"type":"string","enum":["file"],"description":"The type of the content part."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]},"file":{"type":"object","properties":{"file_data":{"type":"string","description":"The file data, encoded in base64 and passed to the model as a string. Only PDF format is supported.\n        - Maximum size per file: Up to 512 MB and up to 2 million tokens.\n        - Maximum number of files: Up to 20 files can be attached to a single GPT application or Assistant. This limit applies throughout the application's lifetime.\n        - Maximum total file storage per user: 10 GB."},"file_id":{"type":"string"},"filename":{"type":"string","description":"The file name specified by the user. This name can be used to reference the file when interacting with the model, especially if multiple files are uploaded."}}}},"required":["type","file"]},{"type":"object","properties":{"type":{"type":"string","enum":["video_url"]},"video_url":{"type":"object","properties":{"url":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"}],"description":"Base64-encoded local video file."}},"required":["url"]}},"required":["type","video_url"]}]}}],"description":"The contents of the user message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the tool message."},"tool_call_id":{"type":"string","description":"Tool call that this message is responding to."},"name":{"type":"string","nullable":true,"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content","tool_call_id"]},{"type":"object","properties":{"role":{"type":"string","enum":["function"]},"content":{"type":"string"},"name":{"type":"string"}},"required":["role","content","name"]},{"type":"object","properties":{"role":{"type":"string","enum":["assistant"],"description":"The role of the author of the message — in this case, the Assistant."},"content":{"anyOf":[{"type":"string","description":"The contents of the Assistant message."},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"refusal":{"type":"string","description":"The refusal message generated by the model."},"type":{"type":"string","enum":["refusal"],"description":"The type of the content part."}},"required":["refusal","type"]}]},"description":"An array of content parts with a defined type. Can be one or more of type text, or exactly one of type refusal."},{"nullable":true}],"description":"The contents of the Assistant message. Required unless tool_calls or function_call is specified."},"tool_calls":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."},"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."}},"required":["name","arguments"],"description":"The function that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","function"]},{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool to call."},"input":{"type":"string","description":"The input for the custom tool call generated by the model."}},"required":["name","input"],"description":"The custom tool that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","custom"]}]},"description":"The tool calls generated by the model, such as function calls."},"reasoning_content":{"type":"string"},"refusal":{"type":"string","nullable":true,"description":"The refusal message by the Assistant."},"audio":{"type":"object","nullable":true,"properties":{"id":{"type":"string","description":"Unique identifier for a previous audio response from the model."}},"required":["id"],"description":"Data about a previous audio response from the model."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role"]},{"type":"object","properties":{"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the developer message."},"role":{"type":"string","enum":["developer"],"description":"The role of the author of the message — in this case, the developer."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["content","role"]}]}}],"description":"A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, documents (txt, pdf), images, and audio."},"metadata":{"type":"object","additionalProperties":{"type":"string"},"description":"An object describing metadata about the request"},"stop_sequences":{"type":"array","items":{"type":"string"},"description":"Custom text sequences that will cause the model to stop generating."},"stream":{"type":"boolean","default":false,"description":"If set to True, the model response data will be streamed to the client as it is generated using server-sent events."},"system":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"default":"text"},"text":{"type":"string"},"citations":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["char_location"]},"cited_text":{"type":"string"},"document_index":{"type":"number"},"document_title":{"type":"string"},"end_char_index":{"type":"number"},"start_char_index":{"type":"number"}},"required":["type","cited_text","document_index","document_title","end_char_index","start_char_index"]},{"type":"object","properties":{"type":{"type":"string","enum":["page_location"]},"cited_text":{"type":"string"},"document_index":{"type":"number"},"document_title":{"type":"string"},"end_page_number":{"type":"number"},"start_page_number":{"type":"number"}},"required":["type","cited_text","document_index","document_title","end_page_number","start_page_number"]},{"type":"object","properties":{"type":{"type":"string","enum":["content_block_location"]},"cited_text":{"type":"string"},"document_index":{"type":"number"},"document_title":{"type":"string"},"end_block_index":{"type":"number"},"start_block_index":{"type":"number"}},"required":["type","cited_text","document_index","document_title","end_block_index","start_block_index"]},{"type":"object","properties":{"type":{"type":"string","enum":["web_search_result_location"]},"cited_text":{"type":"string"},"encrypted_index":{"type":"string"},"title":{"type":"string"},"url":{"type":"string"}},"required":["type","cited_text","encrypted_index","title","url"]},{"type":"object","properties":{"type":{"type":"string","enum":["search_result_location"]},"cited_text":{"type":"string"},"end_block_index":{"type":"number"},"search_result_index":{"type":"number"},"source":{"type":"string"},"start_block_index":{"type":"number"},"title":{"type":"string"}},"required":["type","cited_text","end_block_index","search_result_index","source","start_block_index","title"]}]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["text"]}}],"description":"A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role."},"tool_choice":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["auto"]},"disable_parallel_tool_use":{"type":"boolean"}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["any"]},"disable_parallel_tool_use":{"type":"boolean"}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string","enum":["tool"]},"disable_parallel_tool_use":{"type":"boolean"}},"required":["name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["none"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","minLength":1}},"required":["type"]},{"type":"string","enum":["none","auto","required"],"description":"none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."}},"required":["name"]}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["allowed_tools"],"description":"The type of the tool. Currently, only function is supported."},"allowed_tools":{"type":"object","properties":{"mode":{"type":"string","enum":["auto","required"],"description":"Constrains the tools available to the model to a pre-defined set.\n- auto allows the model to pick from among the allowed tools and generate a message.\n- required requires the model to call one or more of the allowed tools."},"tools":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}},"description":"A list of tool definitions that the model should be allowed to call."}},"required":["mode","tools"]}},"required":["type","allowed_tools"],"description":"Constrains the tools available to the model to a pre-defined set."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"string","enum":["name"],"description":"The name of the function to call."}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"string","enum":["name"],"description":"The name of the custom tool to call."}},"required":["type","custom"],"description":"Specifies a tool the model should use. Use to force the model to call a specific custom tool."}],"description":"Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {\"type\": \"function\", \"function\": {\"name\": \"my_function\"}} forces the model to call that tool.\n  none is the default when no tools are present. auto is the default if tools are present."},"tools":{"anyOf":[{"type":"array","items":{"anyOf":[{"oneOf":[{"type":"object","properties":{"name":{"type":"string","description":"Name of the tool."},"description":{"type":"string","description":"Description of what this tool does.\n  Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema."},"input_schema":{"type":"object","properties":{"type":{"type":"string","enum":["object"]},"properties":{"nullable":true},"required":{"type":"array","items":{"type":"string"}}},"required":["type"],"additionalProperties":{"nullable":true},"description":"JSON schema for this tool's input.\n  This defines the shape of the input that your tool accepts and that the model will produce."},"type":{"type":"string","enum":["custom"]},"defer_loading":{"type":"boolean"},"eager_input_streaming":{"type":"boolean"},"input_examples":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["name","input_schema"]},{"type":"object","properties":{"name":{"type":"string","enum":["bash"],"default":"bash"},"type":{"type":"string","enum":["bash_20250124"]},"input_examples":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["code_execution"],"default":"code_execution"},"type":{"type":"string","enum":["code_execution_20250522"]},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["code_execution"],"default":"code_execution"},"type":{"type":"string","enum":["code_execution_20250825"]},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["code_execution"],"default":"code_execution"},"type":{"type":"string","enum":["code_execution_20260120"]},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["memory"],"default":"memory"},"type":{"type":"string","enum":["memory_20250818"]},"input_examples":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["str_replace_editor"],"default":"str_replace_editor"},"type":{"type":"string","enum":["text_editor_20250124"]},"input_examples":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["str_replace_based_edit_tool"],"default":"str_replace_based_edit_tool"},"type":{"type":"string","enum":["text_editor_20250429"]},"input_examples":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["str_replace_based_edit_tool"],"default":"str_replace_based_edit_tool"},"type":{"type":"string","enum":["text_editor_20250728"]},"max_characters":{"type":"number"},"input_examples":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["web_search"],"default":"web_search"},"type":{"type":"string","enum":["web_search_20250305"]},"allowed_domains":{"type":"array","items":{"type":"string"}},"blocked_domains":{"type":"array","items":{"type":"string"}},"max_uses":{"type":"number"},"user_location":{"type":"object","properties":{"type":{"type":"string","enum":["approximate"]},"city":{"type":"string"},"country":{"type":"string"},"region":{"type":"string"},"timezone":{"type":"string"}},"required":["type"]},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["web_search"],"default":"web_search"},"type":{"type":"string","enum":["web_search_20260209"]},"allowed_domains":{"type":"array","items":{"type":"string"}},"blocked_domains":{"type":"array","items":{"type":"string"}},"max_uses":{"type":"number"},"user_location":{"type":"object","properties":{"type":{"type":"string","enum":["approximate"]},"city":{"type":"string"},"country":{"type":"string"},"region":{"type":"string"},"timezone":{"type":"string"}},"required":["type"]},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["web_fetch"],"default":"web_fetch"},"type":{"type":"string","enum":["web_fetch_20250910"]},"allowed_domains":{"type":"array","items":{"type":"string"}},"blocked_domains":{"type":"array","items":{"type":"string"}},"citations":{"type":"object","properties":{"enabled":{"type":"boolean"}}},"max_content_tokens":{"type":"number"},"max_uses":{"type":"number"},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["web_fetch"],"default":"web_fetch"},"type":{"type":"string","enum":["web_fetch_20260209"]},"allowed_domains":{"type":"array","items":{"type":"string"}},"blocked_domains":{"type":"array","items":{"type":"string"}},"citations":{"type":"object","properties":{"enabled":{"type":"boolean"}}},"max_content_tokens":{"type":"number"},"max_uses":{"type":"number"},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["web_fetch"],"default":"web_fetch"},"type":{"type":"string","enum":["web_fetch_20260309"]},"allowed_domains":{"type":"array","items":{"type":"string"}},"blocked_domains":{"type":"array","items":{"type":"string"}},"citations":{"type":"object","properties":{"enabled":{"type":"boolean"}}},"max_content_tokens":{"type":"number"},"max_uses":{"type":"number"},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["tool_search_tool_bm25"],"default":"tool_search_tool_bm25"},"type":{"type":"string","enum":["tool_search_tool_bm25_20251119","tool_search_tool_bm25"]},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string","enum":["tool_search_tool_regex"],"default":"tool_search_tool_regex"},"type":{"type":"string","enum":["tool_search_tool_regex_20251119","tool_search_tool_regex"]},"defer_loading":{"type":"boolean"},"strict":{"type":"boolean"},"allowed_callers":{"type":"array","items":{"type":"string","enum":["direct","code_execution_20250825","code_execution_20260120"]}},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type"]}]},{"type":"object","properties":{"type":{"type":"string","minLength":1}},"required":["type"]}]}},{"type":"array","items":{"anyOf":[{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"description":{"type":"string","description":"A description of what the function does, used by the model to choose when and how to call the function."},"name":{"type":"string","description":"The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"parameters":{"type":"object","additionalProperties":{"nullable":true,"description":"The parameters the functions accepts, described as a JSON Schema object."}},"strict":{"type":"boolean","nullable":true,"description":"Whether to enable strict schema adherence when generating the function call. If set to True, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is True."}},"required":["name"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","function"]},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool, used to identify it in tool calls."},"description":{"type":"string","description":"Optional description of the custom tool, used to provide more context."},"format":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["grammar"]},"grammar":{"type":"object","properties":{"definition":{"type":"string","description":"The grammar definition."},"syntax":{"type":"string","enum":["lark","regex"],"description":"The syntax of the grammar definition."}},"required":["definition","syntax"]}},"required":["type","grammar"]}],"description":"The input format for the custom tool. Default is unconstrained text."}},"required":["name","format"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","custom"]}]},{"type":"object","properties":{"type":{"type":"string","minLength":1}},"required":["type"]}]}}],"description":"Definitions of tools that the model may use.\n  If you include tools in your API request, the model may return tool_use content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using tool_result content blocks.\n  Each tool definition includes:\n      name: Name of the tool.\n      description: Optional, but strongly-recommended description of the tool.\n      input_schema: JSON schema for the tool input shape that the model will produce in tool_use output content blocks."},"thinking":{"anyOf":[{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["enabled"]},"budget_tokens":{"type":"integer","minimum":1024,"description":"Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality. Must be ≥1024 and less than max_tokens."},"display":{"type":"string","enum":["summarized","omitted"],"default":"summarized"}},"required":["type","budget_tokens"]},{"type":"object","properties":{"type":{"type":"string","enum":["disabled"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["adaptive"]},"display":{"type":"string","enum":["summarized","omitted"],"default":"summarized"}},"required":["type"]}]},{"type":"object","properties":{"type":{"type":"string","minLength":1}},"required":["type"]}],"description":"Configuration for enabling Claude's extended thinking. When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your max_tokens limit."},"max_tokens":{"type":"number","default":128000,"description":"The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API."},"reasoning_effort":{"type":"string","enum":["none","low","medium","high","xhigh","max"],"description":"Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response."},"router":{"type":"object","properties":{"decision_model":{"type":"string","enum":["typesafe/jev-1.14","typesafe/jev-1.13","typesafe/jev","liquid/d1","liquid/d1.1","liquid/d1-ultra"],"description":"The decision model that picks each request's bucket. Default `typesafe/jev-1.14`. `typesafe/jev` is always the newest Jev; name a version to stay on it. Only decision models are accepted here, never a model that answers. Every judgement is billed at that model's catalogue price and listed as its own request in your usage; turns that need none (tool results, a forced bucket, a single bucket) pay nothing for it. It is shown the request's images, up to 8 — billed as its input tokens — and never resizes one: Jev reads PNG or JPEG of 280 to 1568 px a side; the Liquid models JPEG, PNG or WebP, up to 10,000 patches of 32 × 32 px in all and 4.5 MiB per request. A request whose own images do not fit is refused with a 400 that says what to change, before anything is charged."},"buckets":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","maxLength":32,"pattern":"^[A-Za-z0-9][A-Za-z0-9_.-]*$","description":"The bucket's name, unique in the router: 1 to 32 letters, digits, `-`, `_` or `.`. Name it in `default_bucket` and `force_bucket`; the response's `meta.router.bucket` says which one answered."},"when":{"type":"string","minLength":1,"maxLength":500,"description":"What the requests this bucket takes look like, in your words (1 to 500 characters) — for example \"unsolicited advertising, prize claims or phishing\". The decision model picks the bucket whose `when` fits each request best. Required on every bucket when there are two or more; a single bucket has none."},"models":{"type":"array","items":{"anyOf":[{"type":"string","description":"A model id, as you would pass it in `model` (see `GET /v1/models`): a chat, image or video model."},{"type":"object","properties":{"model":{"type":"string"}},"required":["model"],"additionalProperties":false,"description":"The same model id, as an object: `{ \"model\": \"<id>\" }`."}],"description":"A model this bucket may answer with."},"maxItems":10,"description":"1 to 10 models, in the order to try them: the first one that can take the request (its tools, images, JSON schema and context size; on image and video generation, every input image field it sets) answers, and if it fails the next one does. Chat, image and video models side by side: a request takes the bucket's models of its own kind — a chat completion its chat models, an image generation its image models — and a bucket with none of its kind sends it on to the next bucket that has one (`meta.router.spilled_from`). Only models we serve — not routers, not decision models. Models you list run with your request's own settings, reasoning included. Or none (`[]`): a request the decision model puts in this bucket ends at the decision — no model is called, and the response is empty in its endpoint's shape (an assistant message with `content: \"\"` and `finish_reason: \"stop\"`; `data: []` for images; a video generation `completed` with `video: null`) and its `meta.router` says `\"routed\": false` and names the bucket, so your code acts on it. Only the judgement is charged. Not on a single bucket, which is never judged."}},"required":["name","models"],"additionalProperties":false,"description":"One bucket: its name, what it takes, and its models."},"minItems":1,"maxItems":10,"description":"Your buckets, 1 to 10: they replace the default buckets entirely. With two or more, each needs a `when`, and the decision model picks the one that fits each request. A single bucket is a fallback chain — every request goes to it, with no judgement. Left out: the default buckets — `light` (\"Needs little capability: greetings and small talk, one-line or lookup answers, common knowledge, short routine tasks such as a short piece of writing, a quick rewrite or simple arithmetic — a small, fast model answers it well\"): `openai/gpt-6-luna`, `anthropic/claude-haiku-5.5`, `deepseek/deepseek-v4.1-flash`, `google/gemini-3-1-flash-lite`, `google/gemini-3-5-flash-lite`; `standard` (\"Needs a capable model: multi-step tasks that need care and accuracy\"): `openai/gpt-6.1-sol`, `anthropic/claude-sonnet-5.5`; `heavy` (\"Needs the strongest model: complex reasoning, hard math or proofs, large or tricky code, expert-level or research-grade knowledge\"): `anthropic/claude-opus-5.5`, `openai/gpt-6-astra` — which route conversations only (chat completions, the Responses API, the Messages API: on each, the models of a bucket served there); image and video requests need buckets of your own."},"default_bucket":{"type":"string","description":"Where a request goes when it is not judged — the decision model failed, timed out or named no bucket, or the request has no text — and where one goes when none of its bucket's models can take it, before the others are tried. Default: your first bucket; `standard` for the default buckets. Required when your first bucket lists no models: a request that is not judged would otherwise end there, unanswered by any model."},"force_bucket":{"type":"string","description":"Send the request to this bucket without judging it (nothing is charged for a judgement)."},"min_confidence":{"type":"number","minimum":0,"maximum":1,"description":"Below this confidence in its answer (0 to 1), a request goes to `default_bucket` instead (`meta.router.reason`: `unsure`) — for example, send what the decision model is unsure about to your strongest bucket. The judgement is still paid for. On a ladder an unsure turn never moves the conversation up, so a high value keeps conversations on the first rung: measured at 0.9, 40–45% of explicit conversations stayed there."},"ladder":{"type":"boolean","description":"Your buckets are a ladder's rungs: the first is the strictest, each next one more relaxed, and a last one may list no models (`models: []`), where a conversation ends. A conversation only moves down: each new turn — the previous reply and the new message — is judged against every rung, and the conversation goes to the lowest one it needs, and stays — never up: a rung above it keeps it where it is. It climbs back only once what moved it is gone from its history. Send each answer's `meta.router.state` back as `router.state`: with it only what is new is judged, and the conversation stays on its rung's model; without it, or when it does not fit the conversation, the whole conversation is judged again, two windows of 2,000 characters at a time, the newest first, at most 24 judgements — each billed as its own request; a conversation takes up to 5,000 messages, and a turn up to about 288,000 characters of new text. An unsure or failed judgement takes `default_bucket` but never moves a conversation up: name your last rung as `default_bucket` to fail closed. A turn returning tool results goes back to the model that made the calls, unjudged, while nothing new but the model's own calls comes with it. A model that cannot take a turn is passed over for one of a rung below, never above. `force_bucket` is not allowed. Only the user’s and the assistant’s messages are judged — their text and images — never your instructions (`system`) or tool results; an image the decision model cannot be shown (past its limits, or a link we could not store) takes `default_bucket`. A judgement that fails moves nothing for good: what it was to judge is judged again with the next turns, and given up on, at `default_bucket`, only after failing on its own three turns running."},"state":{"type":"string","maxLength":1024,"description":"With `ladder: true`: the previous answer's `meta.router.state`, unchanged. A Responses turn that continues a stored response (`previous_response_id`) needs none: the response keeps its own."}},"additionalProperties":false,"description":"How `aimlapi/dynamic-router` routes this request. Every setting is optional: left out, or `{}`, a conversation — chat completions, Responses, Messages — routes by the default buckets, like `typesafe/jev-router`; a setting you leave out keeps its default, and `buckets`, when given, are the whole table. The same `router` serves chat completions, the Responses API, the Messages API, image generation and editing, and video generation: the decision model judges the request's text — on media, its prompt — and its images, and the request takes the models of its own kind from the bucket. A conversation stays on its model while its turns land in the same bucket, and a turn returning tool results always goes back to the model that made the calls. A Responses turn that continues a stored response (`previous_response_id`) is judged like any other turn and runs only on a model served where that response is kept: it stays with the model that wrote it while it lands in that model's bucket, and a bucket with no models ends it at the decision. The response says where the request went in `meta.router` (`routed`, bucket, reason, the decision model's choice and confidence, the judgement, its charge and the images it was shown) and which model answered in `meta.model` — the router itself when the bucket lists no models; on video, on the submit's response; on a Messages stream, on its `message_stop` event. An invalid configuration is answered with a 400 that names each setting to fix, before anything is charged. In a multipart request (an image edit sending its picture as a file), send `router` as its JSON, in one text field."}},"required":["model","messages"],"title":"aimlapi/dynamic-router"},{"type":"object","properties":{"model":{"type":"string","enum":["aimlapi/dynamic-router"]},"provider":{"type":"string","description":"Provider routing override. Use a source key such as `openai`, `opentree`, `xai`, `google`, `alibaba`, `minimax`, `moonshot`, `baidu`, or `togetherai` to run that provider with no fallback; `auto` (default) uses the full fallback chain. Case-insensitive."},"messages":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"role":{"type":"string","enum":["user"],"description":"The role of the author of the message — in this case, the user"},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["image_url"]},"image_url":{"type":"object","properties":{"url":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"}],"description":"Either a URL of the image or the base64 encoded image data. "},"detail":{"type":"string","enum":["low","high","auto"],"description":"Specifies the detail level of the image. Currently supports JPG/JPEG, PNG, GIF, and WEBP formats."}},"required":["url"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","image_url"]},{"type":"object","properties":{"type":{"type":"string","enum":["file"],"description":"The type of the content part."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]},"file":{"type":"object","properties":{"file_data":{"type":"string","description":"The file data, encoded in base64 and passed to the model as a string. Only PDF format is supported.\n        - Maximum size per file: Up to 512 MB and up to 2 million tokens.\n        - Maximum number of files: Up to 20 files can be attached to a single GPT application or Assistant. This limit applies throughout the application's lifetime.\n        - Maximum total file storage per user: 10 GB."},"file_id":{"type":"string"},"filename":{"type":"string","description":"The file name specified by the user. This name can be used to reference the file when interacting with the model, especially if multiple files are uploaded."}}}},"required":["type","file"]}]}}],"description":"The contents of the user message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the developer message."},"role":{"type":"string","enum":["developer"],"description":"The role of the author of the message — in this case, the developer."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["content","role"]},{"type":"object","properties":{"role":{"type":"string","enum":["system"],"description":"The role of the author of the message — in this case, the system."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the system message."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content"]},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"anyOf":[{"type":"string"},{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]}}],"description":"The contents of the tool message."},"tool_call_id":{"type":"string","description":"Tool call that this message is responding to."},"name":{"type":"string","nullable":true,"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"required":["role","content","tool_call_id"]},{"type":"object","properties":{"role":{"type":"string","enum":["assistant"],"description":"The role of the author of the message — in this case, the Assistant."},"content":{"anyOf":[{"type":"string","description":"The contents of the Assistant message."},{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of the content part."},"text":{"type":"string","description":"The text content."},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","text"]},{"type":"object","properties":{"refusal":{"type":"string","description":"The refusal message generated by the model."},"type":{"type":"string","enum":["refusal"],"description":"The type of the content part."}},"required":["refusal","type"]}]},"description":"An array of content parts with a defined type. Can be one or more of type text, or exactly one of type refusal."},{"nullable":true}],"description":"The contents of the Assistant message. Required unless tool_calls or function_call is specified."},"name":{"type":"string","description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."},"tool_calls":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."},"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."}},"required":["name","arguments"],"description":"The function that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","function"]},{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool to call."},"input":{"type":"string","description":"The input for the custom tool call generated by the model."}},"required":["name","input"],"description":"The custom tool that the model called."},"extra_content":{"type":"object","additionalProperties":{"nullable":true},"description":"Opaque provider metadata for this tool call (e.g. Gemini thought_signature). Echo it back unchanged on the next turn."}},"required":["id","type","custom"]}]},"description":"The tool calls generated by the model, such as function calls."},"refusal":{"type":"string","nullable":true,"description":"The refusal message by the Assistant."}},"required":["role"]}]},"description":"A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, documents (txt, pdf), images, and audio."},"max_tokens":{"type":"number","minimum":1,"description":"The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API."},"stream":{"type":"boolean","default":false,"description":"If set to True, the model response data will be streamed to the client as it is generated using server-sent events."},"stream_options":{"type":"object","properties":{"include_usage":{"type":"boolean"}},"required":["include_usage"]},"tools":{"type":"array","items":{"anyOf":[{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"description":{"type":"string","description":"A description of what the function does, used by the model to choose when and how to call the function."},"name":{"type":"string","description":"The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"parameters":{"type":"object","additionalProperties":{"nullable":true,"description":"The parameters the functions accepts, described as a JSON Schema object."}},"strict":{"type":"boolean","nullable":true,"description":"Whether to enable strict schema adherence when generating the function call. If set to True, the model will follow the exact schema defined in the parameters field. Only a subset of JSON Schema is supported when strict is True."}},"required":["name"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","function"]},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"object","properties":{"name":{"type":"string","description":"The name of the custom tool, used to identify it in tool calls."},"description":{"type":"string","description":"Optional description of the custom tool, used to provide more context."},"format":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["grammar"]},"grammar":{"type":"object","properties":{"definition":{"type":"string","description":"The grammar definition."},"syntax":{"type":"string","enum":["lark","regex"],"description":"The syntax of the grammar definition."}},"required":["definition","syntax"]}},"required":["type","grammar"]}],"description":"The input format for the custom tool. Default is unconstrained text."}},"required":["name","format"]},"cache_control":{"type":"object","properties":{"type":{"type":"string","enum":["ephemeral"]},"ttl":{"type":"string","enum":["5m","1h"]}},"required":["type"]}},"required":["type","custom"]}]},{"type":"object","properties":{"type":{"type":"string","minLength":1}},"required":["type"]}]},"description":"A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported."},"tool_choice":{"anyOf":[{"type":"string","enum":["none","auto","required"],"description":"none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"object","properties":{"name":{"type":"string","description":"The name of the function to call."}},"required":["name"]}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["allowed_tools"],"description":"The type of the tool. Currently, only function is supported."},"allowed_tools":{"type":"object","properties":{"mode":{"type":"string","enum":["auto","required"],"description":"Constrains the tools available to the model to a pre-defined set.\n- auto allows the model to pick from among the allowed tools and generate a message.\n- required requires the model to call one or more of the allowed tools."},"tools":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}},"description":"A list of tool definitions that the model should be allowed to call."}},"required":["mode","tools"]}},"required":["type","allowed_tools"],"description":"Constrains the tools available to the model to a pre-defined set."},{"type":"object","properties":{"type":{"type":"string","enum":["function"],"description":"The type of the tool. Currently, only function is supported."},"function":{"type":"string","enum":["name"],"description":"The name of the function to call."}},"required":["type","function"],"description":"Specifies a tool the model should use. Use to force the model to call a specific function."},{"type":"object","properties":{"type":{"type":"string","enum":["custom"],"description":"The type of the tool. Currently, only function is supported."},"custom":{"type":"string","enum":["name"],"description":"The name of the custom tool to call."}},"required":["type","custom"],"description":"Specifies a tool the model should use. Use to force the model to call a specific custom tool."}],"description":"Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {\"type\": \"function\", \"function\": {\"name\": \"my_function\"}} forces the model to call that tool.\n  none is the default when no tools are present. auto is the default if tools are present."},"normalize_tool_schemas":{"type":"boolean","description":"Enable provider compatibility normalization for tool function JSON schemas."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"n":{"type":"integer","nullable":true,"minimum":1,"description":"How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs."},"seed":{"type":"integer","minimum":1,"description":"This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result."},"reasoning_effort":{"type":"string","enum":["low","medium","high","xhigh"],"description":"Constrains effort on reasoning for reasoning models. Currently supported values are low, medium, and high. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response."},"response_format":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["text"],"description":"The type of response format being defined. Always text."}},"required":["type"],"additionalProperties":false,"description":"Default response format. Used to generate text responses."},{"type":"object","properties":{"type":{"type":"string","enum":["json_object"],"description":"The type of response format being defined. Always json_object."}},"required":["type"],"additionalProperties":false,"description":"An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so."},{"type":"object","properties":{"type":{"type":"string","enum":["json_schema"],"description":"The type of response format being defined. Always json_schema."},"json_schema":{"type":"object","properties":{"name":{"type":"string","description":"The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"schema":{"type":"object","additionalProperties":{"nullable":true},"description":"The schema for the response format, described as a JSON Schema object."},"strict":{"type":"boolean","nullable":true,"description":"Whether to enable strict schema adherence when generating the output. If set to True, the model will always follow the exact schema defined in the schema field. Only a subset of JSON Schema is supported when strict is True."},"description":{"type":"string","description":"A description of what the response format is for, used by the model to determine how to respond in the format."}},"required":["name"],"additionalProperties":false,"description":"JSON Schema response format. Used to generate structured JSON responses."}},"required":["type","json_schema"],"additionalProperties":false,"description":"JSON Schema response format. Used to generate structured JSON responses."}],"description":"An object specifying the format that the model must output."},"router":{"type":"object","properties":{"decision_model":{"type":"string","enum":["typesafe/jev-1.14","typesafe/jev-1.13","typesafe/jev","liquid/d1","liquid/d1.1","liquid/d1-ultra"],"description":"The decision model that picks each request's bucket. Default `typesafe/jev-1.14`. `typesafe/jev` is always the newest Jev; name a version to stay on it. Only decision models are accepted here, never a model that answers. Every judgement is billed at that model's catalogue price and listed as its own request in your usage; turns that need none (tool results, a forced bucket, a single bucket) pay nothing for it. It is shown the request's images, up to 8 — billed as its input tokens — and never resizes one: Jev reads PNG or JPEG of 280 to 1568 px a side; the Liquid models JPEG, PNG or WebP, up to 10,000 patches of 32 × 32 px in all and 4.5 MiB per request. A request whose own images do not fit is refused with a 400 that says what to change, before anything is charged."},"buckets":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","maxLength":32,"pattern":"^[A-Za-z0-9][A-Za-z0-9_.-]*$","description":"The bucket's name, unique in the router: 1 to 32 letters, digits, `-`, `_` or `.`. Name it in `default_bucket` and `force_bucket`; the response's `meta.router.bucket` says which one answered."},"when":{"type":"string","minLength":1,"maxLength":500,"description":"What the requests this bucket takes look like, in your words (1 to 500 characters) — for example \"unsolicited advertising, prize claims or phishing\". The decision model picks the bucket whose `when` fits each request best. Required on every bucket when there are two or more; a single bucket has none."},"models":{"type":"array","items":{"anyOf":[{"type":"string","description":"A model id, as you would pass it in `model` (see `GET /v1/models`): a chat, image or video model."},{"type":"object","properties":{"model":{"type":"string"}},"required":["model"],"additionalProperties":false,"description":"The same model id, as an object: `{ \"model\": \"<id>\" }`."}],"description":"A model this bucket may answer with."},"maxItems":10,"description":"1 to 10 models, in the order to try them: the first one that can take the request (its tools, images, JSON schema and context size; on image and video generation, every input image field it sets) answers, and if it fails the next one does. Chat, image and video models side by side: a request takes the bucket's models of its own kind — a chat completion its chat models, an image generation its image models — and a bucket with none of its kind sends it on to the next bucket that has one (`meta.router.spilled_from`). Only models we serve — not routers, not decision models. Models you list run with your request's own settings, reasoning included. Or none (`[]`): a request the decision model puts in this bucket ends at the decision — no model is called, and the response is empty in its endpoint's shape (an assistant message with `content: \"\"` and `finish_reason: \"stop\"`; `data: []` for images; a video generation `completed` with `video: null`) and its `meta.router` says `\"routed\": false` and names the bucket, so your code acts on it. Only the judgement is charged. Not on a single bucket, which is never judged."}},"required":["name","models"],"additionalProperties":false,"description":"One bucket: its name, what it takes, and its models."},"minItems":1,"maxItems":10,"description":"Your buckets, 1 to 10: they replace the default buckets entirely. With two or more, each needs a `when`, and the decision model picks the one that fits each request. A single bucket is a fallback chain — every request goes to it, with no judgement. Left out: the default buckets — `light` (\"Needs little capability: greetings and small talk, one-line or lookup answers, common knowledge, short routine tasks such as a short piece of writing, a quick rewrite or simple arithmetic — a small, fast model answers it well\"): `openai/gpt-6-luna`, `anthropic/claude-haiku-5.5`, `deepseek/deepseek-v4.1-flash`, `google/gemini-3-1-flash-lite`, `google/gemini-3-5-flash-lite`; `standard` (\"Needs a capable model: multi-step tasks that need care and accuracy\"): `openai/gpt-6.1-sol`, `anthropic/claude-sonnet-5.5`; `heavy` (\"Needs the strongest model: complex reasoning, hard math or proofs, large or tricky code, expert-level or research-grade knowledge\"): `anthropic/claude-opus-5.5`, `openai/gpt-6-astra` — which route conversations only (chat completions, the Responses API, the Messages API: on each, the models of a bucket served there); image and video requests need buckets of your own."},"default_bucket":{"type":"string","description":"Where a request goes when it is not judged — the decision model failed, timed out or named no bucket, or the request has no text — and where one goes when none of its bucket's models can take it, before the others are tried. Default: your first bucket; `standard` for the default buckets. Required when your first bucket lists no models: a request that is not judged would otherwise end there, unanswered by any model."},"force_bucket":{"type":"string","description":"Send the request to this bucket without judging it (nothing is charged for a judgement)."},"min_confidence":{"type":"number","minimum":0,"maximum":1,"description":"Below this confidence in its answer (0 to 1), a request goes to `default_bucket` instead (`meta.router.reason`: `unsure`) — for example, send what the decision model is unsure about to your strongest bucket. The judgement is still paid for. On a ladder an unsure turn never moves the conversation up, so a high value keeps conversations on the first rung: measured at 0.9, 40–45% of explicit conversations stayed there."},"ladder":{"type":"boolean","description":"Your buckets are a ladder's rungs: the first is the strictest, each next one more relaxed, and a last one may list no models (`models: []`), where a conversation ends. A conversation only moves down: each new turn — the previous reply and the new message — is judged against every rung, and the conversation goes to the lowest one it needs, and stays — never up: a rung above it keeps it where it is. It climbs back only once what moved it is gone from its history. Send each answer's `meta.router.state` back as `router.state`: with it only what is new is judged, and the conversation stays on its rung's model; without it, or when it does not fit the conversation, the whole conversation is judged again, two windows of 2,000 characters at a time, the newest first, at most 24 judgements — each billed as its own request; a conversation takes up to 5,000 messages, and a turn up to about 288,000 characters of new text. An unsure or failed judgement takes `default_bucket` but never moves a conversation up: name your last rung as `default_bucket` to fail closed. A turn returning tool results goes back to the model that made the calls, unjudged, while nothing new but the model's own calls comes with it. A model that cannot take a turn is passed over for one of a rung below, never above. `force_bucket` is not allowed. Only the user’s and the assistant’s messages are judged — their text and images — never your instructions (`system`) or tool results; an image the decision model cannot be shown (past its limits, or a link we could not store) takes `default_bucket`. A judgement that fails moves nothing for good: what it was to judge is judged again with the next turns, and given up on, at `default_bucket`, only after failing on its own three turns running."},"state":{"type":"string","maxLength":1024,"description":"With `ladder: true`: the previous answer's `meta.router.state`, unchanged. A Responses turn that continues a stored response (`previous_response_id`) needs none: the response keeps its own."}},"additionalProperties":false,"description":"How `aimlapi/dynamic-router` routes this request. Every setting is optional: left out, or `{}`, a conversation — chat completions, Responses, Messages — routes by the default buckets, like `typesafe/jev-router`; a setting you leave out keeps its default, and `buckets`, when given, are the whole table. The same `router` serves chat completions, the Responses API, the Messages API, image generation and editing, and video generation: the decision model judges the request's text — on media, its prompt — and its images, and the request takes the models of its own kind from the bucket. A conversation stays on its model while its turns land in the same bucket, and a turn returning tool results always goes back to the model that made the calls. A Responses turn that continues a stored response (`previous_response_id`) is judged like any other turn and runs only on a model served where that response is kept: it stays with the model that wrote it while it lands in that model's bucket, and a bucket with no models ends it at the decision. The response says where the request went in `meta.router` (`routed`, bucket, reason, the decision model's choice and confidence, the judgement, its charge and the images it was shown) and which model answered in `meta.model` — the router itself when the bucket lists no models; on video, on the submit's response; on a Messages stream, on its `message_stop` event. An invalid configuration is answered with a 400 that names each setting to fix, before anything is charged. In a multipart request (an image edit sending its picture as a file), send `router` as its JSON, in one text field."}},"required":["model","messages"],"title":"aimlapi/dynamic-router"}],"title":"aimlapi/dynamic-router"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"A unique identifier for the chat completion."},"object":{"type":"string","enum":["chat.completion"],"description":"The object type."},"created":{"type":"number","description":"The Unix timestamp (in seconds) of when the chat completion was created."},"choices":{"type":"array","items":{"type":"object","properties":{"index":{"type":"number","description":"The index of the choice in the list of choices."},"message":{"type":"object","properties":{"role":{"type":"string","description":"The role of the author of this message."},"content":{"type":"string","description":"The contents of the message."},"refusal":{"type":"string","nullable":true,"description":"The refusal message generated by the model."},"annotations":{"type":"array","nullable":true,"items":{"type":"object","properties":{"type":{"type":"string","enum":["url_citation"],"description":"The type of the URL citation. Always url_citation."},"url_citation":{"type":"object","properties":{"end_index":{"type":"integer","description":"The index of the last character of the URL citation in the message."},"start_index":{"type":"integer","description":"The index of the first character of the URL citation in the message."},"title":{"type":"string","description":"The title of the web resource."},"url":{"type":"string","description":"The URL of the web resource."}},"required":["end_index","start_index","title","url"],"description":"A URL citation when using web search."}},"required":["type","url_citation"]},"description":"Annotations for the message, when applicable, as when using the web search tool."},"audio":{"type":"object","nullable":true,"properties":{"id":{"type":"string","description":"Unique identifier for this audio response."},"data":{"type":"string","description":"Base64 encoded audio bytes generated by the model, in the format specified in the request."},"transcript":{"type":"string","description":"Transcript of the audio generated by the model."},"expires_at":{"type":"integer","description":"The Unix timestamp (in seconds) for when this audio response will no longer be accessible on the server for use in multi-turn conversations."}},"required":["id","data","transcript","expires_at"],"description":"A chat completion message generated by the model."},"tool_calls":{"type":"array","nullable":true,"items":{"oneOf":[{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["function"],"description":"The type of the tool."},"function":{"type":"object","properties":{"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."},"name":{"type":"string","description":"The name of the function to call."}},"required":["arguments","name"],"description":"The function that the model called."}},"required":["id","type","function"]},{"type":"object","properties":{"id":{"type":"string","description":"The ID of the tool call."},"type":{"type":"string","enum":["custom"],"description":"The type of the tool."},"custom":{"type":"object","properties":{"input":{"type":"string","description":"The input for the custom tool call generated by the model."},"name":{"type":"string","description":"The name of the custom tool to call."}},"required":["input","name"],"description":"The custom tool that the model called."}},"required":["id","type","custom"]}]},"description":"The tool calls generated by the model, such as function calls."}},"required":["role","content"],"description":"A chat completion message generated by the model."},"finish_reason":{"type":"string","enum":["stop","length","content_filter","tool_calls"],"description":"The reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence, length if the maximum number of tokens specified in the request was reached, content_filter if content was omitted due to a flag from our content filters, tool_calls if the model called a tool"},"logprobs":{"type":"object","nullable":true,"properties":{"content":{"type":"array","items":{"type":"object","properties":{"bytes":{"type":"array","items":{"type":"integer"},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token."},"logprob":{"type":"number","description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely."},"token":{"type":"string","description":"The token."},"top_logprobs":{"type":"array","nullable":true,"items":{"type":"object","properties":{"bytes":{"type":"array","nullable":true,"items":{"type":"integer"},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token."},"logprob":{"type":"number","description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely."},"token":{"type":"string","description":"The token."}},"required":["logprob","token"]},"description":"List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested top_logprobs returned."}},"required":["bytes","logprob","token"]},"description":"A list of message content tokens with log probability information."},"refusal":{"type":"array","items":{"type":"object","properties":{"bytes":{"type":"array","items":{"type":"integer"},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token."},"logprob":{"type":"number","description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely."},"token":{"type":"string","description":"The token."},"top_logprobs":{"type":"array","nullable":true,"items":{"type":"object","properties":{"bytes":{"type":"array","nullable":true,"items":{"type":"integer"},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token."},"logprob":{"type":"number","description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely."},"token":{"type":"string","description":"The token."}},"required":["logprob","token"]},"description":"List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested top_logprobs returned."}},"required":["bytes","logprob","token"]},"description":"A list of message refusal tokens with log probability information."}},"required":["content","refusal"],"description":"Log probability information for the choice."}},"required":["index","message","finish_reason"]}},"model":{"type":"string","description":"The model used for the chat completion."},"usage":{"type":"object","properties":{"prompt_tokens":{"type":"number","description":"Number of tokens in the prompt."},"completion_tokens":{"type":"number","description":"Number of tokens in the generated completion."},"total_tokens":{"type":"number","description":"Total number of tokens used in the request (prompt + completion)."},"completion_tokens_details":{"type":"object","nullable":true,"properties":{"accepted_prediction_tokens":{"type":"integer","nullable":true,"description":"When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion."},"audio_tokens":{"type":"integer","nullable":true,"description":"Audio input tokens generated by the model."},"reasoning_tokens":{"type":"integer","nullable":true,"description":"Tokens generated by the model for reasoning."},"rejected_prediction_tokens":{"type":"integer","nullable":true,"description":"When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion. However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing, output, and context window limits."}},"description":"Breakdown of tokens used in a completion."},"prompt_tokens_details":{"type":"object","nullable":true,"properties":{"audio_tokens":{"type":"integer","nullable":true,"description":"Audio input tokens present in the prompt."},"cached_tokens":{"type":"integer","nullable":true,"description":"Cached tokens present in the prompt."}},"description":"Breakdown of tokens used in the prompt."}},"required":["prompt_tokens","completion_tokens","total_tokens"],"description":"Usage statistics for the completion request."},"meta":{"type":"object","nullable":true,"properties":{"usage":{"type":"object","nullable":true,"properties":{"credits_used":{"type":"number","description":"The number of tokens consumed during generation."},"usd_spent":{"type":"number","description":"The total amount of money spent by the user in USD."}},"required":["credits_used","usd_spent"]},"model":{"type":"string","description":"The model that answered — the one the router chose, or the next one in its bucket if that one failed. The router itself when the request ended at the decision (`router.routed: false`). Its rate is what the answer cost."},"provider":{"type":"string","description":"The provider that served the answer; `aimlapi` when the request ended at the decision."},"router":{"type":"object","properties":{"id":{"type":"string","description":"The router the request named."},"routed":{"type":"boolean","description":"Whether a model answered. `false`: the request ended at the decision — `bucket` lists no models, so no model was called, the message is empty and nothing but the judgement was charged. Act on `bucket` (and `choice`, `confidence`)."},"bucket":{"type":"string","description":"The bucket the request landed in: the one whose model answered — or, when `routed` is `false`, the one that ended it."},"spilled_from":{"type":"string","description":"The bucket the request was judged (or forced, or remembered) into, when none of its models could take the request — its tools, images, JSON schema or size — and a model of `bucket` answered instead."},"reason":{"type":"string","description":"Why it landed there: `classified` (judged), `sticky` (stayed on its conversation’s model), `forced` (`force_bucket`), `single_bucket`, `fallback_only` (listed behind a model that serves the request), `no_eligible_candidate`, `no_text`, `unsure` (judged below `min_confidence`), or a failed judgement — `classifier_timeout`, `classifier_error`, `classifier_unreadable`, `classifier_refused`, `classifier_circuit_open` — that took `default_bucket`."},"decision_model":{"type":"string","description":"The decision model the router consults; none for a single bucket."},"choice":{"type":"string","description":"The bucket the decision model picked, when it answered with one — also when the request went elsewhere (`unsure`, `sticky`)."},"confidence":{"type":"number","minimum":0,"maximum":1,"description":"How sure the decision model was of `choice`, 0 to 1 — what `min_confidence` is held against."},"judgement":{"type":"object","properties":{"inference_id":{"type":"string","description":"The judgement’s own request: a row of its own in your usage, under the router’s name as `client`."},"credits":{"type":"number","description":"What the judgement was charged, in credits — on top of `meta.usage`, which counts only the answer."}},"required":["inference_id","credits"],"additionalProperties":false,"description":"The decision model’s judgement of this request, when one was made: none for a forced bucket, a single bucket, a turn returning tool results, or a request with no text."}},"required":["id","routed","reason"],"additionalProperties":false,"description":"How the router handled the request: where it went, why, and what the decision model answered."}},"required":["model","router"],"description":"Additional details about the answer — on a stream, on its last chunk."}},"required":["id","object","created","choices","model","usage"]}},"text/event-stream":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"A unique identifier for the chat completion."},"choices":{"type":"array","items":{"type":"object","properties":{"delta":{"type":"object","nullable":true,"properties":{"content":{"type":"string","description":"The contents of the chunk message."},"refusal":{"type":"string","nullable":true,"description":"The refusal message generated by the model."},"role":{"type":"string","enum":["user","assistant","developer","system","tool"],"description":"The role of the author of this message."},"tool_calls":{"type":"array","nullable":true,"items":{"type":"object","properties":{"index":{"type":"number"},"id":{"type":"string","description":"The ID of the tool call."},"function":{"type":"object","properties":{"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."},"name":{"type":"string"}},"required":["arguments","name"],"description":"The function that the model called."},"type":{"type":"string","enum":["function"],"description":"The type of the tool."}},"required":["index","id","function","type"]},"description":"The tool calls generated by the model, such as function calls."}},"required":["content","role"],"description":"A chat completion delta generated by streamed model responses."},"finish_reason":{"type":"string","enum":["length","function_call","stop","tool_calls","content_filter"]},"index":{"type":"number","description":"The index of the choice in the list of choices."},"logprobs":{"type":"object","nullable":true,"properties":{"content":{"type":"array","items":{"type":"object","properties":{"token":{"type":"string","description":"The token."},"bytes":{"type":"array","items":{"type":"number"},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token."},"logprob":{"type":"number","description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely."},"top_logprobs":{"type":"array","nullable":true,"items":{"type":"object","properties":{"token":{"type":"string","description":"The token."},"bytes":{"type":"array","items":{"type":"number"},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token."},"logprob":{"type":"number","description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely."}},"required":["token","bytes","logprob"]},"description":"List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested top_logprobs returned."}},"required":["token","bytes","logprob"]}},"refusal":{"type":"array","items":{"type":"object","properties":{"token":{"type":"string","description":"The token."},"bytes":{"type":"array","items":{"type":"number"},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token."},"logprob":{"type":"number","description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely."},"top_logprobs":{"type":"array","nullable":true,"items":{"type":"object","properties":{"token":{"type":"string","description":"The token."},"bytes":{"type":"array","items":{"type":"number"},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token."},"logprob":{"type":"number","description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely."}},"required":["token","bytes","logprob"]},"description":"List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested top_logprobs returned."}},"required":["token","bytes","logprob"]}}},"required":["content","refusal"],"description":"Log probability information for the choice."}},"required":["finish_reason","index"]},"description":"A list of chat completion choices. Can be more than one if n is greater than 1."},"created":{"type":"number","description":"The Unix timestamp (in seconds) of when the chat completion was created."},"model":{"type":"string","description":"The model used for the chat completion."},"object":{"type":"string","enum":["chat.completion.chunk"],"description":"The object type."},"service_tier":{"type":"string","nullable":true,"enum":["auto","default","flex","scale","priority"],"description":"Specifies the processing type used for serving the request."},"usage":{"type":"object","nullable":true,"properties":{"prompt_tokens":{"type":"number","description":"Number of tokens in the prompt."},"completion_tokens":{"type":"number","description":"Number of tokens in the generated completion."},"total_tokens":{"type":"number","description":"Total number of tokens used in the request (prompt + completion)."},"completion_tokens_details":{"type":"object","nullable":true,"properties":{"accepted_prediction_tokens":{"type":"integer","nullable":true,"description":"When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion."},"audio_tokens":{"type":"integer","nullable":true,"description":"Audio input tokens generated by the model."},"reasoning_tokens":{"type":"integer","nullable":true,"description":"Tokens generated by the model for reasoning."},"rejected_prediction_tokens":{"type":"integer","nullable":true,"description":"When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion. However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing, output, and context window limits."}},"description":"Breakdown of tokens used in a completion."},"prompt_tokens_details":{"type":"object","nullable":true,"properties":{"audio_tokens":{"type":"integer","nullable":true,"description":"Audio input tokens present in the prompt."},"cached_tokens":{"type":"integer","nullable":true,"description":"Cached tokens present in the prompt."}},"description":"Breakdown of tokens used in the prompt."}},"required":["prompt_tokens","completion_tokens","total_tokens"],"description":"Usage statistics for the completion request."},"meta":{"type":"object","nullable":true,"properties":{"usage":{"type":"object","nullable":true,"properties":{"credits_used":{"type":"number","description":"The number of tokens consumed during generation."},"usd_spent":{"type":"number","description":"The total amount of money spent by the user in USD."}},"required":["credits_used","usd_spent"]},"model":{"type":"string","description":"The model that answered — the one the router chose, or the next one in its bucket if that one failed. The router itself when the request ended at the decision (`router.routed: false`). Its rate is what the answer cost."},"provider":{"type":"string","description":"The provider that served the answer; `aimlapi` when the request ended at the decision."},"router":{"type":"object","properties":{"id":{"type":"string","description":"The router the request named."},"routed":{"type":"boolean","description":"Whether a model answered. `false`: the request ended at the decision — `bucket` lists no models, so no model was called, the message is empty and nothing but the judgement was charged. Act on `bucket` (and `choice`, `confidence`)."},"bucket":{"type":"string","description":"The bucket the request landed in: the one whose model answered — or, when `routed` is `false`, the one that ended it."},"spilled_from":{"type":"string","description":"The bucket the request was judged (or forced, or remembered) into, when none of its models could take the request — its tools, images, JSON schema or size — and a model of `bucket` answered instead."},"reason":{"type":"string","description":"Why it landed there: `classified` (judged), `sticky` (stayed on its conversation’s model), `forced` (`force_bucket`), `single_bucket`, `fallback_only` (listed behind a model that serves the request), `no_eligible_candidate`, `no_text`, `unsure` (judged below `min_confidence`), or a failed judgement — `classifier_timeout`, `classifier_error`, `classifier_unreadable`, `classifier_refused`, `classifier_circuit_open` — that took `default_bucket`."},"decision_model":{"type":"string","description":"The decision model the router consults; none for a single bucket."},"choice":{"type":"string","description":"The bucket the decision model picked, when it answered with one — also when the request went elsewhere (`unsure`, `sticky`)."},"confidence":{"type":"number","minimum":0,"maximum":1,"description":"How sure the decision model was of `choice`, 0 to 1 — what `min_confidence` is held against."},"judgement":{"type":"object","properties":{"inference_id":{"type":"string","description":"The judgement’s own request: a row of its own in your usage, under the router’s name as `client`."},"credits":{"type":"number","description":"What the judgement was charged, in credits — on top of `meta.usage`, which counts only the answer."}},"required":["inference_id","credits"],"additionalProperties":false,"description":"The decision model’s judgement of this request, when one was made: none for a forced bucket, a single bucket, a turn returning tool results, or a request with no text."}},"required":["id","routed","reason"],"additionalProperties":false,"description":"How the router handled the request: where it went, why, and what the decision model answered."}},"required":["model","router"],"description":"Additional details about the answer — on a stream, on its last chunk."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## Code Example

Two buckets: short, simple requests go to small models, and everything else to strong ones. A request the decision model cannot judge goes to `complex`.

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests

ROUTER = {
    "buckets": [
        {
            "name": "simple",
            "when": "Greetings, small talk, short factual questions, quick rewrites, translations of a sentence or two, and other short routine tasks.",
            "models": ["openai/gpt-6-luna", "google/gemini-3-5-flash-lite"],
        },
        {
            "name": "complex",
            "when": "Multi-step reasoning, math, code, long documents, analysis, or anything that needs care and expert knowledge.",
            "models": ["anthropic/claude-sonnet-5.5", "openai/gpt-6.1-sol"],
        },
    ],
    "default_bucket": "complex",
}

response = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={
        # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
        "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type": "application/json",
    },
    json={
        "model": "aimlapi/dynamic-router",
        "messages": [{"role": "user", "content": "Write a haiku about autumn rain."}],
        "router": ROUTER,
    },
)
data = response.json()

print(data["choices"][0]["message"]["content"])
router = data["meta"]["router"]
print(f'{router["bucket"]} ({router["reason"]}) -> {data["meta"]["model"]}')
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code overflow="wrap" %}

```javascript
const ROUTER = {
  buckets: [
    {
      name: 'simple',
      when: 'Greetings, small talk, short factual questions, quick rewrites, translations of a sentence or two, and other short routine tasks.',
      models: ['openai/gpt-6-luna', 'google/gemini-3-5-flash-lite'],
    },
    {
      name: 'complex',
      when: 'Multi-step reasoning, math, code, long documents, analysis, or anything that needs care and expert knowledge.',
      models: ['anthropic/claude-sonnet-5.5', 'openai/gpt-6.1-sol'],
    },
  ],
  default_bucket: 'complex',
};

const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
  method: 'POST',
  headers: {
    // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
    'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'aimlapi/dynamic-router',
    messages: [{ role: 'user', content: 'Write a haiku about autumn rain.' }],
    router: ROUTER,
  }),
});
const data = await response.json();

console.log(data.choices[0].message.content);
const { bucket, reason } = data.meta.router;
console.log(`${bucket} (${reason}) -> ${data.meta.model}`);
```

{% endcode %}
{% endtab %}
{% endtabs %}

With the OpenAI SDK, pass `router` in `extra_body`.

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json
{
  "id": "chatcmpl-EdGEELKBeS6buK9oIW77LcqVUNQPH",
  "object": "chat.completion",
  "created": 1793025882,
  "model": "gpt-6-luna",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Soft rain veils the leaves  \nGold branches bow in gray skies  \nPools mirror the dusk",
        "refusal": null,
        "annotations": []
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 14,
    "completion_tokens": 130,
    "total_tokens": 144,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "cache_write_tokens": 0,
      "audio_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 103,
      "audio_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    }
  },
  "service_tier": "default",
  "system_fingerprint": null,
  "meta": {
    "model": "openai/gpt-6-luna",
    "provider": "openai",
    "router": {
      "id": "aimlapi/dynamic-router",
      "routed": true,
      "bucket": "simple",
      "reason": "classified",
      "decision_model": "typesafe/jev-1.14",
      "choice": "simple",
      "confidence": 1,
      "judgement": {
        "inference_id": "JUmJ3uDd1DWC61TzklAVy",
        "credits": 33
      }
    },
    "usage": {
      "credits_used": 133,
      "usd_spent": 6.65e-05
    },
    "metrics": {
      "duration_ms": 2777,
      "ttft_ms": 2775,
      "tps": 46.81
    }
  }
}
```

{% endcode %}

</details>

## Set up your buckets

Everything in `router` is optional. A setting you leave out keeps its default. `buckets`, when you send them, replace the default buckets entirely.

| Setting            | Default                                                      | What it does                                                                                                                                                                                                                                                                                                                                                              |
| ------------------ | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `buckets`          | the [default buckets](#without-a-router-the-default-buckets) | 1 to 10 buckets. With two or more, each needs a `when`. A single bucket is a fallback chain: it takes no `when`, is never judged, and cannot be empty.                                                                                                                                                                                                                    |
| `buckets[].name`   | —                                                            | 1 to 32 letters, digits, `-`, `_` or `.`, starting with a letter or digit. Unique in the router, ignoring case. `meta.router.bucket` reports it.                                                                                                                                                                                                                          |
| `buckets[].when`   | —                                                            | What the requests of this bucket look like, in your words: 1 to 500 characters. This is the decision model's prompt. See [Write bucket descriptions that route well](#write-bucket-descriptions-that-route-well).                                                                                                                                                         |
| `buckets[].models` | —                                                            | Up to 10 models in the order to try them, each listed once, or `[]` to end the request at the decision. Chat, image and video models may share a bucket: each request uses the models of its own kind. A model may appear in several buckets. Only models we serve: not routers, not decision models. Each one runs with your request's own settings, reasoning included. |
| `default_bucket`   | your first bucket                                            | Where a request goes when it is not judged: the decision model failed, timed out, was unsure or named no bucket, or the request had no text. Also the first place a request goes when no model of its bucket can take it. Required when your first bucket has no models.                                                                                                  |
| `force_bucket`     | —                                                            | Sends the request to this bucket without judging it, and nothing is charged for a judgement. Useful to test how your app handles each bucket. A forced request never moves to another bucket. Not allowed with `ladder`.                                                                                                                                                  |
| `min_confidence`   | none                                                         | 0 to 1. A decision less sure than this goes to `default_bucket` (`meta.router.reason`: `unsure`). The judgement is still charged.                                                                                                                                                                                                                                         |
| `decision_model`   | `typesafe/jev-1.14`                                          | The model that picks the bucket: `typesafe/jev-1.14`, `typesafe/jev-1.13`, `typesafe/jev` (always the newest Jev), `liquid/d1`, `liquid/d1.1` or `liquid/d1-ultra`. Only [decision models](https://docs.aimlapi.com/api-references/decision-models.md), never a model that answers.                                                                                       |
| `ladder`           | `false`                                                      | `true` turns the buckets into a one-way ladder for conversations. See [Conversations and the ladder](#conversations-and-the-ladder).                                                                                                                                                                                                                                      |
| `state`            | —                                                            | With `ladder: true` only: the previous answer's `meta.router.state`, unchanged. Up to 1,024 characters.                                                                                                                                                                                                                                                                   |

An invalid configuration gets a `400` before anything is charged. Its `error.details` lists every problem, up to 20, each with the setting's path and what to change.

### Without a router: the default buckets

Without `router`, or with `router: {}`, conversations route by how much capability they need, like the [Jev Router](https://docs.aimlapi.com/api-references/text-models-llm/ml-api/jev-router.md). A request that cannot be judged goes to `standard`.

| Bucket     | Takes                                                                                            | Models, cheapest first                                                                                                                            |
| ---------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `light`    | Greetings and small talk, one-line or lookup answers, common knowledge, short routine tasks      | `openai/gpt-6-luna`, `anthropic/claude-haiku-5.5`, `deepseek/deepseek-v4.1-flash`, `google/gemini-3-1-flash-lite`, `google/gemini-3-5-flash-lite` |
| `standard` | Multi-step tasks that need care and accuracy                                                     | `openai/gpt-6.1-sol`, `anthropic/claude-sonnet-5.5`                                                                                               |
| `heavy`    | Complex reasoning, hard math or proofs, large or tricky code, expert or research-grade knowledge | `anthropic/claude-opus-5.5`, `openai/gpt-6-astra`                                                                                                 |

* **Conversations only.** The default buckets serve Chat Completions, Responses and Messages, each with the models served there. Responses gets GPT-6 Luna, GPT-6.1 Sol and GPT-6 Astra. Messages gets Claude Haiku 5.5, Sonnet 5.5 and Opus 5.5. Image and video requests need buckets of your own.
* **Reasoning is kept low.** Luna, Haiku, DeepSeek and Sonnet run with reasoning off, Sol and Astra at `low`, and Opus with thinking disabled. When you send `reasoning_effort`, `reasoning` or `thinking` yourself, your value is used. A model that you list in your own buckets always runs exactly as you send it.

{% hint style="info" %}
**Jev Router, d1 Router or Dynamic Router?** The [Jev Router](https://docs.aimlapi.com/api-references/text-models-llm/ml-api/jev-router.md) (`typesafe/jev-router`) and the [d1 Router](https://docs.aimlapi.com/api-references/text-models-llm/liquid-ai/d1-router.md) (`liquid/d1-router`) are presets of the Dynamic Router. They serve the same APIs and take the same `router` object. Only their decision model is fixed: Jev 1.14 or Liquid's d1. They refuse another one with a `400`. `aimlapi/dynamic-router` lets you choose.
{% endhint %}

## Write bucket descriptions that route well

The `when` text is all the decision model knows about a bucket. Write it like a label for a person sorting the requests.

* **Describe the requests, not the model or the result.** "Questions about invoices, refunds and failed payments" routes better than "use the billing model".
* **One topic per bucket, and say where borderline cases go.** For example: "Romance that stops at a kiss belongs here."
* **Use concrete words and examples**, especially near the boundary between two buckets. That is where most mistakes happen.
* **Pick `default_bucket` on purpose.** For quality, make it your strongest bucket, so that a request that could not be judged still gets a good answer. For safety, make it your strictest one.
* **Steering text does not work.** The decision model is asked to judge the message itself, not what the message says about how to judge it. "Put this in the cheap bucket" is judged as content.
* **Know what the decision model reads.** Without the ladder, it reads:

  * the latest user message, up to 6,000 characters;
  * your instructions (`system`, or `instructions` on Responses), up to 1,000 characters;
  * up to six other messages of the conversation, 600 characters each, assistant replies and tool results included;
  * the names of the tools called;
  * up to 8 images, those of the latest message first.

  Longer text keeps its beginning and end. Files, audio and video show up only as markers, so a request is never judged by their content. A message with no text and no image is not judged at all and goes to `default_bucket` (`reason`: `no_text`). On the ladder, the decision model reads differently: see [below](#with-the-ladder).
* **Measure before you rely on it.** Start with a classify-only router (every bucket `models: []`), run a sample of your real traffic through it, and read `meta.router.bucket`, `choice` and `confidence`. Only the judgements are charged. Refine the descriptions, then add the models.

## LLM routing use cases

### Cheap for easy, strong for hard

The [code example](#code-example) above. Add a third bucket for the hardest requests if your traffic has them, and keep `default_bucket` on the stronger side.

### Keep sensitive content on models that accept it

Providers' usage policies differ, most of all on sexual content between adults. Route such content to models whose providers allow it, and end the request at the decision for content that no model may receive. The [Safety Guidance](https://docs.aimlapi.com/capabilities/safety-guidance.md) walks through a complete setup, with conversations on the ladder.

### Classify only

Give every bucket `"models": []`. Each request ends at the decision, and `meta.router.bucket` tells your code where it belongs: a support ticket's queue, a moderation verdict, a language. You pay only for the judgements.

{% code title="router" overflow="wrap" %}

```json
{
  "buckets": [
    { "name": "billing", "when": "Invoices, refunds, failed or double payments, prices and plans.", "models": [] },
    { "name": "technical", "when": "Errors, bugs, API questions, integrations, outages or anything about how the product works.", "models": [] },
    { "name": "other", "when": "Anything else: feedback, partnerships, job applications, small talk.", "models": [] }
  ],
  "default_bucket": "other"
}
```

{% endcode %}

### Route by topic

Send code to a coding model and everything else to a general one.

{% code title="router" overflow="wrap" %}

```json
{
  "buckets": [
    { "name": "code", "when": "Writing, reviewing, explaining or debugging code, shell commands, SQL, regular expressions and stack traces.", "models": ["anthropic/claude-sonnet-5.5", "openai/gpt-6.1-sol"] },
    { "name": "general", "when": "Everything else: questions, writing, summaries, advice and conversation.", "models": ["openai/gpt-6-luna", "google/gemini-3-5-flash-lite"] }
  ],
  "default_bucket": "general"
}
```

{% endcode %}

### A fallback chain

One bucket, with no `when`. Every request goes to the first model that can take it, then to the next one. Nothing is judged, and nothing is charged for a judgement.

{% code title="router" overflow="wrap" %}

```json
{ "buckets": [{ "name": "chain", "models": ["anthropic/claude-sonnet-5.5", "openai/gpt-6.1-sol", "google/gemini-3-5-flash-lite"] }] }
```

{% endcode %}

### Images and video

The same router works on image generation, image editing and video generation. The decision model judges the prompt and the input images, and the request takes the image or video models of its bucket. See [Images, video, Responses and Messages](#images-video-responses-and-messages).

## Conversations and the ladder

### Without the ladder

Every turn is judged with the context of the conversation, and a conversation may move between buckets in both directions.

* **A conversation keeps its model while its turns land in the same bucket**, for 30 minutes after the last reply. It moves when a turn lands in another bucket. That memory is reset when you change the bucket table, when the reply was edited, or when the `user` changes.
* **A turn that returns tool results goes back to the model that made the calls**, unjudged and free.
* **When a turn cannot be judged, the conversation stays on its model**, even when `default_bucket` lists no models.

That suits routing by difficulty: a hard question goes to a strong model, and the small talk after it back to a cheap one. It does not suit content routing. Suppose a conversation turns explicit and lands in a permissive bucket, and then the user sends an ordinary message. That message is judged on its own and lands in the strict bucket. Its model then sees the explicit history and is likely to refuse. In our tests this happened to about three in four turns after an explicit message. Use the ladder for that.

### With the ladder

`"ladder": true` turns your buckets into the rungs of a ladder, in the order you list them: the first is the strictest, and each next one more relaxed. A ladder needs two rungs at least.

* **A conversation starts on the top rung and only moves down.** Each new turn is judged against all your rungs: the previous reply and the new message. The conversation goes to the lowest rung it needs. A verdict above its rung keeps it where it is. It climbs back only once what moved it is gone from the history, because the user deleted the message or started a new chat.
* **The decision model is asked which rung the most sensitive message needs.** It reads the user's and the assistant's messages, their text and images. It never reads your instructions (`system`), tool results or tool-call arguments. Files, audio and video show up only as markers.
* **The last rung may have no models.** A conversation that reaches it ends there: every later turn stops at once, unjudged and free, until the message that moved it there is removed. No other rung may be empty. Once on the last rung, a conversation is no longer judged.
* **Send the state back.** Each answer carries `meta.router.state`, an opaque value; in a stream it comes with the last event. Send it unchanged as `router.state` with the next turn. With it, only what is new is judged, and the conversation stays on its rung's model.
* **Without a state, the whole conversation is judged again.** The same happens when the state no longer fits the conversation: its history was edited, trimmed or branched, or you renamed, reordered or reworded the rungs. Changing the rungs' models or the decision model keeps the state. The conversation is judged in pieces, the newest first: up to 24 judgements a turn, each charged, and slightly less accurate than with the state. A state does not expire.
* **`meta.router.trigger` names the message that moved the conversation down**: its position in `messages`, and the rung it needed. Tell the user which message to delete to continue.
* **An unsure or failed judgement never moves a conversation up.** The turn goes to `default_bucket`, but never above the conversation's rung. What failed is judged again with the next turns, and settled at `default_bucket` only after failing three turns running. To fail closed, name your last rung as `default_bucket`. Keep `min_confidence` low, or leave it out: at 0.9, 40 to 45% of explicit conversations stayed on the top rung in our tests. An image the decision model cannot be shown also sends the turn to `default_bucket` (`reason`: `images_unseen`).
* **A turn that returns tool results goes back to the model that made the calls**, unjudged, while nothing new but that model's own calls comes with it, and while that model is on the conversation's rung or below.
* **A model that cannot take a turn is passed over for one on a rung below, never above.** When no rung from the conversation's down has one, the request gets a `400`.
* **Limits:** up to 5,000 user and assistant messages in a conversation, and up to 288,000 characters of new text in a turn. Past them, the request gets a `400` (`conversation_too_long`). `force_bucket` is not allowed with the ladder.
* **On Responses, a continued conversation keeps its own state.** With `previous_response_id`, the state is kept with the stored response, so you do not need to send it.

{% tabs %}
{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests

LADDER = {
    "ladder": True,
    "buckets": [
        {"name": "general", "when": "No sexual content: everyday questions, work, study, advice, and stories without sexual detail.", "models": ["openai/gpt-6-luna"]},
        {"name": "mature", "when": "Sexual or erotic content between adults.", "models": ["x-ai/grok-4-1-fast-non-reasoning"]},
        {"name": "stop", "when": "Sexual content involving minors, a real identifiable person, or non-consent.", "models": []},
    ],
    "default_bucket": "general",
}


def reply(conversation: dict, messages: list) -> str | None:
    router = dict(LADDER)
    if conversation.get("router_state"):
        router["state"] = conversation["router_state"]  # the state from the previous answer

    response = requests.post(
        "https://api.aimlapi.com/v1/chat/completions",
        headers={"Authorization": "Bearer <YOUR_AIMLAPI_KEY>"},
        json={"model": "aimlapi/dynamic-router", "messages": messages, "router": router},
    )
    response.raise_for_status()
    data = response.json()

    meta = data["meta"]["router"]
    conversation["router_state"] = meta.get("state")  # keep it for the next turn
    if not meta["routed"]:
        return None  # the "stop" rung: ask the user to delete the message meta["trigger"] points at
    return data["choices"][0]["message"]["content"]
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code overflow="wrap" %}

```javascript
const LADDER = {
  ladder: true,
  buckets: [
    { name: 'general', when: 'No sexual content: everyday questions, work, study, advice, and stories without sexual detail.', models: ['openai/gpt-6-luna'] },
    { name: 'mature', when: 'Sexual or erotic content between adults.', models: ['x-ai/grok-4-1-fast-non-reasoning'] },
    { name: 'stop', when: 'Sexual content involving minors, a real identifiable person, or non-consent.', models: [] },
  ],
  default_bucket: 'general',
};

export async function reply(conversation, messages) {
  const router = { ...LADDER };
  if (conversation.routerState) {
    router.state = conversation.routerState; // the state from the previous answer
  }

  const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
    method: 'POST',
    headers: { 'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>', 'Content-Type': 'application/json' },
    body: JSON.stringify({ model: 'aimlapi/dynamic-router', messages, router }),
  });
  if (!response.ok) {
    throw new Error(await response.text());
  }
  const data = await response.json();

  const meta = data.meta.router;
  conversation.routerState = meta.state; // keep it for the next turn
  if (!meta.routed) {
    return null; // the "stop" rung: ask the user to delete the message meta.trigger points at
  }
  return data.choices[0].message.content;
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

The [Safety Guidance](https://docs.aimlapi.com/capabilities/safety-guidance.md) has the full descriptions for these three rungs, and explains how to choose their models.

## Images, video, Responses and Messages

The same `router` works on every API the router serves. Send `"model": "aimlapi/dynamic-router"` with your `router` to `/v1/responses`, `/v1/messages`, `/v1/images/generations`, `/v1/images/edits` or `/v2/video/generations`. The decision model reads the conversation or the prompt, and the input images, as on Chat Completions. A media request is judged as its prompt, its input images and markers for any other files. Masks are not shown.

* **Each request uses the bucket's models of its own kind:** chat models on Chat Completions, image models on the image endpoints, video models on video. Responses and Messages serve fewer models than Chat Completions; Messages, for example, serves Claude models. The [model list](https://docs.aimlapi.com/api-references/model-database.md) shows which API serves a model.
* **A request goes only to a model that can take it**: its tools, images, files, audio, JSON schema and context size.
* **When no model of the bucket can take the request, it moves on**, first to `default_bucket`, then to your other buckets in your order. `meta.router.spilled_from` names the bucket it left. A bucket with no models never takes a request that moved on. On a ladder, a request moves only to a rung below. When it matters where a request lands, give every bucket a model for each API you use, or no models at all.
* **A table with no model at all for the request** (say, an image request to buckets of chat models) gets a `400` before anything is charged. On image and video requests, a field that none of the bucket's models supports gets a `400` (`unserved_field`) that names it.
* **A request that ends at the decision is answered in its API's shape:**
  * Chat Completions: an empty assistant message (`content: ""`, `finish_reason: "stop"`);
  * Responses: a `completed` response with empty output;
  * Messages: one empty text block with `stop_reason: "end_turn"`;
  * images: `{ "data": [] }`;
  * video: `{ "id": …, "status": "completed", "video": null }`, which polling returns too.
* **Where `meta.router` is:** in the response body. In a stream it comes with the last event: the last chunk on Chat Completions, `response.completed` on Responses, and `message_stop` on Messages. On video, it is in the submit's response.
* **Continuing a stored response (`previous_response_id`)** works like any other turn, with one limit: it can only run on a model that can read the stored response. It stays with the model that wrote it while it lands in that model's bucket, and a bucket with no models ends it at the decision. Stored responses can be continued for 7 hours after they are created, by the account that created them, unless they were created with `store: false`. If a conversation may change buckets, send its history in `input` instead.
* **The default buckets route conversations only.** Image and video requests need buckets of your own.
* **In a multipart image edit,** send `router` as a JSON string in one form field.

Give media requests a router of their own when your chat buckets list only chat models. Otherwise an image request in a bucket with no image model moves on to another bucket's image models.

{% code title="media router" overflow="wrap" %}

```json
{
  "buckets": [
    { "name": "text", "when": "Images that must show readable text: posters, logos, signs, labels, menus and infographics.", "models": ["google/nano-banana-2"] },
    { "name": "other", "when": "Every other image: photos, scenes, portraits and illustrations.", "models": ["alibaba/z-image-turbo"] }
  ],
  "default_bucket": "other"
}
```

{% endcode %}

## What the response tells you

`meta.model` names the model that answered. It is the router itself when the request ended at the decision. `meta.router` says how the request was routed:

| Field                  | Meaning                                                                                                                                                                                                         |
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                   | The router the request named.                                                                                                                                                                                   |
| `routed`               | `false` when the request ended at the decision: a bucket with no models, or a ladder's stop rung.                                                                                                               |
| `bucket`               | The bucket the request landed in.                                                                                                                                                                               |
| `spilled_from`         | The bucket the request left because none of its models could take it.                                                                                                                                           |
| `reason`               | Why it landed there. See the table below.                                                                                                                                                                       |
| `decision_model`       | The decision model that judged. Absent for a single bucket.                                                                                                                                                     |
| `choice`, `confidence` | The bucket the decision model picked, and how sure it was, from 0 to 1. They can differ from `bucket` when the decision was unsure, the conversation kept its model, or the ladder kept its rung.               |
| `judgement`            | The judgement: `inference_id`, its own request in your usage, and `credits`, its price. `images` and `images_unseen` count the images the decision model was and was not shown. Absent when nothing was judged. |
| `judgements`           | Ladder: each judgement of the turn, when it took more than one.                                                                                                                                                 |
| `state`                | Ladder: send it back as `router.state` with the next turn.                                                                                                                                                      |
| `trigger`              | Ladder: the message that moved the conversation down (`message`, its position in `messages` or `input`) and the rung it needed (`bucket`).                                                                      |

| `reason`                                                                                     | Meaning                                                                                                                                                 |
| -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `classified`                                                                                 | The decision model picked the bucket.                                                                                                                   |
| `sticky`                                                                                     | The conversation kept its model, or its rung on a ladder.                                                                                               |
| `forced`                                                                                     | `force_bucket` chose the bucket.                                                                                                                        |
| `single_bucket`                                                                              | The router has one bucket. Nothing was judged.                                                                                                          |
| `unsure`                                                                                     | The decision was less sure than `min_confidence`. The request went to `default_bucket`.                                                                 |
| `no_text`                                                                                    | The message had nothing to judge. The request went to `default_bucket`.                                                                                 |
| `images_unseen`                                                                              | Ladder: an image could not be shown to the decision model. The turn went to `default_bucket`.                                                           |
| `classifier_timeout`, `classifier_error`, `classifier_circuit_open`, `classifier_unreadable` | The judgement failed, or its answer named no bucket. The request went to `default_bucket`.                                                              |
| `classifier_refused`                                                                         | The judgement was refused by your own limits (funds, key quota, spend limit) or by a restriction on your account. The request went to `default_bucket`. |
| `no_eligible_candidate`                                                                      | No model in the router can take the request. It went unjudged to one of your models, whose own error says what the request lacks.                       |
| `fallback_only`                                                                              | The router was only a fallback behind another model in your request's `models`, and did not judge.                                                      |

On a ladder, `reason` may name a failure even when the turn's other judgements routed it.

## Pricing

* **The answer** is charged at the price of the model that gave it (`meta.model`). `meta.usage` and the `x-aimlapi-credits-used` header cover the answer only.
* **Each judgement** is a request of its own, with its own id and its own row in your usage, under the router's name. It is charged at the decision model's [catalogue price](https://docs.aimlapi.com/api-references/decision-models.md) for its input, images included. `meta.router.judgement.credits` shows the exact amount. A text judgement costs a few dozen credits (a credit is $0.0000005). Each image adds more, because the decision model reads it as input tokens.
* **No judgement is charged** for:

  * a single bucket or a forced bucket;
  * a turn that returns tool results;
  * a message with nothing to judge;
  * a configuration we refuse, or a request no model can take;
  * a decision model we skip after repeated failures (`classifier_circuit_open`).

  An unsure or unreadable decision is still charged.
* **A request that ends at the decision** costs its judgement only. The empty answer is free.
* **On a ladder,** each piece of a judged conversation is charged, and `judgement.credits` is their total. A turn on a stop rung is free.
* **In a stream,** the `x-aimlapi-credits-used` header shows `0`, because it is sent before the charge is known. The charge is in the last event and in your usage.

## Limits and errors

|                                 | Limit                                                                                                                                                                                     |
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Buckets                         | 1 to 10                                                                                                                                                                                   |
| Bucket name                     | 1 to 32 characters: letters, digits, `-`, `_` or `.`                                                                                                                                      |
| `when`                          | 1 to 500 characters                                                                                                                                                                       |
| Models in a bucket              | Up to 10, each once                                                                                                                                                                       |
| `state`                         | Up to 1,024 characters                                                                                                                                                                    |
| Images the decision model reads | Up to 8 a request. Jev: PNG or JPEG, 280 to 1,568 px a side, up to 16 MiB each and 32 MiB in all. Liquid's models: JPEG, PNG or WebP, up to 10,000 tiles of 32 × 32 px and 4.5 MiB in all |
| Decision deadline               | Jev: 1.5 s, or 3 s with images. d1.1 and d1-ultra: 3 s. d1: 60 s                                                                                                                          |
| Ladder                          | 2 rungs at least, 5,000 user and assistant messages, 288,000 characters of new text a turn, 24 judgements a turn                                                                          |
| Stored responses                | 7 hours after creation, for `previous_response_id`                                                                                                                                        |

A decision that misses its deadline sends the request to `default_bucket`. A decision model that keeps failing is skipped for 30 seconds (`classifier_circuit_open`).

Every error below is an HTTP `400` with its code in `error.details[].code`, unless the table says otherwise.

| Code                            | When                                                                                                                                   | What to do                                                                  |
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| `invalid_router_config`         | The `router` object is invalid. Every problem is listed with its path. Nothing is charged.                                             | Fix the named settings.                                                     |
| `invalid_image`                 | An image in the latest message, or in a media request, does not fit the decision model's limits. The error names the image.            | Resize or convert it, or send fewer images.                                 |
| `unserved_field`                | An image or video request sets a field that none of the bucket's models supports.                                                      | Remove the field, or list a model that takes it.                            |
| `unserved_request`              | On a ladder, no model of the conversation's rung or below can take the request.                                                        | List one in a rung from that rung down.                                     |
| `conversation_too_long`         | On a ladder: more than 5,000 messages, or more new text than one turn can judge.                                                       | Send `router.state` back, trim the history, or start a new conversation.    |
| `previous_response_not_found`   | No stored response with that id for your account.                                                                                      | Send the conversation in `input`.                                           |
| `previous_response_unavailable` | The stored response is kept where none of your buckets' models runs.                                                                   | Continue with the model that wrote it, or send the conversation in `input`. |
| `402` or `429`                  | Your own limits refused the judgement of a request that would end at the decision. The refusal is returned instead of an empty answer. | Top up, or raise the limit.                                                 |

## Good to know

* **`router` only works on the routers.** On any other model it is ignored, without an error. If a response has no `meta.router`, check `model`.
* **The router keeps nothing for you.** Send the same `router` object with every request. Change it, and conversations lose their memory.
* **The Playground does not take `router`.** There, the router always uses the default buckets.
* **A model that cannot take the request is skipped**: tools, images, files, audio, JSON schema, context size. Put the model you prefer first.
* **A policy refusal is final.** When a provider refuses a request under its usage policy, the next model in the bucket is not tried. Route such content to another bucket instead.
* **The top-level `model` in the response may be the provider's own name** for the model. Use `meta.model` for our id.
* **Without the ladder, an empty `default_bucket` does not stop a conversation in progress.** When a turn of a remembered conversation cannot be judged, it stays on its model. Use the ladder, with the last rung as `default_bucket`, to fail closed.
* **Bucket names are matched ignoring case**, in `default_bucket`, `force_bucket` and the decision model's answer.
* **A bucket table with an empty bucket always pays for the judgement**, even when no model could have taken the request.

## FAQ

### What is an LLM router?

A service that sends each request to the model best suited to it, instead of sending everything to one model. Routers are mostly used to cut cost, with easy requests going to cheap models, and to respect what each model is good at and allowed to do. The Dynamic Router does it with bucket descriptions that you write.

### Is the Dynamic Router a semantic router?

Yes: it routes by what a request means. Instead of example phrases and an embedding index, you write a description per bucket in plain words, and a hosted decision model judges each request. There is nothing to train, tune or host.

### Does it work with the OpenAI SDK?

Yes. Set `model` to `aimlapi/dynamic-router` and pass `router` in `extra_body`. The Responses API and the Anthropic-style Messages API work the same way.

### How much does routing cost?

The answer costs what its model costs. Each judgement adds a few dozen credits for text. A single bucket, a forced bucket and turns that return tool results need no judgement.

### Is it an AI gateway?

It runs on the AI/ML API gateway: one API key and one bill for every model in your buckets, and each model keeps its own provider fallbacks.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.aimlapi.com/api-references/text-models-llm/ml-api/dynamic-router.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
