> This is part 1 of 13 of the full documentation (pages 1–72 of 816).
> The content is paginated: fetch every part to see all of it.
> Next part: https://docs.aimlapi.com/llms-full.txt/1
> Page index: https://docs.aimlapi.com/llms.txt

# 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
This site has an agentic ask interface you may use to query the documentation dynamically 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/index.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.

---

# Documentation Map

Map of the AI/ML API docs: find the model for a task and open its API reference. One API key, OpenAI-compatible base URL https\://api.aimlapi.com/v1.

This page helps you quickly find the right AI model for your task.\
Open the API reference and copy a working example to integrate it into your code in minutes.

***

**Trending Models**

<table data-column-title-hidden data-view="cards" data-full-width="false"><thead><tr><th align="center"></th><th data-hidden data-card-cover data-type="image">Cover image</th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center">Pro-Grade Image Model</td><td><a href="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2FOHRh3Mc6y1zB1jMGlWwY%2Fnano_banana_2_cover_v3.png?alt=media&amp;token=d04ba652-a498-424b-a7ce-efe4da80b4ec">nano_banana_2_cover_v3.png</a></td><td><a href="/api-references/image-models/google/gemini-3.1-flash-image">Nano Banana 2 (Gemini 3.1 Flash Image)</a></td></tr><tr><td align="center">Frontier AI Reasoning Model</td><td><a href="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2FAAy7A9XPlq3yvgf7eF5X%2FChatGPT%20Image%20Sep%202%2C%202026%2C%2006_52_40%20PM.png?alt=media&amp;token=77191793-dc47-40b5-ac7f-419a71b699fd">ChatGPT Image Sep 2, 2026, 06_52_40 PM.png</a></td><td><a href="/api-references/text-models-llm/anthropic/claude-fable-5.1">Claude Fable 5.1</a></td></tr><tr><td align="center">Fast Video Generation</td><td><a href="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2FagQbPN6IlqHKZeoyFCDe%2Fseedance-2-5-cover.png?alt=media&amp;token=c2a4972c-9d52-476a-86de-d5b17d4e8569">seedance-2-5-cover.png</a></td><td><a href="/api-references/video-models/bytedance/dreamina-seedance-2-5">Seedance 2.5</a></td></tr></tbody></table>

***

<table data-header-hidden data-full-width="false"><thead><tr><th width="281.09991455078125" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><p><strong>Start with this code block</strong><br><br>🚀 <a href="/quickstart/simple-model"><strong>Setup guide</strong></a><br><br>🧩 <a href="/quickstart/supported-sdks"><strong>SDKs</strong></a></p><p>▶️ <a href="https://aimlapi.com/app/"><strong>Run in Playground</strong></a></p></td><td valign="top"><pre class="language-python" data-overflow="wrap"><code class="lang-python">from openai import OpenAI
client = OpenAI(
base_url="https://api.aimlapi.com/v1",
api_key="&#x3C;YOUR_AIMLAPI_KEY>",
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Write a one-sentence story about numbers."}]
)
print(response.choices[0].message.content)
</code></pre></td></tr><tr><td valign="top"></td><td valign="top"></td></tr></tbody></table>

***

Select the model by its **Task**, by its **Developer** or by the supported **Capabilities**:

{% hint style="info" %}
If you've already made your choice and know the model ID, use the [Search panel](https://docs.aimlapi.com/?q=) on your right.
{% endhint %}

{% tabs %}
{% tab title="Models by TASK" %}
{% content-ref url="/pages/6a2JwgGnh8dvD5mmdzoP" %}
[Text Models (LLM)](/api-references/text-models-llm)
{% endcontent-ref %}

{% content-ref url="/pages/RFizWjOk4ojVgsvmejjK" %}
[Image Models](/api-references/image-models)
{% endcontent-ref %}

{% content-ref url="/pages/LUpdTqMHZ9YRxWhhrPCV" %}
[Video Models](/api-references/video-models)
{% endcontent-ref %}

{% content-ref url="/pages/W4MpGk1WlcYX0fNrH2IP" %}
[Music Models](/api-references/music-models)
{% endcontent-ref %}

{% content-ref url="/pages/Xw5ohM8tnr5umNsfCWF6" %}
[Voice/Speech Models](/api-references/speech-models)
{% endcontent-ref %}

{% content-ref url="/pages/0Yx821BRYTKgP4Xzk6hC" %}
[3D-Generating Models](/api-references/3d-generating-models)
{% endcontent-ref %}

{% content-ref url="/pages/awkdnLHWRSqjdFPQahur" %}
[Vision Models](/api-references/vision-models)
{% endcontent-ref %}

{% content-ref url="/pages/9xxhbHaEisZemoWFlpdd" %}
[Embedding Models](/api-references/embedding-models)
{% endcontent-ref %}
{% endtab %}

{% tab title="Models by DEVELOPER" %}
**Alibaba Cloud**: [Text/Chat](/api-references/text-models-llm/alibaba-cloud) [Image](/api-references/video-models/alibaba-cloud) [Video](/api-references/image-models/alibaba-cloud) [Text-to-Speech](/api-references/speech-models/text-to-speech/alibaba-cloud) [Embedding](/api-references/embedding-models/alibaba-cloud)

**Anthracite**: [Text/Chat](/api-references/text-models-llm/anthracite)

<mark style="background-color:green;">**Anthropic**</mark>: [Text/Chat](/api-references/text-models-llm/anthropic) [Embedding](/api-references/embedding-models/anthropic)

**Assembly AI:** [Speech-To-Text](/api-references/speech-models/speech-to-text/assembly-ai)

**Baidu**: [Text/Chat](/api-references/text-models-llm/baidu)

**ByteDance**: [Text/Chat](/api-references/text-models-llm/bytedance) [Image](/api-references/video-models/bytedance) [Video](/api-references/image-models/bytedance)

**Cohere**: [Text/Chat](/api-references/text-models-llm/cohere)

<mark style="background-color:green;">**DeepSeek**</mark>: [Text/Chat](/api-references/text-models-llm/deepseek)

**Deepgram**: [Speech-To-Text](/api-references/speech-models/speech-to-text/deepgram) [Text-to-Speech](/api-references/speech-models/text-to-speech/deepgram)

<mark style="background-color:green;">**ElevenLabs**</mark>**:** [Text-to-Speech](/api-references/speech-models/text-to-speech/elevenlabs) [Voice Chat](/api-references/speech-models/voice-chat/elevenlabs) [Music](/api-references/music-models/elevenlabs)

<mark style="background-color:green;">**Flux**</mark>: [Image](/api-references/image-models/flux)

**Google**: [Text/Chat](/api-references/text-models-llm/google) [Image](/api-references/image-models/google) [Video](/api-references/video-models/google) [Music](/api-references/vision-models/ocr-optical-character-recognition/google) [Vision(OCR)](/api-references/music-models/google) [Embedding](/api-references/embedding-models/google)

**Gryphe**: [Text/Chat](/api-references/text-models-llm/gryphe)

**Hume AI**: [Text-to-Speech](/api-references/speech-models/text-to-speech/hume-ai)

**Inworld**: [Text-to-Speech](/api-references/speech-models/text-to-speech/inworld)

<mark style="background-color:green;">**Kling AI**</mark>: [Image](/api-references/image-models/kling-ai) [Video](/api-references/video-models/kling-ai)

**Krea**: [Video](/api-references/video-models/krea)

**LTXV**: [Video](/api-references/video-models/ltxv)

**Meta**: [Text/Chat](/api-references/text-models-llm/meta)

**Microsoft**: [Text-to-Speech](/api-references/speech-models/text-to-speech/microsoft)

<mark style="background-color:green;">**MiniMax**</mark>: [Text/Chat](/api-references/text-models-llm/minimax) [Video](/api-references/video-models/minimax) [Music](/api-references/music-models/minimax) [Voice-Chat](/api-references/speech-models/voice-chat)

**Mistral AI**: [Text/Chat](/api-references/text-models-llm/mistral-ai) [Vision(OCR)](/api-references/vision-models/ocr-optical-character-recognition/mistral-ai)

**Moonshot**: [Text/Chat](/api-references/text-models-llm/moonshot)

**NousResearch**: [Text/Chat](/api-references/text-models-llm/nousresearch)

**NVIDIA**: [Text/Chat](/api-references/text-models-llm/nvidia)

<mark style="background-color:green;">**OpenAI**</mark>: [Text/Chat](/api-references/text-models-llm/openai) [Image](/api-references/image-models/openai) [Speech-To-Text](/api-references/speech-models/speech-to-text/openai) [Embedding](/api-references/embedding-models/openai)

**Perplexity**: [Text/Chat](/api-references/text-models-llm/perplexity)

**PixVerse:** [Video](/api-references/video-models/pixverse)

**RecraftAI**: [Image](/api-references/image-models/recraftai)

**Reve**: [Image](/api-references/image-models/reve)

**Runway**: [Video](/api-references/video-models/runway)

**Sber AI**: [Video](/api-references/video-models/sber-ai)

<mark style="background-color:green;">**Stability AI**</mark>: [Image](/api-references/image-models/stability-ai) [Music](/api-references/music-models/stability-ai) [3D-Generation](/api-references/3d-generating-models/stability-ai)

**StepFun**: [Text/Chat](/api-references/text-models-llm/stepfun)

**Tencent**: [Image](/api-references/image-models/tencent) [Video](/api-references/video-models/tencent) [3D](/api-references/3d-generating-models/tencent)

**VEED**: [Video](/api-references/video-models/veed)

**xAI**: [Text/Chat](/api-references/text-models-llm/xai) [Image](/api-references/image-models/xai) [Video](/api-references/video-models/xai)

**Zhipu**: [Text/Chat](/api-references/text-models-llm/zhipu)
{% endtab %}

{% tab title="Text Models by CAPABILITY" %}
{% content-ref url="/pages/OK6oBdkSyX2hIUJw0O0H" %}
[Completion and Chat Completion](/capabilities/completion-or-chat-models)
{% endcontent-ref %}

{% content-ref url="/pages/wsJkOZ0nHCLLwDoDNQ8D" %}
[Streaming Mode](/capabilities/streaming-mode)
{% endcontent-ref %}

{% content-ref url="/pages/lRPQC4QmxtpqCTIblyvz" %}
[Code Generation](/capabilities/code-generation)
{% endcontent-ref %}

{% content-ref url="/pages/6yXmWtTfeUCPft5341aw" %}
[Thinking / Reasoning](/capabilities/thinking-reasoning)
{% endcontent-ref %}

{% content-ref url="/pages/xhkO48FYd9TFBwAHGMmt" %}
[Function Calling](/capabilities/function-calling)
{% endcontent-ref %}

{% content-ref url="/pages/JvoFINbW7KOduZAFvOwX" %}
[Vision in Text Models](/capabilities/image-to-text-vision)
{% endcontent-ref %}

{% content-ref url="/pages/Ofr7iaCJpt04wnPRKfn1" %}
[Web Search](/capabilities/web-search)
{% endcontent-ref %}
{% endtab %}
{% endtabs %}

***

## Going Deeper

<table data-header-hidden data-full-width="false"><thead><tr><th width="409.4000244140625"></th><th valign="top"></th></tr></thead><tbody><tr><td><p><strong>Use more text model capabilities in your project:</strong><br><br><span data-gb-custom-inline data-tag="emoji" data-code="1f4d6">📖</span> <a href="/capabilities/completion-or-chat-models">​Completion and Chat Completion</a></p><p><span data-gb-custom-inline data-tag="emoji" data-code="1f4d6">📖</span> <a href="/capabilities/function-calling">Function Calling</a></p><p><span data-gb-custom-inline data-tag="emoji" data-code="1f4d6">📖</span> <a href="/capabilities/streaming-mode">Streaming Mode</a></p><p><span data-gb-custom-inline data-tag="emoji" data-code="1f4d6">📖</span> <a href="/capabilities/image-to-text-vision">Vision in Text Models (Image-to-Text)</a></p><p><span data-gb-custom-inline data-tag="emoji" data-code="1f4d6">📖</span> <a href="/capabilities/code-generation">Code Generation</a></p><p><span data-gb-custom-inline data-tag="emoji" data-code="1f4d6">📖</span> <a href="/capabilities/thinking-reasoning">Thinking / Reasoning</a></p><p><span data-gb-custom-inline data-tag="emoji" data-code="1f4d6">📖</span> <a href="/capabilities/web-search">Web Search</a><br><br></p></td><td valign="top"><p><strong>Miscellaneous</strong>:<br><br><span data-gb-custom-inline data-tag="emoji" data-code="1f517">🔗</span> <a href="/integrations/our-integration-list">Integrations</a></p><p><span data-gb-custom-inline data-tag="emoji" data-code="1f4d7">📗</span> <a href="/glossary/concepts">Glossary</a></p><p><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> <a href="/errors-and-messages/general-info">Errors and Messages</a></p><p><span data-gb-custom-inline data-tag="emoji" data-code="2753">❓</span> <a href="/faq/how-can-i-track-my-funds">FAQ </a>​</p><p><br></p></td></tr><tr><td><strong>Learn more about developer-specific features:</strong><br><br><span data-gb-custom-inline data-tag="emoji" data-code="1f4d6">📖</span> <a href="/api-references/text-models-llm/anthropic">Features of Anthropic Models</a><br></td><td valign="top"></td></tr></tbody></table>


# Quickstart

Make a first request to any model with the OpenAI SDK, Python requests or curl: base URL https\://api.aimlapi.com/v1, header Authorization: Bearer \<AIMLAPI\_KEY>.

{% hint style="success" %}
If you are a manager and simply want to test a model to evaluate its performance, for instance in content generation, the quickest approach is **to use** [**our Playground**](https://aimlapi.com/app/).\
It offers an intuitive, user-friendly interface—no coding required.

Programmatic API calls are best suited for developers who want to integrate a model into their own apps.
{% endhint %}

***

Here, you'll learn how to start using our API in your code.\
The following steps must be completed regardless of which of our models you plan to call:

* [generating an AIML API Key](#generating-an-aiml-api-key),
* [choosing and preparing your development environment](#choosing-and-preparing-the-development-environment),
* [making an API call](#making-an-api-call).

Let's walk through an example of connecting to [the Gemma 3](/api-references/text-models-llm/google/gemma-3) model via REST API.

## G**enerating an AIML API Key**

<details>

<summary><mark style="color:blue;">What is an API Key?</mark></summary>

You can find your AIML API keys on the [account page](https://aimlapi.com/app/keys).

An AIML API key is a credential that grants you access to our API from your code.\
It is a sensitive string that is shown **only at creation time** and should be kept confidential.\
Do not share this key with anyone, as it could be misused without your knowledge.\
If you lose it, generate a new key from your dashboard.

⚠️ <mark style="color:orange;">Note that API keys from third-party organizations cannot be used with our API:</mark> \ <mark style="color:orange;">you need AIML API keys.</mark>

***

To start using our models in the Playground or through the API, you need to create at least one API key.

You may also create separate API keys for individual employees, AI agents, teams, or specific workflows and tasks. This approach can simplify usage tracking, access management, and cost monitoring across different environments or use cases.

All API keys created within your account share the same account balance.

</details>

To use the AIML API, you need an account and at least one AIML API key.\
If you have not created them yet, follow these steps:

1. [**Create an Account**](https://aimlapi.com/app/sign-up): Visit the AI/ML API website and create an account.
2. [**Generate an API Key**](https://aimlapi.com/app/keys): After logging in, navigate to your account dashboard and generate your API key. Ensure that key is enabled on UI.

<figure><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2FgI6ytCZoMvgIWFQxUES8%2Fkeys-create-first.png?alt=media&amp;token=d114f172-293d-4a3b-89e5-2f97730b23a5" alt=""><figcaption></figcaption></figure>

Detailed instructions for managing your API keys in the dashboard can be found in the corresponding [Help Center article](https://help.aimlapi.com/article/19-how-to-create-an-api-key).

***

## Choosing the Development Environment

Each language has recommended environments for running code samples.

<table data-header-hidden><thead><tr><th width="196.9332275390625" valign="top"></th><th></th></tr></thead><tbody><tr><td valign="top"><strong>cURL</strong></td><td><ul><li><a href="https://reqbin.com/curl">REQBIN</a> is a web-based REST client that lets you quickly run cURL requests directly in your browser, without installing any tools.</li><li><a href="https://git-scm.com/install/windows">Git Bash</a> (Windows) or the built-in Terminal (macOS/Linux) allow you to run cURL examples and other command-line tools locally.</li></ul></td></tr><tr><td valign="top"><strong>Python</strong></td><td><ul><li><a href="https://jupyter.org/try-jupyter/lab/index.html">Jupyter Notebook</a> is a popular online environment for running Python code and is the fastest option if you do not want to install anything locally.</li><li><a href="https://code.visualstudio.com/download">Visual Studio Code</a> (VS Code) is a lightweight and widely used code editor that supports both Python and Node.js. It is suitable for running and debugging local examples and for working on real projects.</li></ul></td></tr><tr><td valign="top"><strong>JavaScript</strong></td><td><ul><li><a href="https://code.visualstudio.com/download">Visual Studio Code</a> (VS Code)</li></ul></td></tr></tbody></table>

{% hint style="info" %}
In the examples below for cURL, JavaScript and Python, we use the [**REST API**](/quickstart/supported-sdks#rest-api). This approach works with all of our APIs, but it is not the only way to integrate. You can use [**other supported SDKs**](/quickstart/supported-sdks).
{% endhint %}

## Making an API Call

Based on your environment, you will call our API differently. Below are three common ways to call our API using two popular languages: **cURL** (a command-line format for making HTTP requests rather than a programming language), **Python**, and **JavaScript** (NodeJS).

If you want to get started really quickly, choose one of the four expandable sections below.\
Each one contains instructions for calling our model using different tools and environments.\
The first two options are especially simple and suitable even for beginners.

For completeness, the same example is explained in detail in the [Code Step-by-Step](#code-step-by-step-explanation) section.

{% tabs %}
{% tab title="cURL" %}

```bash
curl -L \
  --request POST \
  --url 'https://api.aimlapi.com/v1/chat/completions' \
  --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "google/gemma-3-4b-it",
    "messages": [
      {
        "role": "user",
        "content": "Tell me about San Francisco"
      }
    ],
    "temperature": 0.7,
    "max_tokens": 512
  }'
```

{% endtab %}

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

```javascript
userPrompt = 'Tell me about San Francisco' // insert your request here

async function main() {
  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: 'google/gemma-3-4b-it',
      messages:[
          {
              role:'user',
              content: userPrompt
          }
      ],
      temperature: 0.7,
      max_tokens: 512,
    }),
  });

  const data = await response.json();
  const answer = data.choices[0].message.content;
  
  console.log('User:', userPrompt);
  console.log('AI:', answer);
}

main();
```

{% endcode %}
{% endtab %}

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

```python
import requests 

user_prompt = "Tell me about San Francisco"  # insert your request here

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>"
    },
    json={
        "model":"google/gemma-3-4b-it",
        "messages":[  
            {
                "role":"user",
                "content": user_prompt
            }
        ],
        "temperature": 0.7,
        "max_tokens": 512,
    }
)

data = response.json()
answer = data["choices"][0]["message"]["content"]

print("User:", user_prompt)
print("AI:", answer)
```

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

<details>

<summary><span data-gb-custom-inline data-tag="emoji" data-code="2b50">⭐</span> How to run a <mark style="color:$primary;"><strong>cURL</strong></mark> example in a web-based REST client (REQBIN)</summary>

<mark style="color:$info;">Calling the API via cURL through a web service like this is the simplest and fastest method, requiring no additional libraries. However, there is a downside: cURL is not a programming language, which means it has very limited capabilities for adding logic—only API calls, no loops or conditions. You can’t even extract just the specific field with the model’s text response—cURL returns the model’s full output, as you’ll see below.</mark>

***

1\. Copy the cURL example above and paste it into a text editor, such as Notepad or Notepad++.

2\. Replace the placeholder `<YOUR_AIMLAPI_KEY>` with your actual AIMLAPI Key.

3\. If needed, modify the prompt (the `content` field).

4\. Copy the modified example, go to the [REQBIN](https://reqbin.com/curl) website, paste it into the designated field and click **Run**:

<figure><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2FyK8k4Y6wKV8Z6Q2rgfqK%2Fimage.png?alt=media&amp;token=bd59328a-9f6a-4b88-ba80-c2e714f196b0" alt=""><figcaption></figcaption></figure>

5\. After the model processes your request, the model’s full output will be shown directly below the input field.

{% hint style="info" %}
Pro tip: try experimenting with the three different ways of displaying the model’s output.\
Some are more readable than others.
{% endhint %}

<figure><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2FsMPN4CLmfqjhA09p53sd%2Fimage.png?alt=media&amp;token=a2ff1f09-8712-49e4-adb8-0c038dbfd313" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary><span data-gb-custom-inline data-tag="emoji" data-code="2b50">⭐</span> How to run a <mark style="color:$primary;"><strong>Python</strong></mark> example in an online Jupyter Notebook</summary>

<mark style="color:$info;">The second fastest option, and a much more convenient choice, while offering more flexibility for customizing how the output is displayed in code.</mark>

***

**1**. When you open [Jupyter Notebook](https://jupyter.org/try-jupyter/notebooks/?path=Untitled.ipynb) for the first time, select **“Python 3.13 (XPython)”** in the pop-up window to indicate the programming language kernel you will be working with:

<div align="left"><figure><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2FDzy0tT9b0Fjmj8wlYJjD%2Fimage.png?alt=media&amp;token=210cf449-ff2e-401e-9ff7-712e49e8c51c" alt="" width="283"><figcaption></figcaption></figure></div>

{% hint style="info" %}
In some browsers, the kernel selection may look different:
{% endhint %}

<figure><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2FkQMLzdNnrRtgczKwF7e4%2Fimage.png?alt=media&amp;token=db529280-e805-4f33-80c6-7843fc95db4d" alt=""><figcaption></figcaption></figure>

2\. Enter the following command in the first cell to install the `requests` library:

```bash
%pip install requests
```

Click the **Run** button in the toolbar above the cell to execute it:

<figure><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fjl3kyuILEWCiToL9OTrK%2Fimage.png?alt=media&amp;token=6f0d6557-234a-4671-82df-1754a500c8a3" alt=""><figcaption></figcaption></figure>

3\. Paste our example into the second cell, replace the placeholder with your AIMLAPI Key, then click the **Run** button in the toolbar:

<figure><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2FE7fvTORnfKTY2P2dwfxn%2Fimage.png?alt=media&amp;token=90c9d52a-fbfe-479e-a8f9-083d499147ff" alt=""><figcaption></figcaption></figure>

4\. After the model processes your request, the result will be shown directly below the cell:

<figure><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fod8K3QgUtQo5C8kLqC0o%2Fimage.png?alt=media&amp;token=679dcd3b-1296-4cff-ac60-e5318f1046cc" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary>How to run a <mark style="color:$primary;"><strong>Python</strong></mark> example locally from the command line (without an IDE)</summary>

Let's start from very beginning. We assume you already installed Python (with `venv`), if not, here a [guide for the beginners](/faq/can-i-use-api-in-python).

Create a new folder for test project, name it as `aimlapi-welcome` and change to it.

```bash
mkdir ./aimlapi-welcome
cd ./aimlapi-welcome
```

(Optional) If you use IDE then we recommend to open created folder as workspace. On example, in Visual Studio Code you can do it with:

```
code .
```

Run a terminal inside created folder and create virtual envorinment with a command:

```shell
python3 -m venv ./.venv
```

Activate created virtual environment:

```shell
# Linux / Mac
source ./.venv/bin/activate
# Windows
./.venv/bin/Activate.bat
```

Install requirement dependencies. In our case (REST API SDK) we need only `request` library:

```shell
pip install requests
```

Create new file and name it as `travel.py`:

```shell
touch travel.py
```

Paste following content inside this `travel.py` and replace `<YOUR_AIMLAPI_KEY>` with your API key you got on [first step](#generating-an-api-key):

```python
import requests 

user_prompt = "Tell me about San Francisco"

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":"google/gemma-3-4b-it",
        "messages":[
            {
                "role":"user",
                "content": user_prompt
            }
        ],
        "temperature": 0.7,
        "max_tokens": 512,
    }
)

data = response.json()
answer = data["choices"][0]["message"]["content"]

print("User:", user_prompt)
print("AI:", answer)
```

Run the application:

```shell
python3 ./travel.py
```

If you done all correct, you will see following output:

{% code overflow="wrap" %}

```json5
User: Tell me about San Francisco
AI:  San Francisco, located in northern California, USA, is a vibrant and culturally rich city known for its iconic landmarks, beautiful vistas, and diverse neighborhoods. It's a popular tourist destination famous for its iconic Golden Gate Bridge, which spans the entrance to the San Francisco Bay, and the iconic Alcatraz Island, home to the infamous federal prison.

The city's famous hills offer stunning views of the bay and the cityscape. Lombard Street, the "crookedest street in the world," is a must-see attraction, with its zigzagging pavement and colorful gardens. Ferry Building Marketplace is a great place to explore local food and artisanal products, and the Pier 39 area is home to sea lions, shops, and restaurants.

San Francisco's diverse neighborhoods each have their unique character. The historic Chinatown is the oldest in North America, while the colorful streets of the Mission District are known for their murals and Latin American culture. The Castro District is famous for its LGBTQ+ community and vibrant nightlife.
```

{% endcode %}

</details>

<details>

<summary>How to run a <mark style="color:$primary;"><strong>JavaScript</strong></mark> example locally from the command line (without an IDE)</summary>

We assume you already have Node.js installed. If not, here is a [guide for beginners](/faq/can-i-use-api-in-nodejs).

Create a new folder for the example project:

```bash
mkdir ./aimlapi-welcome
cd ./aimlapi-welcome
```

Create a project file:

```bash
npm init -y
```

Create a file with the source code:

```bash
touch ./index.js
```

And paste the following content to the file and save it:

```javascript
async function main() {
  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: 'google/gemma-3-4b-it',
      messages:[
          {
              role:'user',
              content: 'Tell me about San Francisco'  // Insert your prompt here
          }
      ],
      temperature: 0.7,
      max_tokens: 256,
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

Run the file:

```bash
./index.js
```

You will see a response that looks like this:

{% code overflow="wrap" %}

```json5
User: Tell me about San Francisco
AI: San Francisco, located in the northern part of California, USA, is a vibrant and culturally rich city known for its iconic landmarks, beautiful scenery, and diverse neighborhoods.

The city is famous for its iconic Golden Gate Bridge, an engineering marvel and one of the most recognized structures in the world. Spanning the Golden Gate Strait, this red-orange suspension bridge connects San Francisco to Marin County and offers breathtaking views of the San Francisco Bay and the Pacific Ocean.
```

{% endcode %}

</details>

***

## Code Step-by-Step

Below is a step-by-step explanation of the same API call in three variants: cURL, JavaScript, and Python. All three examples send an identical request to the `google/gemma-3-4b-it` chat model.

<details>

<summary>cURL</summary>

***

**1. Command start**

```bash
curl -L \
```

Runs the cURL HTTP client. The `-L` flag tells cURL to follow redirects (if any).

***

**2. HTTP method**

```bash
--request POST \
```

Specifies that the request uses the **POST** method.

***

**3. Endpoint**

```bash
--url 'https://api.aimlapi.com/v1/chat/completions' \
```

The full endpoint URL used to call chat models.

***

**4. Authorization header**

```bash
--header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
```

Sends your AIMLAPI key in the `Authorization` header.

***

**5. Content type**

```bash
--header 'Content-Type: application/json' \
```

Indicates that the request body is JSON.

***

**6. Request body**

```bash
--data '{
  "model": "google/gemma-3-4b-it",
  "messages": [
    {
      "role": "user",
      "content": "Tell me about San Francisco"
    }
  ],
  "temperature": 0.7,
  "max_tokens": 512
}'
```

This is the payload sent to the API:

* `model` – the model identifier.
* `messages` – the chat history.
  * `role: "user"` – the user message.
  * `content` – the user prompt.
* `temperature` – controls output randomness.
* `max_tokens` – the maximum number of tokens in the response.

{% hint style="info" %}
These are the input parameters used to tell the endpoint—which in this case generates text answers—what exactly we want it to produce.

With the parameters shown above, we are effectively asking the API to use the `google/gemma-3-4b-it` model and generate a reasonably vivid and engaging description of San Francisco, limited to roughly 300–350 words— with the `temperature` and `max_tokens` parameters controlling the creativity and approximate length of the output, respectively.
{% endhint %}

***

**7. Response**

In the cURL example, you receive the **entire JSON response**.\
No fields are extracted — cURL simply prints the raw output.

</details>

<details>

<summary>JavaScript (Node.js)</summary>

***

**1. Define the user prompt**

```js
userPrompt = 'Tell me about San Francisco'
```

Stores the text of the user request.

***

**2. Call the API**

```js
const response = await fetch(
  'https://api.aimlapi.com/v1/chat/completions',
  { ... }
);
```

Sends an HTTP request to the endpoint.

***

**3. HTTP method**

```js
method: 'POST',
```

Specifies that the request uses the **POST** method.

***

**4. Headers**

```js
headers: {
  'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
  'Content-Type': 'application/json',
},
```

* Sends your AIMLAPI key in the `Authorization` header.
* Indicates that the request body is JSON.

***

**5. Request body**

```js
body: JSON.stringify({
  model: 'google/gemma-3-4b-it',
  messages: [
    {
      role: 'user',
      content: userPrompt
    }
  ],
  temperature: 0.7,
  max_tokens: 512,
}),
```

This is the payload sent to the API:

* `model` – the model identifier.
* `messages` – the chat history.
  * `role: "user"` – the user message.
  * `content` – the user prompt.
* `temperature` – controls output randomness.
* `max_tokens` – the maximum number of tokens in the response.

{% hint style="info" %}
These are the input parameters used to tell the endpoint—which in this case generates text answers—what exactly we want it to produce.

With the parameters shown above, we are effectively asking the API to use the `google/gemma-3-4b-it` model and generate a reasonably vivid and engaging description of San Francisco, limited to roughly 300–350 words— with the `temperature` and `max_tokens` parameters controlling the creativity and approximate length of the output, respectively.
{% endhint %}

***

**6. Parse the response**

```js
const data = await response.json();
```

Converts the API response into a JavaScript object.

***

**7. Extract the model’s text output**

```js
const answer = data.choices[0].message.content;
```

Reads the text of the first generated message.

***

**8. Print the result**

```js
console.log('User:', userPrompt);
console.log('AI:', answer);
```

Output formatting: from the model’s full response, only the generated text is extracted, and it is presented together with the original prompt in a dialogue-style format.

***

</details>

<details>

<summary>Python</summary>

***

**1. Import the HTTP library**

```python
import requests
```

The `requests` library is used to send HTTP requests.

***

**2. Define the user prompt**

```python
user_prompt = "Tell me about San Francisco"
```

Stores the text of the user query.

***

**3. Call the API**

```python
response = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    ...
)
```

Sends a POST request to the endpoint.

***

**4. Headers**

```python
headers={
    "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
    "Content-Type": "application/json"
},
```

* Sends your AIMLAPI key in the `Authorization` header.
* Indicates that the request body is JSON.

***

**5. Request body**

```python
json={
    "model": "google/gemma-3-4b-it",
    "messages": [
        {
            "role": "user",
            "content": user_prompt
        }
    ],
    "temperature": 0.7,
    "max_tokens": 512,
}
```

This is the payload sent to the API:

* `model` – the model identifier.
* `messages` – the chat history.
  * `role: "user"` – the user message.
  * `content` – the user prompt.
* `temperature` – controls output randomness.
* `max_tokens` – the maximum number of tokens in the response.

{% hint style="info" %}
These are the input parameters used to tell the endpoint—which in this case generates text answers—what exactly we want it to produce.

With the parameters shown above, we are effectively asking the API to use the `google/gemma-3-4b-it` model and generate a reasonably vivid and engaging description of San Francisco, limited to roughly 300–350 words— with the `temperature` and `max_tokens` parameters controlling the creativity and approximate length of the output, respectively.
{% endhint %}

***

**6. Parse the response**

```python
data = response.json()
```

Converts the JSON response into a Python dictionary.

***

**7. Extract the model’s text output**

```python
answer = data["choices"][0]["message"]["content"]
```

Reads the text of the first generated message.

***

**8. Print the result**

```python
print("User:", user_prompt)
print("AI:", answer)
```

Output formatting: from the model’s full response, only the generated text is extracted, and it is presented together with the original prompt in a dialogue-style format.

</details>

***

## Future Steps

* [Move to production-ready models: see the guide for connecting GPT-4o](/quickstart/simple-model/requesting-more-advanced-models)
* [Browse and compare AI models, including GPT, Claude, and many others, using the Playground](https://aimlapi.com/app/)
* [Know more about supported SDKs](/quickstart/supported-sdks)
* [Learn more about special text model capabilities](/capabilities/completion-or-chat-models)
* [Join the community: get help and share your projects in our Discord](https://discord.com/invite/hvaUsJpVJf)


# Requesting more advanced models

This guide uses a more advanced model, [GPT-4o](/api-references/text-models-llm/openai/gpt-4o), and also explains how to use various chat model capabilities:

* streaming mode
* calling tools
* uploading images to the model for analysis
* uploading files to the model for analysis
* web search

{% hint style="info" %}
If you need help with API keys or environment configuration, go back to the previous step and follow [the detailed quickstart guide](/quickstart/simple-model) for the Gemma 3 model.
{% endhint %}

***

## Making an API Call

The chat model used in this example is more advanced. In addition to regular user messages, it supports the `system` role in the `messages` parameter, which can be used to define global instructions that affect the model’s overall behavior, for example:

```python
messages: [
    {
      role: "system",
      content: "You are a travel agent. Be descriptive and helpful.",
    },
    {
      role: "user",
      content: "Tell me about San Francisco",
    },
],
```

Here’s the complete code you can use right away in a cURL, Python, or Node.js program. You only need to replace `<YOUR_AIMLAPI_KEY>` with your AIML API key from your account, provide your behavior instructions in the system prompt, and place your request to the model in the user prompt.

{% tabs %}
{% tab title="cURL" %}

```bash
curl -L \
  --request POST \
  --url 'https://api.aimlapi.com/v1/chat/completions' \
  --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-4o",
    "messages": [
      {
        "role": "system",
        "content": "You are a travel agent. Be descriptive and helpful.",
      }, 
      {
        "role": "user",
        "content": "Tell me about San Francisco"
      }
    ],
    "temperature": 0.7,
    "max_tokens": 512
  }'
```

{% endtab %}

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

```javascript
systemPrompt = 'You are a travel agent. Be descriptive and helpful.' // instructions
userPrompt = 'Tell me about San Francisco' // your request

async function main() {
  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: 'gpt-4o',
      messages:[
          {
              role: 'system',
              content: systemPrompt,
          }, 
          {
              role: 'user',
              content: userPrompt
          }
      ],
      temperature: 0.7,
      max_tokens: 512,
    }),
  });

  const data = await response.json();
  const answer = data.choices[0].message.content;
  
  console.log('User:', userPrompt);
  console.log('AI:', answer);
}

main();
```

{% endcode %}
{% endtab %}

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

```python
import requests
import json  # for getting a structured output with indentation 

system_prompt = "You are a travel agent. Be descriptive and helpful."
user_prompt = "Tell me about San Francisco"

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":"gpt-4o",
        "messages":[
            {
                "role":"system",
                "content": system_prompt,
            },       
            {
                "role":"user",
                "content": user_prompt,
            }
        ],
        "temperature": 0.7,
        "max_tokens": 256,
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

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

***

## **Using Streaming Mode**

Streaming lets the model send partial responses as they’re generated instead of waiting for the full output — useful for real‑time feedback.

### Full Streaming Response (Raw Events)

This example shows how to consume the streaming response as-is, without abstraction. Each chunk is processed in real time, exposing the full event structure returned by the API.

Use this approach if you need:

* access to all event types
* fine-grained control over parsing
* debugging or logging of raw responses
* support for metadata beyond plain text

{% tabs %}
{% tab title="Python" %}

```python
import requests
import json  # for getting a structured output with indentation 

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":"gpt-4o",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ],
        "stream": True
    }
)

# data = response.json()
print(response.text)
```

{% endtab %}

{% tab title="Python + OpenAI SDK" %}

```python
from openai import OpenAI

# Initialize the client
client = OpenAI(
    # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
    api_key="YOUR_AIMLAPI_KEY",
    base_url="https://api.aimlapi.com/v1"
)

# Create a streaming chat completion
stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {
            "role": "user",
            "content": "Hi! What do you think about mankind?"
        }
    ],
    stream=True
)

# Print raw chunks (similar to response.text in requests)
for chunk in stream:
    print(chunk)
```

{% endtab %}
{% endtabs %}

<details>

<summary>Example raw streaming response</summary>

{% code overflow="wrap" expandable="true" %}

```json
data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"RmYFV8ad65HP9F"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"fjE24R0ZOJr"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":"!"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"qAlxZuNpvVvIIOm"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" As"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"Zn3rsadkL8zHO"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" an"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"D1ss0WZmiGg8l"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" AI"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"bOHB8VYpq4G0W"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":","},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"OwZvgIyMlYVcIgH"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" I"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"u9lFaH3ngdK6MR"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" don't"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"KRFgmSe4yG"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" have"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"YL8zlQ9PjDF"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" personal"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"Gzgb5OT"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" opinions"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"Flz362J"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" or"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"XA0qqmSQr2jme"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" feelings"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"VA3dwaU"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":","},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"POplI0eiOWXpIPD"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" but"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"aDifMrQ8OH9i"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" I"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"ceVweUN2pByieS"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" can"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"txjYCds61AQp"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" provide"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"IGlSpZBf"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" an"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"BtPIfSvUXgRnl"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" overview"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"IYfRhEo"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" of"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"uh8pR2mNtYSNQ"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" various"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"ILZ0ffVW"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" perspectives"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"Rgs"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" on"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"r7Awao2PSZ0DH"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" mankind"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"m8vJ3dzf"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"f2wZrEj0RqUFprg"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" Humanity"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"cCPi2qV"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" is"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"yNd7SUoXBojpA"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" often"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"VEaggK2dFS"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" viewed"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"8nhopBJZe"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" as"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"6xG2VkJLonAeF"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" a"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"WDu20GtJyN8Lep"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" complex"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"4bE4D3tS"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" and"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"DZtW3Ahopdgl"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" multif"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"8bS4GMzf3"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":"aceted"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"ivtxUAov3l"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" species"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"Xcq85kDt"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" capable"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"PfwZUtYS"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" of"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"DoyM4RGNLxnFc"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" remarkable"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"mUvVH"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" achievements"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"4fl"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" and"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"GUdfkDUkNBNO"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" profound"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"x4KCnLk"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" creativity"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"goTL4"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"gkqK9sezr258S93"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" People"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"c49BcmfXz"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" have"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"Br7pbWtK86v"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" built"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"dzAoO36Siv"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" civilizations"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"yS"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":","},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"hiMiIGF7QM9BeJA"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" explored"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"IhuVoUB"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" space"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"qNqiO3hyXB"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":","},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"UVmzp6Y0qjb7Zkb"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" and"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"iiIw0gK2MP5D"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" developed"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"FJUJhv"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" technologies"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"pkQ"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" that"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"sAhx0IJoR0m"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" transform"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"YDTnhx"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" everyday"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"imFIYIz"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" life"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"6xJBjebVPfo"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"DKIPIwgAnVDj3g1"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" At"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"HhuMheG0mPcuI"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" the"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"yIQIWY1CXoW6"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" same"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"QcKwiqSqGRU"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" time"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"f6e6uGKikn5"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":","},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"1eXIFULDN1iS8b1"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" humans"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"GH0z8I36B"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" face"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"JLUmj9BN7PQ"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" significant"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"qdQg"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" challenges"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"KMzNb"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" such"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"8pw9I3FGElO"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" as"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"nY0RLEY6Am9zD"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" environmental"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"4r"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" degradation"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"1zGA"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":","},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"bhbZZCR7wNgWQkq"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" social"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"FcCsVIGji"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" inequalities"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"6kb"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":","},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"Z4Zz2oDgc5zw0D6"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" and"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"Q5XvheR2EWhq"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" geopolitical"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"ySW"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" conflicts"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"eiERwe"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"oNAsPbgeJSOuPMg"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" The"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"4TwzxlGRpebL"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" potential"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"lW3Jfo"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" for"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"Ejvws7kQryhN"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" both"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"HVm3EDKAkuA"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" positive"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"HMY8pYv"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" change"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"fbOaTSNWR"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" and"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"ETmTxHsFbCkw"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" destructive"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"WHk8"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" behavior"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"EvSYFf5"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" makes"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"yfwGRy20jz"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" mankind"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"vwJGC8sU"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" a"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"nHyqFYnTzVmVsE"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" subject"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"wtm8Wh9c"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" of"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"gnLF2uDFfg976"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" deep"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"BEc6wh2y2vV"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" contemplation"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"zf"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" and"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"vpg86EhZm5c3"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" varied"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"iWNJAcR7a"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":" viewpoints"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"JRXUN"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"5yN6iGLyFLiQV0H"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null,"obfuscation":"4lkqbaPLDt"}

data: {"id":"chatcmpl-DL2G9KdEY06xq8M0PqZ5rs5Jv13ok","object":"chat.completion.chunk","created":1773905945,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_f986a632b0","choices":[],"usage":{"prompt_tokens":16,"completion_tokens":102,"total_tokens":118,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}},"obfuscation":"VChaI1ntRBrTy"}
```

{% endcode %}

</details>

### Streaming Response Processing (Text Extraction)

This example shows how to process the streaming response to extract only the generated text. Instead of handling all event types, the code filters incoming chunks and prints the content as it arrives. Use this approach if you only need the generated text.

{% tabs %}
{% tab title="Python" %}
{% code expandable="true" %}

```python
import requests
import json

url = "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"
}

payload = {
    "model": "gpt-4o",
    "messages": [
        {"role": "user", "content": "Explain quantum computing simply."}
    ],
    "stream": True
}

with requests.post(url, headers=headers, json=payload, stream=True) as r:
    # Iterate over the streaming response line by line
    for line in r.iter_lines():
        if not line:
            continue  # Skip empty lines

        # Decode bytes to string
        line = line.decode("utf-8")

        # SSE messages start with "data: "
        if not line.startswith("data: "):
            continue

        # Remove the "data: " prefix
        data_str = line[len("data: "):]

        # "[DONE]" indicates the end of the stream
        if data_str.strip() == "[DONE]":
            break

        try:
            # Parse JSON payload
            data = json.loads(data_str)
        except json.JSONDecodeError:
            continue  # Skip malformed chunks
        
        # Ensure "choices" exists and is not empty
        choices = data.get("choices")
        if not choices:
            continue

        # Extract text delta (OpenAI-style streaming format)
        delta = data.get("choices", [{}])[0].get("delta", {})
        content = delta.get("content")

        # Print text as it arrives
        if content:
            print(content, end="")
```

{% endcode %}
{% endtab %}

{% tab title="Python + OpenAI SDK" %}
{% code expandable="true" %}

```python
from openai import OpenAI

client = OpenAI(
    # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
    api_key="<YOUR_AIMLAPI_KEY>",
    base_url="https://api.aimlapi.com/v1"
)

stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "user", "content": "Explain quantum computing simply."}
    ],
    stream=True
)

# Iterate over streaming chunks
for chunk in stream:
    # Ensure choices exist and are not empty
    if not chunk.choices:
        continue

    delta = chunk.choices[0].delta
    content = getattr(delta, "content", None)

    # Print text as it arrives
    if content:
        print(content, end="")
```

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

<details>

<summary>Example processed clean streaming response</summary>

{% code overflow="wrap" %}

```json
Quantum computing is a type of computing that uses principles of quantum mechanics to process information. Unlike classical computers, which use bits to represent data as 0s or 1s, quantum computers use quantum bits or qubits. 

Qubits have unique properties that give quantum computers more power in certain tasks:

1. **Superposition**: A qubit can exist in multiple states (i.e., both 0 and 1) simultaneously. This allows quantum computers to process a vast amount of possibilities at once.

2. **Entanglement**: Qubits can be linked together in such a way that the state of one qubit can depend on the state of another, no matter the distance apart. This can lead to more efficient processing and problem-solving.

3. **Quantum Interference**: Quantum algorithms make use of interference, where different quantum states can amplify or cancel each other out, guiding the computation toward the correct answer.

Because of these properties, quantum computers have the potential to solve certain complex problems much faster than classical computers can, potentially revolutionizing fields like cryptography, materials science, and optimization. However, building practical quantum computers is extremely challenging due to issues with qubit stability and error rates.
```

{% endcode %}

</details>

***

## **Tool calling**

GPT‑4o can call functions/tools you define in the API request to extend behavior (e.g., performing calculations, retrieving structured data).

<details>

<summary>How it works</summary>

1. **Initial request** — The model receives the user prompt and the registered tool, and generates a `tool_calls` object indicating which function it wants to execute.
2. **Extract and run the tool** — Parse the `arguments` from the `tool_calls` object and execute the function locally.
3. **Send back the result** — Return the computed result to the model using the `tool` role and the `content` field.
4. **Final response** — The model incorporates the tool’s output and generates a complete answer for the user.

</details>

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

```python
import requests
import json

# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
api_key = "<YOUR_AIMLAPI_KEY>"
base_url = "https://api.aimlapi.com/v1"

headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json"
}

# Step 1: Define the tool correctly
tool = {
    "type": "function",
    "function": {
        "name": "toCelsius",
        "description": "Convert Fahrenheit to Celsius",
        "parameters": {
            "type": "object",
            "properties": {
                "fahrenheit": {"type": "number"}
            },
            "required": ["fahrenheit"]
        }
    }
}

# Step 2: Initial request with the tool
payload = {
    "model": "gpt-4o",
    "messages": [
        {"role": "user", "content": "Convert 256°F to °C"}
    ],
    "tools": [tool]
}

response = requests.post(f"{base_url}/chat/completions", headers=headers, json=payload)
data = response.json()

# Step 3: Extract tool call
tool_calls = data["choices"][0]["message"].get("tool_calls", [])
if not tool_calls:
    raise ValueError("No tool calls found. Make sure the tool is correctly defined.")

tool_call = tool_calls[0]
arguments = json.loads(tool_call["function"]["arguments"])
fahrenheit = arguments["fahrenheit"]

# Step 4: Execute the tool locally
celsius_result = (fahrenheit - 32) * 5 / 9

# Step 5: Send result back to model
final_payload = {
    "model": "gpt-4o",
    "messages": [
        {"role": "user", "content": "Convert 256°F to °C"},
        {
            "role": "assistant",
            "tool_calls": [
                {
                    "id": tool_call["id"],
                    "type": "function",
                    "function": {
                        "name": tool_call["function"]["name"],
                        "arguments": tool_call["function"]["arguments"]
                    }
                }
            ]
        },
        {
            "role": "tool",
            "tool_call_id": tool_call["id"],
            "content": str(celsius_result)
        }
    ]
}

final_response = requests.post(f"{base_url}/chat/completions", headers=headers, json=final_payload)
final_data = final_response.json()

# Step 6: Print final answer
print(final_data["choices"][0]["message"]["content"])
```

{% endcode %}
{% endtab %}

{% tab title="Python + OpenAI SDK" %}
{% code overflow="wrap" %}

```python
from openai import OpenAI
import json

client = OpenAI(
    # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
    api_key="<YOUR_AIMLAPI_KEY>",
    base_url="https://api.aimlapi.com/v1"
)

# Step 1: Define the tool correctly
tool = {
    "type": "function",
    "function": {
        "name": "toCelsius",
        "description": "Convert Fahrenheit to Celsius",
        "parameters": {
            "type": "object",
            "properties": {
                "fahrenheit": {"type": "number"}
            },
            "required": ["fahrenheit"]
        }
    }
}

# Step 2: Initial request with tool
initial_response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Convert 256°F to °C"}],
    tools=[tool]
)

# Step 3: Extract tool call
assistant_message = initial_response.choices[0].message
tool_calls = getattr(assistant_message, "tool_calls", [])
if not tool_calls:
    raise ValueError("No tool calls found. Make sure the tool is correctly defined.")

tool_call = tool_calls[0]
arguments = json.loads(tool_call.function.arguments)
fahrenheit = arguments["fahrenheit"]

# Step 4: Execute tool locally
celsius_result = (fahrenheit - 32) * 5 / 9

# Step 5: Send result back
final_response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "user", "content": "Convert 256°F to °C"},
        {
            "role": "assistant",
            "tool_calls": [
                {
                    "id": tool_call.id,
                    "type": "function",
                    "function": {
                        "name": tool_call.function.name,
                        "arguments": tool_call.function.arguments,
                    },
                }
            ],
        },
        {
            "role": "tool",
            "tool_call_id": tool_call.id,
            "content": str(celsius_result),
        },
    ],
)

print(final_response.choices[0].message.content)
```

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

<details>

<summary>Example response</summary>

{% code overflow="wrap" expandable="true" %}

```json
256°F is approximately 124.44°C.
```

{% endcode %}

</details>

***

## **Image upload**

GPT‑4o supports vision inputs: you can send an image URL in the `messages` request to let the model analyze or describe it.

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

```python
import requests
import json

url = "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"
}

payload = {
  "model": "gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": [
        {"type": "text", "text": "Describe this scene:"},
        {"type": "image_url", "image_url": {"url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/mona_lisa_extended.jpg"}}
      ]
    }
  ]
}

response = requests.post(url, headers=headers, data=json.dumps(payload))
data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

{% tab title="Python + OpenAI SDK" %}
{% code overflow="wrap" %}

```python
from openai import OpenAI
import json

# Initialize the client
client = OpenAI(
    # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:  
    api_key="<YOUR_AIMLAPI_KEY>",
    base_url="https://api.aimlapi.com/v1"
)

# Prepare the messages with text and image_url
messages = [
    {
        "role": "user",
        "content": [
            {"type": "text", "text": "Describe this scene:"},
            {
                "type": "image_url",
                "image_url": {
                    "url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/mona_lisa_extended.jpg"
                }
            }
        ]
    }
]

# Create a chat completion
response = client.chat.completions.create(
    model="gpt-4o",
    messages=messages
)

# Print full JSON response
print(json.dumps(response.model_dump(), indent=2, ensure_ascii=False))
```

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

<details>

<summary>Example response</summary>

{% code overflow="wrap" %}

```json
{
  "id": "chatcmpl-DL3DDPif2s79HbOHySq6bVY8SAsKQ",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "message": {
        "content": "The scene is an iconic Renaissance portrait showing a woman with an enigmatic smile, known for its mastery of detail and composition. The woman is seated against a distant, dreamlike landscape featuring winding paths and rocky formations. She wears a dark dress and light veil, with her hands delicately folded. The background's atmospheric perspective creates depth, with bluish mountains fading into the horizon. The artwork evokes a sense of mystery and balance.",
        "refusal": null,
        "role": "assistant",
        "annotations": [],
        "audio": null,
        "function_call": null,
        "tool_calls": null
      }
    }
  ],
  "created": 1773909607,
  "model": "gpt-4o-2024-08-06",
  "object": "chat.completion",
  "service_tier": "default",
  "system_fingerprint": "fp_0a8aa8bfeb",
  "usage": {
    "completion_tokens": 85,
    "prompt_tokens": 776,
    "total_tokens": 861,
    "completion_tokens_details": {
      "accepted_prediction_tokens": 0,
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "rejected_prediction_tokens": 0
    },
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0
    }
  },
  "meta": {
    "usage": {
      "credits_used": 7254
    }
  }
}
```

{% endcode %}

</details>

***

## **Web search integration**

With *search‑preview* models, you can perform live web search queries in combination with the model to get up‑to‑date results and grounded responses.

{% hint style="info" %}
See [the complete list of our search‑capable models](/capabilities/web-search#models-that-support-web-search).
{% endhint %}

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

```python
import json
import requests
from typing import Dict, Any

# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
API_KEY = "<YOUR_AIMLAPI_KEY>"
BASE_URL = "https://api.aimlapi.com/v1"

HEADERS = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
}


def search_impl(arguments: Dict[str, Any]) -> Any:
    return arguments


def chat(messages):
    url = f"{BASE_URL}/chat/completions"
    payload = {
        "model": "gpt-4o-mini-search-preview",
        "messages": messages,
        "temperature": 0.6,
        "tools": [
            {
                "type": "builtin_function",
                "function": {"name": "$web_search"},
            }
        ]
    }

    response = requests.post(url, headers=HEADERS, json=payload)
    response.raise_for_status()
    return response.json()["choices"][0]


def main():
    messages = [
        {"role": "system", "content": "You are GPT with web search skills."},
        {"role": "user", "content": "Please search for AGI and tell me what it is in English."}
    ]

    finish_reason = None
    while finish_reason is None or finish_reason == "tool_calls":
        choice = chat(messages)
        finish_reason = choice["finish_reason"]
        message = choice["message"]

        if finish_reason == "tool_calls":
            messages.append(message)

            for tool_call in message["tool_calls"]:
                tool_call_name = tool_call["function"]["name"]
                tool_call_arguments = json.loads(tool_call["function"]["arguments"])

                if tool_call_name == "$web_search":
                    tool_result = search_impl(tool_call_arguments)
                else:
                    tool_result = f"Error: unable to find tool by name '{tool_call_name}'"

                messages.append({
                    "role": "tool",
                    "tool_call_id": tool_call["id"],
                    "name": tool_call_name,
                    "content": json.dumps(tool_result),
                })

    print(message["content"])


if __name__ == "__main__":
    main()
```

{% endcode %}
{% endtab %}

{% tab title="Python + OpenAI SDK" %}
{% code overflow="wrap" %}

```python
import json
from typing import Dict, Any
from openai import OpenAI

# Insert your API key
client = OpenAI(
    # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
    api_key="YOUR_AIMLAPI_KEY",
    base_url="https://api.aimlapi.com/v1"
)


def search_impl(arguments: Dict[str, Any]) -> Any:
    return arguments


def chat(messages):
    response = client.chat.completions.create(
        model="gpt-4o-mini-search-preview",
        messages=messages,
        temperature=0.6,
        tools=[
            {
                "type": "function",
                "function": {
                    "name": "$web_search",
                    "parameters": {
                        "type": "object",
                        "properties": {},
                    },
                },
            }
        ],
    )
    return response.choices[0]


def main():
    messages = [
        {"role": "system", "content": "You are GPT with web search skills."},
        {"role": "user", "content": "Please search for AGI and tell me what it is in English."}
    ]

    finish_reason = None
    while finish_reason is None or finish_reason == "tool_calls":
        choice = chat(messages)
        finish_reason = choice.finish_reason
        message = choice.message

        if finish_reason == "tool_calls":
            messages.append(message.model_dump())

            for tool_call in message.tool_calls:
                tool_call_name = tool_call.function.name
                tool_call_arguments = json.loads(tool_call.function.arguments)

                if tool_call_name == "$web_search":
                    tool_result = search_impl(tool_call_arguments)
                else:
                    tool_result = f"Error: unable to find tool by name '{tool_call_name}'"

                messages.append({
                    "role": "tool",
                    "tool_call_id": tool_call.id,
                    "name": tool_call_name,
                    "content": json.dumps(tool_result),
                })

    print(message.content)


if __name__ == "__main__":
    main()
```

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

<details>

<summary>Example response</summary>

{% code overflow="wrap" %}

```json
"AGI" is an acronym that can represent different terms depending on the context:

1. **Adjusted Gross Income**: In the United States, AGI refers to Adjusted Gross Income, which is a taxpayer's total income from all sources minus allowable adjustments. This figure is used to determine taxable income and eligibility for various tax benefits. ([usafacts.org](https://usafacts.org/articles/adjusted-gross-income-agi-definition?utm_source=openai))

2. **Artificial General Intelligence**: In the field of artificial intelligence, AGI stands for Artificial General Intelligence. This concept refers to AI systems that possess the ability to understand, learn, and apply knowledge across a wide range of tasks, matching or surpassing human cognitive abilities. ([en.wikipedia.org](https://en.wikipedia.org/wiki/Artificial_general_intelligence?utm_source=openai))

3. **Alliance Graphique Internationale**: AGI also denotes the Alliance Graphique Internationale, an international organization of leading graphic artists and designers. ([en.wikipedia.org](https://en.wikipedia.org/wiki/Alliance_Graphique_Internationale?utm_source=openai))

4. **Agi Language**: Additionally, "Agi" is the name of a Torricelli language spoken in Papua New Guinea. ([en.wikipedia.org](https://en.wikipedia.org/wiki/Agi_language?utm_source=openai))

The specific meaning of "AGI" depends on the context in which it is used.
```

{% endcode %}

</details>

***

## Future Steps

* [Browse and compare AI models, including GPT, Claude, and many others, using the Playground](https://aimlapi.com/app/)
* [Know more about supported SDKs](/quickstart/supported-sdks)
* [Learn more about special text model capabilities](/capabilities/completion-or-chat-models)
* [Join the community: get help and share your projects in our Discord](https://discord.com/invite/hvaUsJpVJf)


# MCP

Connect Claude Desktop, Claude Code, Cursor and other MCP clients to AI/ML API over OAuth, with no API key to copy: discover models and run inference.

Connect AI/ML API to your AI client — **Claude Desktop, Claude (web), Cursor, Claude Code**, and other MCP-capable apps — over the [Model Context Protocol](https://modelcontextprotocol.io/) using **OAuth**.

You sign in with your AI/ML API account in the browser; there is **no API key to copy or paste**. Once connected, you can discover and compare models, run inference (LLM / image / video / audio / embeddings), manage long-running generation jobs, and check your balance — directly from the client.

Usage is billed to your AI/ML API account, exactly like the REST API.

> Prefer to paste an API key instead of signing in? That method is also supported — add an `Authorization: Bearer <YOUR_AIMLAPI_KEY>` header instead of using OAuth. This guide covers the **OAuth** (browser sign-in) flow.

## Prerequisites

* An **AI/ML API account** — create one at [https://aimlapi.com](https://aimlapi.com/).
* A client that supports **remote MCP servers over Streamable HTTP with OAuth** (all clients below do).
* A balance on your account if you plan to run billable inference (top up at <https://aimlapi.com/app/billing>).
* **A correct system clock.** OAuth tokens are time-sensitive — if your computer's date, time, or time zone is wrong, the sign-in will fail (and some clients won't even start the session). Make sure the clock is set automatically / synced before you begin.

## Endpoint

| Environment | MCP URL                       |
| ----------- | ----------------------------- |
| Production  | `https://mcp.aimlapi.com/mcp` |

You only ever enter this **one URL**. Your client discovers everything else (the sign-in page, how to register, how to get a token) automatically.

## How the OAuth connection works

When you add the server URL **without an API key**, your client:

1. Contacts the MCP server and is told that authentication is required.
2. Automatically discovers the AI/ML API authorization server.
3. Registers itself and opens your browser.
4. You **sign in to AI/ML API** and **approve access**; the client receives a token and connects.

You never handle a key. The client stores the token securely and refreshes it for you.

> **Note on the "Connect" button (Claude Desktop & web).** Adding the connector only *registers* it — it does not sign you in. After you add it, the connector appears with a **Connect** button; you must click **Connect** to open the browser and complete the AI/ML API sign-in. Until you click **Connect** and approve, the connector stays added but **not authenticated**, and its tools will not work.

## Claude Desktop

1. **Settings → Connectors → Add custom connector.**
2. **Name:** `AIMLAPI` · **Remote MCP server URL:** `https://mcp.aimlapi.com/mcp`
3. Click **Add**. The connector is now registered.
4. Click **Connect** on the AIMLAPI connector. A browser window opens → **sign in to AI/ML API** → **approve access**.
5. The connector shows **connected**, and the AI/ML API tools become available in your chats.
6. **Verify:** open a chat and ask *"Use AI/ML API to check my account balance."* A returned balance confirms the connection and authorization are working.

**Remove:** **Settings → Connectors → AI/ML API → Remove / Disconnect.**

## Claude (web — claude.ai)

1. Open **Settings → Connectors → Add custom connector** (on Team/Enterprise plans this is done by an Owner under **Organization settings → Connectors**).
2. Enter the URL `https://mcp.aimlapi.com/mcp` and add it.
3. Click **Connect** on the AIMLAPI connector. A browser flow opens → **sign in to AI/ML API** → **approve** → connected.
4. **Verify:** ask *"Use AI/ML API to check my account balance."*

> Custom-connector availability depends on your Claude plan.

**Remove:** **Settings → Connectors → AI/ML API → Remove.**

## Cursor

Add the server to `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (project). **Do not add a `headers` block** — leaving it out is what triggers the OAuth flow:

```json
{
  "mcpServers": {
    "aimlapi": {
      "url": "https://mcp.aimlapi.com/mcp"
    }
  }
}
```

Then open **Cursor Settings → Tools & Integrations** and find **aimlapi**. It usually appears **Disabled** first — click **···→ Enable**, then click **Login**. A browser opens → **sign in to AI/ML API** → **Allow**. The server turns green when connected.

**Verify:** in an Agent chat, ask *"Using aimlapi, check my account balance."*

**Remove:** Cursor cannot delete an MCP server from the UI — the **···** menu only offers Configure / Reload / Enable. To remove it, open `~/.cursor/mcp.json` (the **Configure** dialog shows its path) and delete the `aimlapi` block, then **Reload** or restart Cursor. Note: turning off the source toggle only hides the server from the UI — the entry stays in the file until you delete it there.

## Claude Code (CLI)

```bash
claude mcp add --transport http aimlapi https://mcp.aimlapi.com/mcp
```

By default this adds the server in **local** scope — it is only available inside the current folder / project. To make it available everywhere, add `--scope user`:

```bash
claude mcp add --transport http --scope user aimlapi https://mcp.aimlapi.com/mcp
```

Then, inside an interactive Claude Code session, run **`/mcp`**, select **aimlapi**, and choose **Authenticate** — a browser opens for you to sign in. (Do **not** pass an `--header` flag; that switches the client to API-key auth instead of OAuth.)

**Verify:** run `claude mcp list` (the server should show as connected), or in a session ask *"Use the aimlapi MCP to check my account balance."*

**Remove:** `claude mcp remove aimlapi` (confirm with `claude mcp list`).

## Other MCP clients

Any client implementing the MCP authorization spec (OAuth 2.1 + PKCE with dynamic client registration) works the same way: point it at `https://mcp.aimlapi.com/mcp` with no API key and complete the browser sign-in. To inspect the flow step by step, use the MCP Inspector:

```bash
npx @modelcontextprotocol/inspector@latest
```

Set **Transport = Streamable HTTP**, **URL = `https://mcp.aimlapi.com/mcp`**, then use **Open Auth Settings → Quick OAuth Flow**.

## What you can do once connected

* **Discover models** — search and compare the catalog, get a comparable headline price.
* **Run inference** — LLM chat, embeddings, image / video / audio generation.
* **Manage jobs** — submit long-running generations and poll their status/results.
* **Account** — check your balance and usage.

Every call is billed to your AIML API account, just like the REST API.

### Example requests

Once connected, you talk to AIML API in plain language from your client. Because AIML API is an aggregator of **1000+ models**, you can do things no single-provider MCP can.

**Pick the right model for the job** *(unique to an aggregator)*

* "Find the cheapest model with function calling and 128k context, and show the cost per 1M tokens."
* "Compare GPT-5.6 Sol and Claude Opus 4.8 on price and context window."
* "Which AIML API model is best for coding agents?"
* "Run this prompt through the top 3 models and show me the answers side by side."

**Keep an eye on spend (AI FinOps)**

* "What's my AIML API balance?"
* "How much have I spent this month, and on what?"
* "Suggest a cheaper model for my last task."

**Discover the catalog**

* "List the newest LLMs on AIML API."
* "Show me all image models and their prices."

**Run inference**

* "Explain OAuth in two sentences."
* "Generate an image of a mountain lake at sunset with Nano Banana 2."
* "Create embeddings for these three sentences."

Your client picks the right AIML API tool automatically and streams the result back into the chat.

## Managing the connection

To stop using AIML API from a client, **remove or disconnect** the AI/ML API connector — the exact step differs per client:

| Client         | How to remove                                                                                                           |
| -------------- | ----------------------------------------------------------------------------------------------------------------------- |
| Claude Desktop | Settings → Connectors → AI/ML API → Remove / Disconnect.                                                                |
| Claude (web)   | Settings → Connectors → AI/ML API → Remove.                                                                             |
| Cursor         | Edit `~/.cursor/mcp.json` and delete the `aimlapi` block (cannot be removed from the UI), then Reload / restart Cursor. |
| Claude Code    | `claude mcp remove aimlapi`.                                                                                            |

**Clean reinstall.** Removing the connector in the client does not always revoke the OAuth token on the AI/ML API side. For a fully clean reinstall — one that shows the sign-in / approval screen again — also revoke the app's access in your AI/ML API account (**Authorized apps / Connections → Revoke**) before adding the server back.

## Troubleshooting

<table data-search="false"><thead><tr><th>Symptom</th><th>Fix</th></tr></thead><tbody><tr><td>Browser didn't open, or the client is stuck "connecting"</td><td>Remove the connector and add it again; make sure you clicked <strong>Connect</strong> and completed the AI/ML API sign-in in the browser.</td></tr><tr><td>Session won't start / "clock is set incorrectly" / sign-in fails immediately</td><td>Your system clock is wrong. Set the date, time, and time zone automatically, then retry — OAuth tokens are time-sensitive.</td></tr><tr><td>Connector added but tools don't work</td><td>You likely didn't click <strong>Connect</strong> (Desktop / web) or <strong>Enable + Login</strong> (Cursor). The connector must be authenticated, not just added.</td></tr><tr><td>Server shows <strong>Disabled</strong> in Cursor after editing <code>mcp.json</code></td><td>Open <strong>···→ Enable</strong>, then <strong>Login</strong> to authenticate.</td></tr><tr><td>MCP works in one folder but is missing in another (Claude Code)</td><td>It was added in <strong>local</strong> scope. Re-add with <code>--scope user</code> to make it global.</td></tr><tr><td>Reinstalled but never asked to sign in again</td><td>The old OAuth token is still valid. Revoke the app in <strong>AI/ML API → Authorized apps</strong>, then reconnect.</td></tr><tr><td>Connected, but inference fails with an insufficient-balance error</td><td>Top up at <a href="https://aimlapi.com/app/billing">https://aimlapi.com/app/billing</a>.</td></tr><tr><td>The client connects but never asks you to sign in</td><td>You likely added an <code>Authorization</code> header — with a header the client uses API-key auth, not OAuth. Remove the header to use OAuth.</td></tr><tr><td>"Sign-in failed" / authorization error</td><td>Confirm you're signing in to the correct AI/ML API account, then retry from the client.</td></tr></tbody></table>


# CLI

Connect Claude Code, Codex, OpenCode, Cline, OpenClaude, OpenClaw, Hermes Agent, zero or ZCode to AI/ML API with one command using the aimlapi CLI.

`aimlapi` is the AI/ML API command-line tool. It signs you in through the browser, creates an API key for you, and starts your coding agent already connected to AI/ML API:

```bash
npx aimlapi claude
```

You don't copy a key or edit config files by hand. Usage is billed to your AI/ML API account like any other API request.

## Supported agents

| Agent                         | Command              | Default model                                                                            | If the agent is missing                           |
| ----------------------------- | -------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------- |
| [Claude Code](#claude-code)   | `aimlapi claude`     | [`anthropic/claude-sonnet-5`](/api-references/text-models-llm/anthropic/claude-sonnet-5) | offers `npm install -g @anthropic-ai/claude-code` |
| [Codex](#codex)               | `aimlapi codex`      | [`openai/gpt-5.6-sol`](/api-references/text-models-llm/openai/gpt-5.6-sol)               | offers `npm install -g @openai/codex`             |
| [OpenCode](#opencode)         | `aimlapi opencode`   | [`anthropic/claude-sonnet-5`](/api-references/text-models-llm/anthropic/claude-sonnet-5) | offers `npm install -g opencode-ai`               |
| [Cline](#cline)               | `aimlapi cline`      | [`anthropic/claude-sonnet-5`](/api-references/text-models-llm/anthropic/claude-sonnet-5) | offers `npm install -g cline`                     |
| [OpenClaude](#openclaude)     | `aimlapi openclaude` | [`anthropic/claude-sonnet-5`](/api-references/text-models-llm/anthropic/claude-sonnet-5) | offers `npm install -g @gitlawb/openclaude`       |
| [OpenClaw](#openclaw)         | `aimlapi openclaw`   | [`anthropic/claude-sonnet-5`](/api-references/text-models-llm/anthropic/claude-sonnet-5) | offers `npm install -g openclaw@latest`           |
| [Hermes Agent](#hermes-agent) | `aimlapi hermes`     | [`anthropic/claude-sonnet-5`](/api-references/text-models-llm/anthropic/claude-sonnet-5) | prints the Hermes install command                 |
| [zero](#zero)                 | `aimlapi zero`       | [`anthropic/claude-sonnet-5`](/api-references/text-models-llm/anthropic/claude-sonnet-5) | offers `npm install -g @gitlawb/zero`             |
| [ZCode](#zcode)               | `aimlapi zcode`      | [`zhipu/glm-5.3`](/api-references/text-models-llm/zhipu/glm-5.3)                         | prints where to build it from source              |

Supported platforms: macOS, Linux and Windows, on x64 and arm64.

## Install

You need an **AI/ML API account** with a positive balance. You can top up at <https://aimlapi.com/app/billing>.

{% tabs %}
{% tab title="npx (no install)" %}
Needs Node.js 18+ and npm.

```bash
npx aimlapi <command>
```

{% endtab %}

{% tab title="npm (global)" %}
Needs Node.js 18+ and npm.

```bash
npm i -g aimlapi
aimlapi <command>
```

{% endtab %}

{% tab title="macOS / Linux (no Node)" %}

```bash
curl -fsSL https://aimlapi.com/install.sh | sh
```

Installs `aimlapi` into `~/.local/bin`. If that directory is not on your `PATH`, the script prints the line to add to your shell's rc file (it never edits rc files).
{% endtab %}

{% tab title="Windows (no Node)" %}
In PowerShell:

```powershell
irm https://aimlapi.com/install.ps1 | iex
```

Installs `aimlapi` into `%LOCALAPPDATA%\aimlapi\bin` and adds that directory to your user `PATH`. Open a new terminal afterwards.
{% endtab %}
{% endtabs %}

The command is called `aimlapi`, and the examples on this page use it. If you run the CLI through npx, use `npx aimlapi` in its place.

* **Install scripts.** They download the same binary that `npm i -g aimlapi` installs from the npm registry, check its sha512 and install it without `sudo`. Settings (environment variables): `AIMLAPI_INSTALL_DIR` (another directory), `AIMLAPI_VERSION` (a specific version, default `latest`), `AIMLAPI_NPM_REGISTRY`, and on Windows `AIMLAPI_INSTALL_NO_MODIFY_PATH=1` (don't touch `PATH`).
* **Alias.** The npm package `aimlapi-cli` is an alias of `aimlapi` with the same `aimlapi` command (`npx aimlapi-cli claude`, `npm i -g aimlapi-cli`). Install only one of the two globally.
* **Updates.** Once a day the CLI checks for a new release and prints a one-line notice (outside agent sessions it may also offer to update right away). `aimlapi update` updates it the way it was installed: with `npm i -g aimlapi@latest` (or `aimlapi-cli@latest`) for an npm install, or by downloading, verifying and replacing the binary for a script install. It only moves to a newer release. Through npx there is nothing to update; run `npx aimlapi@latest <command>` to get the newest version. To turn the check off, set `AIMLAPI_NO_UPDATE_CHECK=1`; it is also off when `CI=true`.

{% hint style="info" %}
For **Claude Code, Codex** and **Hermes Agent**, `--config` (see [Agent commands](#agent-commands)) saves the path of the `aimlapi` binary into the agent's config, so it needs an installed `aimlapi` (npm global or install script). A binary run through npx sits in a temporary cache that npm can delete at any time: under npx, `--config` for these agents stops with exit code `2` and asks you to run `npm i -g aimlapi` first.
{% endhint %}

## Quick start

{% stepper %}
{% step %}

### Start your agent

```bash
aimlapi claude
```

Other agents work the same way: `codex`, `opencode`, `cline`, `openclaude`, `openclaw`, `hermes`, `zero`, `zcode`.
{% endstep %}

{% step %}

### Install the agent (only if it's missing)

If the agent isn't installed, `aimlapi` shows the exact install command and asks, for example:

```
Claude Code is not installed. Install it now? npm install -g @anthropic-ai/claude-code [Y/n]
```

See [Missing agents](#missing-agents).
{% endstep %}

{% step %}

### Pick a model

In an interactive terminal, the CLI shows a model picker with the agent's default preselected. To skip it, pass `--model <id>`. Later runs reuse the model you picked last (the CLI tells you so); pass `--model` to choose another.
{% endstep %}

{% step %}

### Sign in (first run only)

If no key is stored yet, the CLI opens your browser. **Sign in to AI/ML API** and **approve the aimlapi CLI**. On that page you can also set an optional **USD limit** for the new key. The key is created and saved on your computer. The CLI also prints the link, in case the browser doesn't open.
{% endstep %}

{% step %}

### Work

The agent starts with AI/ML API as its provider. What the CLI writes, if anything, depends on the agent: see its section below.
{% endstep %}
{% endstepper %}

## Agent commands

Every agent takes the same flags:

```
aimlapi <agent> [--model <id>] [--config | --undo] [--dry-run] [--yes] [-- <agent arguments>]
```

| Flag                   | What it does                                                                                                                                                                                                                                                                      |
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| *(none)*               | Configures the agent for this run and starts it.                                                                                                                                                                                                                                  |
| `--model <id>`         | The model to use. Without it, the CLI reuses the model you picked last for this agent; the first time, you get a picker in an interactive terminal, otherwise (no terminal, or `CI=true`) the default model. An id that isn't a preset is checked against the [catalog](#models). |
| `--config`             | Saves the configuration into the agent's own config files and exits, so the agent uses AI/ML API when you start it directly.                                                                                                                                                      |
| `--undo`               | Reverts what the CLI wrote into the agent's config files and puts back the values it replaced. Works even when the agent is no longer installed.                                                                                                                                  |
| `--force`              | With `--undo`: restore files even if they were edited after the CLI wrote them.                                                                                                                                                                                                   |
| `--dry-run`            | Prints what would happen (environment variables, file diffs, the command line) with secrets masked, and changes nothing. Combine it with `--config` or `--undo` to preview them.                                                                                                  |
| `--yes`, `-y`          | Installs a missing agent with npm without asking.                                                                                                                                                                                                                                 |
| `-- <agent arguments>` | Everything after `--` is passed to the agent unchanged.                                                                                                                                                                                                                           |

**What the CLI changes and keeps safe:**

* The API key never appears on a command line. The agent gets it from a credential helper (`aimlapi key print`), from an environment variable of the agent process only, or from the agent's own config or credential store (mode `0600`), or, for OpenClaw, from aimlapi's credentials file.
* Before writing any agent file, the CLI copies the original to `~/.aimlapi/backups/<agent>/<timestamp>/`. A repeated run that changes nothing writes nothing.
* The CLI only changes the settings it owns. Other settings in the file stay as they are, and a value it replaces is restored by `--undo`.

### Missing agents

When the agent isn't installed, `aimlapi` offers to install its official npm package and prints the exact command first. Press Enter (or type `y`) to install; the run then goes on with the model picker and the launch.

* It asks only in an interactive terminal (and not when `CI` is set). `--yes` installs without asking, also in CI.
* Without a terminal, with `CI` set, with `--dry-run`, or when you decline, it only prints the command and exits with code `4`.
* npm runs in your environment without the CLI's variables (no API key) and never with `sudo`. On an `EACCES` error, the CLI suggests a user-writable npm prefix. If npm's global `bin` directory is not on your `PATH`, it names that directory.
* **Hermes Agent** (installed by its own script) and **ZCode** (the `zcode` command is built from source) are not installed automatically: the CLI prints how to install them. Node.js isn't installed either.

### Model presets

The picker offers the agent's presets first:

* Anthropic: `anthropic/claude-sonnet-5`, `anthropic/claude-opus-5`, `anthropic/claude-opus-5.5`, `anthropic/claude-haiku-4.5`, for every agent except Codex and ZCode.
* OpenAI: `openai/gpt-5.6-sol`, `openai/gpt-5.6-terra`, `openai/gpt-6-astra`, for Codex, OpenCode, Cline, OpenClaw, Hermes Agent and zero.
* GLM: `zhipu/glm-5.3`, `z-ai/glm-5.3-flash`, `zhipu/glm-5.2`, `zhipu/glm-5.1`, `z-ai/glm-5-turbo`, for ZCode.

You can pass any other model from `aimlapi models --agent <agent>` with `--model`.

### Claude Code

```bash
aimlapi claude
aimlapi claude --model opus
aimlapi claude -- -p "Explain the architecture of this project"
```

**Launch.** Runs `claude --settings '<json>' --model <model>`. The inline settings contain an `env` block (base URL `https://api.aimlapi.com`, the model slots, tracking headers) and `apiKeyHelper`, which Claude Code runs to get the key from `aimlapi key print`. Settings on the command line take priority over your settings files, so no file is written. `ANTHROPIC_API_KEY` and `ANTHROPIC_AUTH_TOKEN` are set to empty, so an Anthropic key exported in your shell is never sent to AI/ML API.

**Model slots.** `--model` also accepts the Claude Code tier aliases:

| Claude Code slot / alias | AI/ML API model              |
| ------------------------ | ---------------------------- |
| `opus`                   | `anthropic/claude-opus-5.5`  |
| `sonnet`                 | `anthropic/claude-sonnet-5`  |
| `haiku`                  | `anthropic/claude-haiku-4.5` |
| subagents                | `anthropic/claude-sonnet-5`  |

**`--config`.** Merges the same `env` keys and `apiKeyHelper` into `~/.claude/settings.json` (or `$CLAUDE_CONFIG_DIR/settings.json`). Needs an installed `aimlapi`, not npx.

{% hint style="warning" %}
After `aimlapi claude --config`, **every** Claude Code session goes through AI/ML API and is billed to your AI/ML API account, including a plain `claude` started from any terminal, until you run `aimlapi claude --undo`.
{% endhint %}

### Codex

```bash
aimlapi codex
aimlapi codex --model openai/gpt-5.6-terra
aimlapi codex -- exec "explain this repo"
```

**Launch.** Runs `codex` with `-c` overrides that add the model provider `aimlapi-cli` (Responses API at `https://api.aimlapi.com/v1`, tracking headers). Codex gets the key by running `aimlapi key print`. No file is written.

**`--config`.** Writes a separate profile, `~/.codex/aimlapi.config.toml` (or `$CODEX_HOME/aimlapi.config.toml`), without the key. Your `config.toml` is never modified, and a plain `codex` works as before. Start Codex with the profile:

```bash
aimlapi codex --config
codex --profile aimlapi
```

**`--undo`** deletes the profile, or puts back a profile of yours that `--config` replaced.

{% hint style="info" %}
Codex **0.118.0** or newer gets the key from `aimlapi key print`; with an older Codex, the key is passed in `AIMLAPI_API_KEY` of the Codex process only, and the CLI prints a notice. `--config` needs Codex **0.131.0** or newer. To update Codex, run `npm install -g @openai/codex@latest`.
{% endhint %}

### OpenCode

```bash
aimlapi opencode
aimlapi opencode --model openai/gpt-5.6-sol
aimlapi opencode -- run "explain this repo"
```

**Launch.** Runs `opencode` with an inline config in `OPENCODE_CONFIG_CONTENT` (provider `aimlapi-cli`, shown as **AIMLAPI**, OpenAI-compatible at `https://api.aimlapi.com/v1`, the preset models) and the key in `AIMLAPI_API_KEY` of the OpenCode process only. No file is written. Models appear as `aimlapi-cli/<model id>`, for example `aimlapi-cli/anthropic/claude-sonnet-5`.

**`--config`.** Adds the provider (without the key) to OpenCode's global config (`~/.config/opencode/opencode.json`, or `opencode.jsonc`, or `$OPENCODE_CONFIG`) and stores the key in OpenCode's credential store `auth.json` (mode `0600`). It sets the default `model` only if you have none; otherwise pick an `aimlapi-cli/…` model with `/models`. After `--config`, a launch keeps the stored key current.

### Cline

```bash
aimlapi cline
aimlapi cline --model openai/gpt-5.6-sol
aimlapi cline -- "explain this repo"
```

**Every run** writes Cline's provider store `~/.cline/data/settings/providers.json` (mode `0600`), because Cline has no flag for a base URL: the built-in **OpenAI Compatible** provider gets `https://api.aimlapi.com/v1`, the key, the model and tracking headers, and becomes Cline's default. A launch then runs `cline -P openai-compatible -m <model>`; `--config` stops after the write.

{% hint style="warning" %}
The Cline CLI, the Cline VS Code extension and the JetBrains plugin share this provider store. After any `aimlapi cline` run, all of them use AI/ML API by default until you run `aimlapi cline --undo`. Cline keeps only **one** OpenAI Compatible provider: if you had one for another endpoint, the CLI replaces it and `--undo` puts it back. If the VS Code extension is open, reload the window (Command Palette → **Developer: Reload Window**).
{% endhint %}

`aimlapi cline` needs the `cline` command even if you only use the VS Code extension. It finds the provider store the way Cline does (`CLINE_PROVIDER_SETTINGS_PATH`, `CLINE_DATA_DIR`, `CLINE_DIR`, and `--config <dir>` / `--data-dir <dir>` after `--`); run `--undo` with the same settings.

### OpenClaude

```bash
aimlapi openclaude
aimlapi openclaude --model opus
```

**Launch.** Connects [OpenClaude](/integrations/openclaude) over AI/ML API's Anthropic-compatible route (`/v1/messages`): the base URL, model slots (the same as for [Claude Code](#claude-code)) and tracking headers are set in its environment, and the key in `ANTHROPIC_AUTH_TOKEN` of the OpenClaude process only. No file is written. OpenClaude's built-in `aimlapi.com` preset is not used, and `AIMLAPI_API_KEY` is removed from the session.

**`--config`.** Writes the same variables, with the key, into the `env` of `~/.openclaude/settings.json` (or `$OPENCLAUDE_CONFIG_DIR/settings.json`, mode `0600`); after `--config`, a launch keeps the stored key current. Picking another provider with `/provider` later removes only part of these settings; to remove them, run `aimlapi openclaude --undo`.

### OpenClaw

```bash
aimlapi openclaw
aimlapi openclaw --config
```

[OpenClaw](/integrations/openclaw) has no per-run provider switch, so **every run** writes its config (`~/.openclaw/openclaw.json`, or the file `$OPENCLAW_CONFIG_PATH`, `$OPENCLAW_STATE_DIR` or a `--profile <name>` after `--` selects): the OpenAI-compatible provider `aimlapi-cli` with the preset models, and the default model `aimlapi-cli/<model>`. A launch then starts `openclaw`; `--config` only writes. A running Gateway reloads the config by itself.

The key is not copied into `openclaw.json`: OpenClaw reads it from the CLI's credentials file. So sign in with `aimlapi login` first (`AIMLAPI_API_KEY` alone is not enough, exit code `3`), and run `openclaw secrets reload` after you log in with a new key or log out.

### Hermes Agent

```bash
aimlapi hermes
aimlapi hermes --config
```

[Hermes Agent](/integrations/hermes) is installed with its own script, not npm (`curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash`; the CLI prints the Windows command). Hermes has no per-run provider switch, so the CLI adds named custom providers (OpenAI-compatible, the preset models) to Hermes' `config.yaml` (`~/.hermes`, `$HERMES_HOME`, or the active Hermes profile). The key is not copied: Hermes runs `aimlapi key print` to get it.

* **Launch** writes the entry `aimlapi-cli-run` and starts `hermes --provider custom:aimlapi-cli-run -m <model>`, so a plain `hermes` keeps its default.
* **`--config`** writes the entry `aimlapi-cli` and makes it Hermes' default model. Needs an installed `aimlapi`, not npx. A running Hermes gateway needs `hermes gateway restart`.
* **`--undo`** removes both entries and puts back the `model:` keys they replaced. Only those lines of `config.yaml` change.

### zero

```bash
aimlapi zero
aimlapi zero --config
```

[zero](/integrations/zero) has no flag for a provider, so **every run** writes the OpenAI-compatible provider profile `aimlapi-cli` into zero's config (`~/.config/zero/config.json`, or `$XDG_CONFIG_HOME/zero/config.json`; on Windows `%AppData%\zero\config.json`). zero's built-in `aimlapi` preset is not used. The profile reads the key from `AIMLAPI_CLI_KEY`, so no key is written: a launch sets it for the zero process only. `--config` also makes the profile zero's default provider.

{% hint style="warning" %}
After `aimlapi zero --config`, `aimlapi zero` works as is, but a **plain `zero`** needs `AIMLAPI_CLI_KEY` in your shell. With an installed `aimlapi` (not npx), add this line to your shell profile:

```bash
export AIMLAPI_CLI_KEY="$(aimlapi key print)"
```

Without it, zero silently uses another provider it has a key for. Don't export `AIMLAPI_API_KEY` for this: it overrides the key saved by `aimlapi login` for every `aimlapi` command.
{% endhint %}

### ZCode

```bash
aimlapi zcode
aimlapi zcode --config
```

[ZCode](/integrations/zcode) is Z.ai's coding agent for GLM models. `aimlapi zcode` needs ZCode's terminal command `zcode`, which Z.ai does not publish as a package: [build it from source](https://github.com/zai-org/ZCode/blob/main/README.en.md#zcode-cli-distribution). The CLI adds the OpenAI-compatible provider `aimlapi-cli` (shown as **AI/ML API**) with the GLM presets; ZCode keeps the key in its provider config (mode `0600`).

* **Launch** gives `zcode` a provider config of the CLI's own (`$ZCODE_PERSONAL_PROVIDER_CONFIG_FILE`), so your `~/.zcode` is not changed. A provider you add inside such a session is saved into that file and is gone after `--undo` or `logout`: add your own providers in a plain `zcode` session or the desktop app. `zcode --web` can't be started this way; use `--config`.
* **`--config`** adds the provider to `~/.zcode/v2/provider_config.json` (or `$ZCODE_DATA_BASE_DIR/.zcode/v2`), shared by the ZCode desktop app, `zcode` and `zcode --web`, and makes its model the default. If the desktop app keeps its data in another folder, that copy is set up too. A running ZCode picks up the change by itself.

## Account commands

### `login`

```bash
aimlapi login
aimlapi login --device
```

`login` opens the browser, where you sign in and approve the aimlapi CLI. On the approval page you can set an optional **USD limit** for the new key and how often it resets. The key is saved to `~/.aimlapi/credentials` (file mode `0600`; on Windows `%APPDATA%\aimlapi\credentials`). You don't have to run `login` first: in an interactive terminal, agent commands start the same sign-in when no key is stored.

The **device code** flow (`--device`) prints a link that you open and approve on any device. The CLI picks it automatically over SSH, on Linux without a graphical display, and when it can't open a browser or a local port.

If you log in again, the stored key is replaced, but the previous key stays active. You can revoke it on the [API Keys page](https://aimlapi.com/app/keys).

### `logout`

```bash
aimlapi logout
```

Revokes the stored key on the server and removes it from your computer. Agent configs that hold a copy of that key (OpenCode, Cline, OpenClaude, ZCode) are reverted as `aimlapi <agent> --undo` would, and the agent config backups are deleted. If the server refuses or can't be reached, the key is still removed locally but may remain active: revoke it on the [API Keys page](https://aimlapi.com/app/keys). `logout` doesn't change `AIMLAPI_API_KEY`.

### `status`

```bash
aimlapi status
aimlapi status --json
```

Shows your account balance and the spend and limit of the API key in use. The key itself is only shown masked.

### `models`

```bash
aimlapi models
aimlapi models --agent claude
aimlapi models --agent codex --json
```

Lists AI/ML API chat models from the public catalog. No login is needed.

* Without `--agent`, you get every chat model and the agents that can use it.
* With `--agent <agent>`, you get only the models that agent can use: served on the agent's API and supporting tool calling. The agent's presets come first, with the default model and the model slots marked.
* With `--json`, the output is machine-readable.

### `update`

```bash
aimlapi update
aimlapi --version
```

Updates `aimlapi` to the latest version, through npm or, for a script install, by replacing the binary (see [Install](#install)).

## Set up from your agent

You can also let your coding agent set itself up. Paste this into any of the supported agents:

```
Read https://docs.aimlapi.com/quickstart/cli/aimlapi-setup.md and follow it to connect this agent to AI/ML API.
```

The agent signs you in through the browser (you approve; you never paste a key into the chat), shows what it will change with `--dry-run`, applies it after you confirm, and tells you how to undo it.

To install it as a Claude Code skill instead (then just ask Claude Code to "set up AI/ML API"), download the file with its frontmatter:

```bash
mkdir -p ~/.claude/skills/aimlapi-setup
curl -fsSL https://raw.githubusercontent.com/aimlapi/api-docs/main/skills/aimlapi-setup/SKILL.md -o ~/.claude/skills/aimlapi-setup/SKILL.md
```

## Troubleshooting

<details>

<summary>Headless server, SSH session or CI</summary>

Over SSH, the CLI uses the device code flow automatically. You can also force it with `aimlapi login --device`, then open the printed link on any device.

In a non-interactive session (no terminal, or `CI=true`), agent commands don't start a sign-in, don't show the model picker and don't ask to install a missing agent (pass `--yes` for that). Log in beforehand with `aimlapi login`, or provide a key through the environment:

```bash
export AIMLAPI_API_KEY=<YOUR_AIMLAPI_KEY>
```

Without a key, the command exits with code `3`. OpenClaw needs `aimlapi login`; the variable alone is not enough for it.

</details>

<details>

<summary>"… is not installed"</summary>

The agent isn't on your `PATH`. In a terminal the CLI offers to install it (see [Missing agents](#missing-agents)); otherwise it prints the install command and exits with code `4`. For Cline, the `cline` command is needed even if you use the VS Code extension; for ZCode, the `zcode` command, not only the desktop app.

</details>

<details>

<summary>"--config … runs from a temporary package-runner cache (npx)"</summary>

`--config` for Claude Code, Codex or Hermes Agent was run through npx. Install `aimlapi` (`npm i -g aimlapi` or an [install script](#install)) and run `aimlapi <agent> --config` again.

</details>

<details>

<summary>A different key than expected is used</summary>

`AIMLAPI_API_KEY` in your environment overrides the key saved by `aimlapi login` for every command. Unset it to use the saved key. Run `aimlapi status` to see which key is in use (masked).

</details>

<details>

<summary>Corporate proxy</summary>

The CLI's own requests (login, `models`, `status`, updates) respect the standard proxy variables:

```bash
export HTTPS_PROXY=http://proxy.example.com:8080
export NO_PROXY=localhost,127.0.0.1
```

Agents started by `aimlapi` inherit your environment; check your agent's documentation for its own proxy support. The browser sign-in returns to a local address (`127.0.0.1`). If your browser can't reach it, use `aimlapi login --device`.

</details>

<details>

<summary>Restoring an agent's configuration</summary>

To revert what the CLI wrote into an agent's config, preview it first:

```bash
aimlapi claude --undo --dry-run
```

Then restore it:

```bash
aimlapi claude --undo
```

Every other agent works the same way. A file in which you have since replaced the CLI's settings by hand is left as it is (`--force` restores it anyway).

The CLI also copies the original of every file before it changes it, to `~/.aimlapi/backups/<agent>/<timestamp>/` (Windows: `%APPDATA%\aimlapi\backups\<agent>\<timestamp>\`). Each backup has a `manifest.json` and the original files under `files/`. Backups can contain credentials that were in the original files, so treat them as secrets.

To remove the CLI itself, run `--undo` for every configured agent first (Claude Code, Codex and Hermes Agent configs point at the `aimlapi` binary), then `npm uninstall -g aimlapi`, or delete the binary if you used an install script.

</details>

<details>

<summary>Windows</summary>

The CLI keeps its files in `%APPDATA%\aimlapi` and runs the agent as a child process, forwarding Ctrl+C and the agent's exit code. The examples on this page use POSIX shell syntax; in PowerShell set variables with `$env:NAME = "value"`. OpenClaw refuses a credentials file whose permissions it can't verify as private, which is likely if you point `AIMLAPI_CONFIG_DIR` at a shared folder.

</details>

### Exit codes

| Code | Meaning                                                                                   |
| ---- | ----------------------------------------------------------------------------------------- |
| `0`  | Success.                                                                                  |
| `1`  | General error (network, file, server, agent too old).                                     |
| `2`  | Invalid arguments, flags or environment values (for example, `--config` run through npx). |
| `3`  | Authentication: not logged in, the key is invalid or rejected, or the sign-in was denied. |
| `4`  | The coding agent is not installed, or its installation failed.                            |

When the agent starts, its own exit code is returned when it finishes.

### Environment variables

| Variable                                 | Effect                                                                                     |
| ---------------------------------------- | ------------------------------------------------------------------------------------------ |
| `AIMLAPI_API_KEY`                        | API key to use instead of the one saved by `aimlapi login`, for every command.             |
| `AIMLAPI_CONFIG_DIR`                     | Directory for credentials and backups (default `~/.aimlapi`; Windows `%APPDATA%\aimlapi`). |
| `AIMLAPI_BASE_URL`                       | Overrides the API host (default `https://api.aimlapi.com`).                                |
| `AIMLAPI_NO_UPDATE_CHECK`                | Set to `1` to turn off the daily new-version check.                                        |
| `AIMLAPI_CLI_KEY`                        | The key variable of zero's `aimlapi-cli` profile (see [zero](#zero)).                      |
| `CI`                                     | When `true`: no model picker, no inline sign-in, no install prompt, no update check.       |
| `HTTPS_PROXY`, `NO_PROXY`                | Proxy for the CLI's own requests.                                                          |
| `AIMLAPI_INSTALL_DIR`, `AIMLAPI_VERSION` | Install scripts only: target directory and version (see [Install](#install)).              |


# Agent setup skill

Instructions for a coding agent (Claude Code, Codex, OpenCode, Cline, OpenClaude, OpenClaw, Hermes Agent, zero or ZCode) to install the aimlapi CLI and connect itself to AI/ML API.

You are a coding agent. The user wants you (or another agent on this machine) to use [AI/ML API](https://aimlapi.com) models. The `aimlapi` CLI (npm package `aimlapi`) does the work: it signs the user in, stores an API key on this machine, and edits the agent's own config files. Your job is to run it in the right order, show the user what will change, and never handle the API key yourself.

These instructions work for any agent that can run shell commands. Where a step says "ask the user", stop and wait for an answer.

## Rules (read first)

* [ ] **Never ask the user for an API key and never accept one in the chat.** Sign-in is `aimlapi login`: the user approves in the browser and the CLI stores the key itself. If the user pastes a key anyway, do not repeat it, do not store it, do not pass it to any command; tell them it is now in the chat transcript and suggest revoking it at <https://aimlapi.com/app/keys>.
* [ ] **Never print, read or copy the key.** Do not run `aimlapi key print`. Do not open or `cat` the credentials file (`~/.aimlapi/credentials`, on Windows `%APPDATA%\aimlapi\credentials`) or the agent files that hold the key after setup (OpenCode `auth.json`, Cline `providers.json`, OpenClaude `settings.json`, ZCode `provider_config.json`). Do not dump the environment (`env`, `printenv`, `set`) — `AIMLAPI_API_KEY` may be in it. Use only the CLI's own output, which never shows the whole key (only a masked form or a short prefix).
* [ ] **Never put a key on a command line** (no `--apikey …`, no `AIMLAPI_API_KEY=… aimlapi …`, no `export AIMLAPI_API_KEY=…`).
* [ ] **Confirm before changing config.** Always run `--dry-run` first, show the user what will change, and wait for a clear yes. Never re-run `--config` on your own to "fix" something a later check reports — ask the user first.
* [ ] **Always pass `--model <id>` to every `--config` command** (dry run, apply and verify), with the same id each time. Without it, in a terminal the CLI opens an interactive model picker that you cannot answer and the command hangs; otherwise it takes the model remembered from an earlier run (or the default), which may not be the one the user confirmed.
* [ ] **Never run `aimlapi <agent>` without `--config`, `--dry-run` or `--undo`.** Plain `aimlapi claude` (etc.) *launches* an interactive agent session, which would hang your shell tool.
* [ ] Run every `aimlapi` command with `AIMLAPI_NO_UPDATE_CHECK=1` (as in the examples) so a new-version notice cannot interrupt setup. The examples use POSIX shell syntax. In PowerShell set the variable in the same command line (your shell tool may start a new shell per command) and replace a trailing `</dev/null` with a leading `$null |`, e.g. `$env:AIMLAPI_NO_UPDATE_CHECK=1; $null | aimlapi <agent> --config --model <id>`. Keep stdin closed like this: without a stored key, `--config` then exits `3` instead of starting an interactive login you cannot answer.
* [ ] Do not use `sudo`, change system settings, or install other software (Node.js, the agent itself) without asking the user. Once the user has agreed to install a missing agent, pass `--yes` so that aimlapi installs it (step 6, exit `4`).
* [ ] Do not commit or share the files this changes. If the user keeps their home directory or dotfiles in git, warn them before applying.
* [ ] If your sandbox blocks network access or writes outside the workspace, ask the user to approve the command through your normal permission mechanism, or to run it in their own terminal. Do not work around the sandbox.

## Exit codes

Every `aimlapi` command exits with one of these. Branch on the code, and show the user the command's stderr when it is not 0.

| Code | Meaning                                              | What to do                                                 |
| ---- | ---------------------------------------------------- | ---------------------------------------------------------- |
| `0`  | success                                              | continue                                                   |
| `1`  | general error (network, file, server, agent too old) | show the error, stop, ask the user                         |
| `2`  | usage error, or `--config` run from `npx`            | fix the command; for `--config` see step 5                 |
| `3`  | not signed in, or the server rejected the key        | run step 4 (login)                                         |
| `4`  | the agent is not installed (or its install failed)   | show the printed install command, ask the user; see step 6 |

## Workflow

* [ ] 1\. Pick the agent
* [ ] 2\. Check Node.js
* [ ] 3\. Check sign-in
* [ ] 4\. Sign in (only if step 3 exits 3)
* [ ] 5\. Install the CLI globally (or offer to update it)
* [ ] 6\. Choose the model and preview the change (`--dry-run`)
* [ ] 7\. Apply it (`--config`) after the user confirms
* [ ] 8\. Verify and tell the user how to restart

### 1. Pick the agent

The agent ids are `claude` (Claude Code), `codex` (Codex), `opencode` (OpenCode), `cline` (Cline), `openclaude` (OpenClaude), `zcode` (ZCode, Z.ai's agent for GLM models) and `hermes` (Hermes Agent); `openclaw` (OpenClaw) and `zero` (zero by Gitlawb) are configured only when the user names them. If the user named an agent, use it. Otherwise configure the agent you are running in: you normally know it from your own instructions. These environment variables confirm it (check only these names; do not print the whole environment):

```sh
env | grep -E '^(CLAUDECODE|CODEX_THREAD_ID|CODEX_SANDBOX|OPENCODE|HERMES_AGENT)='
```

```powershell
Get-ChildItem Env: | Where-Object Name -in 'CLAUDECODE','CODEX_THREAD_ID','CODEX_SANDBOX','OPENCODE','HERMES_AGENT' | Select-Object Name, Value
```

| Variable present                                                   | Agent id     |
| ------------------------------------------------------------------ | ------------ |
| `CLAUDECODE=1`                                                     | `claude`     |
| `CLAUDECODE=1`, and you are OpenClaude (it sets the same variable) | `openclaude` |
| `CODEX_THREAD_ID` or `CODEX_SANDBOX`                               | `codex`      |
| `OPENCODE=1`                                                       | `opencode`   |
| `HERMES_AGENT=true`                                                | `hermes`     |
| none of these, and you are Cline                                   | `cline`      |
| none of these, and you are ZCode                                   | `zcode`      |

If you are not sure, ask the user which agent to configure. Tell the user which one you picked before going on.

### 2. Check Node.js

```sh
node --version
npm --version
```

Node.js 18 or newer is required. If `node` or `npm` is missing or older, stop and ask the user to install the current LTS from <https://nodejs.org> (do not install it yourself without permission).

### 3. Check sign-in

First check, without printing its value, whether an API key is set in the environment:

```sh
[ -n "$AIMLAPI_API_KEY" ] && echo set || echo unset
```

```powershell
if ($env:AIMLAPI_API_KEY) { 'set' } else { 'unset' }
```

If it is `set`, tell the user: `AIMLAPI_API_KEY` overrides the key stored by `aimlapi login` for every `aimlapi` command, and for `opencode`, `cline`, `openclaude` and `zcode`, `--config` writes **that** key into the agent's config files. Ask whether to continue with it or have them unset it in their own shell profile first.

Then:

```sh
AIMLAPI_NO_UPDATE_CHECK=1 npx -y aimlapi@latest status
```

* Exit `0`: the user is signed in. The output shows the environment, the masked key and the balance. Go to step 5.
* Exit `3`: not signed in, or the stored key was rejected (revoked). Go to step 4.
* Anything else: show the error and stop.

If the balance is zero or "low balance" is shown, tell the user that requests will fail until they top up in the dashboard (<https://aimlapi.com/app>); setup can still continue.

### 4. Sign in

Tell the user: "A browser window will open. Sign in to AI/ML API and approve the aimlapi CLI. The CLI stores the API key on this computer; I never see it." Then run:

```sh
AIMLAPI_NO_UPDATE_CHECK=1 npx -y aimlapi@latest login
```

* The command waits until the user approves (up to 10 minutes). Run it with a long timeout, or in the background and poll its output. It prints progress and any link on **stderr** — relay every link or code it prints to the user exactly as printed.
* Over SSH, on Linux without a display, or when no browser can be opened, the CLI switches to a **device code**: it prints a link the user opens on any device. To force this flow, add `--device`. If your shell tool shows output only after the command ends, run it in the background so you can show the user the link while it waits.
* If you cannot keep a command running that long, ask the user to run the same command in their own terminal (in Claude Code they can type `! AIMLAPI_NO_UPDATE_CHECK=1 npx -y aimlapi@latest login` in the prompt), then continue.
* Exit `3` here means the request was denied, expired or timed out: show the message and ask whether to try again.

When it succeeds it prints `Logged in to AI/ML API. API key <prefix>… saved to …` (only a short prefix of the key). Run the `status` command from step 3 again and expect exit `0`.

### 5. Install the CLI globally (or update it)

`--config` writes settings that stay after this session. For Claude Code and Codex they include the absolute path of the `aimlapi` binary (the agent runs `aimlapi key print` to get the key). A binary started by `npx` lives in a temporary cache that can be deleted, so the CLI refuses `--config` for Claude Code, Codex and Hermes Agent from `npx` with exit `2` (OpenCode, Cline, OpenClaude and ZCode store no binary path, but a global install is still the way to keep using `aimlapi`). First check whether it is installed already:

```sh
aimlapi --version
```

If it prints a version, the `aimlapi` command is installed already — from the npm package `aimlapi` or from its alias `aimlapi-cli`, which installs the same `aimlapi` command. Keep it: skip the install. Do not install the other package next to it and do not uninstall anything.

An installed `aimlapi` may be older than the one these steps describe. Look up the latest version:

```sh
npx -y aimlapi@latest --version
```

Both commands print `aimlapi <version> (commit …, built …)`. Compare the two versions (`X.Y.Z`, compared number by number). If the installed one is older, tell the user both versions and ask whether to update it. Run the update only if the user agrees:

```sh
AIMLAPI_NO_UPDATE_CHECK=1 aimlapi update
aimlapi --version
```

`aimlapi update` reinstalls the same package it came from (`aimlapi` or `aimlapi-cli`) with npm. If it fails with `EACCES`, handle it as in the install below (no `sudo` on your own). If the user declines, if the installed version is not `X.Y.Z` (e.g. `dev`, a local build), or if the latest version cannot be looked up (offline), keep the installed one. Then go to step 6.

Only if `aimlapi` is not found, install it:

```sh
npm install -g aimlapi
aimlapi --version
```

* If npm fails with `EEXIST` (a file `aimlapi` already exists, usually from `aimlapi-cli`), an `aimlapi` is installed already: keep the existing install and continue. Do not retry with `--force`. If `aimlapi --version` still cannot find it, see the `PATH` item below.
* If npm fails with `EACCES` (permission denied), do **not** retry with `sudo` on your own. Explain the error and ask the user whether they want to run `sudo npm install -g aimlapi` themselves or fix their npm prefix (<https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally>).
* If `aimlapi` is not found after install, the npm global `bin` directory is not on `PATH`: show the user `npm prefix -g` and ask them to add its `bin` (Windows: the prefix itself) to `PATH`, then open a new shell.

The sign-in from step 4 is shared: the global `aimlapi` uses the same stored key. From now on use `aimlapi …`, not `npx`.

### 6. Choose the model and preview the change

List the models this agent can use (no sign-in needed):

```sh
AIMLAPI_NO_UPDATE_CHECK=1 aimlapi models --agent <agent>
```

The row whose `PRESET` column says `default` is the recommended model (with `--json`: `"default": true`). Offer it to the user and use another id from the list only if they ask for one. Write the chosen id down: steps 6, 7 and 8 must all pass exactly this `--model <id>`.

If no row says `default`:

* Exit `0`, and stderr has `note: preset <id> (the default) is not listed …`: the catalog does not list the recommended model for this agent right now. Tell the user, and offer that `<id>` (it may not work until the catalog lists it again) or a model from the list; use what they choose.
* Exit `1` (the catalog could not be loaded): show the error, then ask the user for the model id to use (<https://aimlapi.com/models> lists them) or whether to try again later. Do not guess an id.

```sh
AIMLAPI_NO_UPDATE_CHECK=1 aimlapi <agent> --config --dry-run --model <id> </dev/null
```

The dry run changes nothing. It prints the files it would create or edit, with a diff (secrets masked), and notes. Summarize it for the user: which files change, what is added, what is replaced, and the notes. Show the full output if they ask. What each agent gets:

| Agent        | Agent files changed by `--config`                                                                                                                                                                                                                                                                                   | Key storage                                                                                                     |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `claude`     | `~/.claude/settings.json` (or `$CLAUDE_CONFIG_DIR/settings.json`): `env` (base URL, models, headers) and `apiKeyHelper`                                                                                                                                                                                             | none in the file: Claude Code runs `aimlapi key print`                                                          |
| `codex`      | new profile `~/.codex/aimlapi.config.toml` (or `$CODEX_HOME`); `config.toml` is **not** touched                                                                                                                                                                                                                     | none in the file: Codex runs `aimlapi key print`                                                                |
| `opencode`   | provider `aimlapi-cli` in OpenCode's global `opencode.json`; sets `model` only if the user has none                                                                                                                                                                                                                 | OpenCode's `auth.json` (mode 0600)                                                                              |
| `cline`      | provider `openai-compatible` in `~/.cline/data/settings/providers.json`, made the default (shared by the Cline CLI, VS Code and JetBrains)                                                                                                                                                                          | in `providers.json` (Cline's own store)                                                                         |
| `openclaude` | `env` of `~/.openclaude/settings.json` (or `$OPENCLAUDE_CONFIG_DIR/settings.json`): base URL, models, headers                                                                                                                                                                                                       | `ANTHROPIC_AUTH_TOKEN` in that `settings.json` (mode 0600)                                                      |
| `openclaw`   | provider `aimlapi-cli`, secret provider `aimlapi-cli` and `agents.defaults.model` in `~/.openclaw/openclaw.json`                                                                                                                                                                                                    | none in the file: OpenClaw reads aimlapi's credentials file (needs `aimlapi login`, not only `AIMLAPI_API_KEY`) |
| `zero`       | profile `aimlapi-cli` (`aimlapi-cli-dev` for `--env dev`) in `~/.config/zero/config.json` (or `$XDG_CONFIG_HOME/zero/config.json`), made the default provider                                                                                                                                                       | none in the file: zero reads `$AIMLAPI_CLI_KEY` (`$AIMLAPI_CLI_DEV_KEY` for dev), never `AIMLAPI_API_KEY`       |
| `zcode`      | provider `aimlapi-cli` (shown as "AI/ML API") in `~/.zcode/v2/provider_config.json` (or `$ZCODE_DATA_BASE_DIR/.zcode/v2`), its model made ZCode's default; shared by the ZCode desktop app, `zcode` and `zcode --web`                                                                                               | in `provider_config.json` (ZCode's own store, mode 0600)                                                        |
| `hermes`     | provider `aimlapi-cli` under `providers:` in `~/.hermes/config.yaml` (or `$HERMES_HOME`, or the active Hermes profile), and `model.default` / `model.provider` pointed at it (`model.base_url` and similar keys removed); a plain `aimlapi hermes` run adds its own entry `aimlapi-cli-run` and never changes these | none in the file: Hermes runs `aimlapi key print` (`key_cmd`)                                                   |

For every agent the dry run also shows a `create` of `~/.aimlapi/agents/<agent>/previous/<hash>.json`: aimlapi's own record of the values (for Codex: the profile file) it replaces, which `--undo` uses to restore them. Every file the CLI changes is backed up first, under `~/.aimlapi/backups/<agent>/<timestamp>/`.

Codex older than 0.131 cannot load profile files: the dry run already fails with exit `1` and asks to update Codex (`npm install -g @openai/codex@latest`). Tell the user; update only if they agree.

Exit `4`: the agent is not installed, so there is nothing to preview yet. stderr names the install command. If it is `npm install -g <package>` (every agent except `hermes` and `zcode`), describe the change from the table above and ask one question: " is not installed. Install it with `npm install -g <package>` and apply this setup?" On a clear yes, run the step 7 command with `--yes` instead of step 7:

```sh
AIMLAPI_NO_UPDATE_CHECK=1 aimlapi <agent> --config --yes --model <id> </dev/null
```

aimlapi runs exactly that npm command (never with `sudo`), shows npm's output, and then applies the config; go on with step 8, whose dry run shows the result. If it still exits `4`, relay its message (an `EACCES` fix for npm's global directory, or the npm `bin` directory to add to `PATH`) and stop. `--yes` does nothing with `--dry-run`, and nothing for `hermes` (install script) or `zcode` (built from source): show their command and let the user install them.

Then ask: "Apply these changes?" Continue only on a clear yes.

### 7. Apply

Run the same command without `--dry-run`, with the same `--model <id>`:

```sh
AIMLAPI_NO_UPDATE_CHECK=1 aimlapi <agent> --config --model <id> </dev/null
```

It prints `Updated N file(s); backup: <dir>`, the files, and `Note:` lines. Relay the notes and the backup directory to the user.

* Exit `3`: there are no stored credentials (`--config` only checks that a key exists; it does not contact the server). Go back to step 4.
* Exit `4`: the agent is not installed. Show the printed install command and ask the user; with their yes, run the command again with `--yes` (step 6).

### 8. Verify and restart

```sh
AIMLAPI_NO_UPDATE_CHECK=1 aimlapi status
AIMLAPI_NO_UPDATE_CHECK=1 aimlapi <agent> --config --dry-run --model <id> </dev/null
```

Use the same `--model <id>` as in step 7. `status` must exit `0`. The dry run must list every file as `unchanged` — the config is in place. If it shows changes instead, do **not** run `--config` again: show the user the output and ask what to do (the agent or the user may have edited the file since).

Then tell the user how to pick it up:

| Agent        | How to start using AI/ML API                                                                                                                                                                                                                                                                                                                                                  | Extra check                                                                                                                                                                                                              |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `claude`     | Quit Claude Code and start it again; every new session uses AI/ML API.                                                                                                                                                                                                                                                                                                        | In the new session, `/status` shows the AI/ML API base URL.                                                                                                                                                              |
| `codex`      | Start Codex with the profile: `codex --profile aimlapi`. Plain `codex` keeps the previous provider.                                                                                                                                                                                                                                                                           | —                                                                                                                                                                                                                        |
| `opencode`   | Restart OpenCode. If the user already had a default model, pick an `aimlapi-cli/…` model with `/models`.                                                                                                                                                                                                                                                                      | `opencode models aimlapi-cli` lists AI/ML API models.                                                                                                                                                                    |
| `cline`      | The Cline CLI uses it on the next run. In VS Code: Command Palette → "Developer: Reload Window".                                                                                                                                                                                                                                                                              | —                                                                                                                                                                                                                        |
| `openclaude` | Quit OpenClaude and start it again. Picking another provider with `/provider` later deletes only part of the AI/ML API settings; to remove them, run `aimlapi openclaude --undo`.                                                                                                                                                                                             | In the new session, `/status` shows the AI/ML API base URL.                                                                                                                                                              |
| `openclaw`   | A running Gateway reloads the config by itself; start a new session (`/new`) or run `openclaw`.                                                                                                                                                                                                                                                                               | `openclaw config validate`                                                                                                                                                                                               |
| `zero`       | `aimlapi zero` starts it with the key. Plain `zero` needs `AIMLAPI_CLI_KEY` (dev: `AIMLAPI_CLI_DEV_KEY`) in the user's shell: tell them they can add `export AIMLAPI_CLI_KEY="$(aimlapi key print)"` to their shell profile themselves (do not run it); without it, zero silently uses another provider it has a key for. Never suggest exporting `AIMLAPI_API_KEY` for this. | `zero providers list` shows `aimlapi-cli` as active.                                                                                                                                                                     |
| `zcode`      | A running ZCode (desktop app or `zcode`) picks it up by itself; start a new session to use the AI/ML API model.                                                                                                                                                                                                                                                               | The model picker lists the "AI/ML API" provider.                                                                                                                                                                         |
| `hermes`     | Start a new `hermes` session. A running Hermes gateway (messaging) needs `hermes gateway restart`.                                                                                                                                                                                                                                                                            | In the new session, `/model` lists "AI/ML API (aimlapi CLI)" (`custom:aimlapi-cli`) as the current provider; a plain `aimlapi hermes` run adds a second entry, "AI/ML API (aimlapi CLI, last launch)", for its own runs. |

This session keeps running on its current provider until the user restarts; say so.

## Roll back

Preview, confirm with the user, then undo:

```sh
AIMLAPI_NO_UPDATE_CHECK=1 aimlapi <agent> --undo --dry-run </dev/null
AIMLAPI_NO_UPDATE_CHECK=1 aimlapi <agent> --undo </dev/null
```

`--undo` removes exactly what `--config` added and restores the values it replaced; the user's other settings are kept (Codex: deletes the `aimlapi` profile, or puts back a profile of the user's that `--config` replaced; Cline: restores the previous OpenAI Compatible provider). A file in which the user has since replaced aimlapi's settings by hand is left as it is; a Codex profile edited since `--config` makes `--undo` exit `1` without changing it (show the message to the user). Every file `--undo` changes is backed up too.

Optional, after `--undo` for every configured agent:

* Sign out: revokes the CLI's API key and removes it from this computer, including the copies aimlapi wrote into OpenCode, Cline, OpenClaude and ZCode configs at their usual locations, and the agent config backups taken for that environment or holding the key (`logout --env dev` leaves a setup made for prod alone, and the other way round):

  ```sh
  AIMLAPI_NO_UPDATE_CHECK=1 aimlapi logout
  ```

  Copies written to a non-default location (Cline with `$CLINE_DIR`, `$CLINE_DATA_DIR` or `--data-dir`, OpenCode with another `$XDG_DATA_HOME`) are only reported in a warning, not removed: run `aimlapi <agent> --undo` with the same settings first.
* `npm uninstall -g aimlapi` removes the CLI (`npm uninstall -g aimlapi-cli` if it came from the alias, see step 5). Do this only after `--undo`: Claude Code and Codex configs point at the `aimlapi` binary.

## Troubleshooting

| Symptom                                                                 | Cause                                                                                   | Action                                                            |
| ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
| `--config … runs from a temporary package-runner cache (npx)`, exit `2` | `--config` run through `npx`                                                            | step 5, then use `aimlapi`                                        |
| `not logged in to AI/ML API`, exit `3`                                  | no stored key                                                                           | step 4                                                            |
| `<Agent> is not installed`, exit `4`                                    | agent binary not on `PATH` (Cline needs the `cline` CLI even for the VS Code extension) | show the printed install command; install only if the user agrees |
| `codex … cannot load profile files`, exit `1`                           | Codex older than 0.131                                                                  | ask the user to update Codex, then repeat step 6                  |
| a `--config` command prints a menu and never ends                       | `--model` was left out in a terminal                                                    | stop it; re-run with `--model <id>` and `</dev/null`              |
| `warning: AIMLAPI_API_KEY is set`                                       | a key in the environment overrides the stored one                                       | tell the user (step 3); do not print the variable                 |
| `could not fetch the model catalog`                                     | network hiccup                                                                          | harmless warning; setup still applies                             |
| `Config is up to date (0 changes)` on `--undo`                          | nothing of aimlapi's is left in the agent's config                                      | nothing to do                                                     |


# Supported SDKs

Use the OpenAI SDK (Python, JavaScript) and other SDKs with AI/ML API by setting base\_url to https\://api.aimlapi.com/v1.

This page describes the SDK[^1]s that can be used to call our API.

<details>

<summary>Key Definitions &#x26; Notes</summary>

The **REST API** itself is *not* an SDK. It is the **server-side interface** that exposes your models over HTTP. It defines endpoints, HTTP methods (POST/GET), required headers, and the structure of request and response JSON. Essentially, it’s the “contract” the server provides for clients to interact with models programmatically.

***

An **SDK** (Software Development Kit) is a **client-side library** that wraps around the REST API. It handles details like building HTTP requests, serializing/deserializing JSON, error handling, retries, and sometimes additional conveniences.

You can skip the SDK and call the REST API directly via cURL, fetch, requests, etc.\
The SDK just makes your life easier; the REST API is the “core interface” the SDK talks to.

***

The following flow shows how a request travels from your code to the model and back. Using an SDK is optional — it simply wraps the REST API for convenience.

> Your code → SDK (optional) → REST API → Model → REST API → SDK → Your code

</details>

{% hint style="info" %}
Comparing requests made with raw REST API and different SDKs, pay attention to the following common aspects:

* how the Authorization header and the AIML API key are provided,
* how the `POST` method and the endpoint URL are specified,
* how the input parameters are passed.
  {% endhint %}

{% hint style="success" %}
Also take a look at the [**INTEGRATIONS**](/integrations/our-integration-list) section — it covers many third-party services and libraries (workflow platforms, coding assistants, etc.) that allow you to integrate our models in various ways.
{% endhint %}

***

## REST API

We use the REST API because it’s fast, simple, and easy to understand. Only in Python do you need to import a separate library (`requests`), while cURL and JavaScript (Node.js) already have built-in support for HTTP requests. Therefore, REST API is used in the documentation examples for *all* of our models.

### Installation

In Python examples, you need to import the `requests` library. The Node.js and cURL examples do not require any additional imports.

Install the library first:

{% tabs %}
{% tab title="Shell" %}

```bash
pip install requests
```

{% endtab %}
{% endtabs %}

Import the library in every Python code snippet where you make calls to the REST API.

{% tabs %}
{% tab title="Python" %}

```python
import requests
```

{% endtab %}
{% endtabs %}

### Authorization

Our API authorization is based on a Bearer token. Include it in the `Authorization` HTTP header within the request. Example:

{% tabs %}
{% tab title="cURL" %}

```ruby
  --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
  headers: {
    Authorization: "Bearer <YOUR_AIMLAPI_KEY>",
  },
```

{% endtab %}

{% tab title="Python" %}

```python
    headers={
        "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
    },
```

{% endtab %}
{% endtabs %}

### Request Example

{% tabs %}
{% tab title="cURL" %}

```ruby
curl --request POST \
  --url https://api.aimlapi.com/chat/completions \
  --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "google/gemma-3-4b-it",
    "messages": [
        {
            "role": "user",
            "content": "What kind of model are you?"
        }
    ],
    "max_tokens": 512
}'
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
fetch("https://api.aimlapi.com/chat/completions", {
  method: "POST",
  headers: {
    Authorization: "Bearer <YOUR_AIMLAPI_KEY>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "google/gemma-3-4b-it",
    messages: [
      {
        role: "user",
        content: "What kind of model are you?",
      },
    ],
    max_tokens: 512,
  }),
})
  .then((res) => res.json())
  .then(console.log);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json  # for getting a structured output with indentation

response = requests.post(
    url="https://api.aimlapi.com/chat/completions",
    headers={
        "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type": "application/json",
    },
    data=json.dumps(
        {
            "model": "google/gemma-3-4b-it",
            "messages": [
                {
                    "role": "user",
                    "content": "What kind of model are you?",
                },
            ],
            "max_tokens": 512
        }
    ),
)

response.raise_for_status()
print(response.json())
```

{% endtab %}
{% endtabs %}

***

## OpenAI

The OpenAI SDK is a convenient library that simplifies working with our API. It automatically handles JSON responses, includes built-in error handling and retry logic, and provides simple, easy-to-use methods for all API features such as chat, embeddings, and completions.

<details>

<summary>The AI features that the OpenAI SDK supports</summary>

* Streaming
* Completions
* Chat Completions
* Audio
* Beta Assistants
* Beta Threads
* Embeddings
* Image Generation
* File Uploads

{% hint style="info" %}
Therefore, we don’t currently have the option to call video models or voice / speech models (STT and TTS) through this SDK.
{% endhint %}

</details>

### Installation

<details>

<summary>Python</summary>

1\. Make sure you have Python 3.7+ and `pip` installed.

2\. Install the OpenAI SDK via terminal or Jupyter Notebook:

```bash
pip install openai
```

> In Jupyter Notebook, you can also use:
>
> ```python
> %pip install openai
> ```

3\. Import the SDK:

```python
import openai
```

***

</details>

<details>

<summary>JavaScript (Node.js)</summary>

1\. Make sure you have Node.js 18+ and npm installed.

2\. Install the OpenAI SDK in your project:

```bash
npm install openai
```

3\. Import the SDK and initialize the client:

```js
import OpenAI from "openai";
```

</details>

### Example Code

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

```python
from openai import OpenAI

# Insert your AIML API key in the quotation marks instead of <YOUR_AIMLAPI_KEY>:
api_key = "<YOUR_AIMLAPI_KEY>" 
base_url = "https://api.aimlapi.com/v1"
user_prompt = "Tell me about San Francisco"

api = OpenAI(api_key=api_key, base_url=base_url)


def main():
    completion = api.chat.completions.create(
        model="google/gemma-3-4b-it",
        messages=[
            {
              "role": "user", 
              "content": user_prompt
            },
        ],
        temperature=0.7,
        max_tokens=256,
    )

    response = completion.choices[0].message.content
    print("User:", user_prompt)
    print("AI:", response)


if __name__ == "__main__":
    main()
```

{% endcode %}
{% endtab %}

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

```javascript
#!/usr/bin/env node

const OpenAI = require("openai");
const baseURL = "https://api.aimlapi.com/v1";
const apiKey = "<YOUR_AIMLAPI_KEY>";
const systemPrompt = "You are a travel agent. Be descriptive and helpful.";
const userPrompt = "Tell me about San Francisco";

const api = new OpenAI({
  apiKey,
  baseURL,
});

const main = async () => {
  try {
    const completion = await api.chat.completions.create({
      model: "gpt-4o",
      messages: [
        {
          role: "system",
          content: systemPrompt,
        },
        {
          role: "user",
          content: userPrompt,
        },
      ],
      temperature: 0.7,
      max_tokens: 256,
    });

    const response = completion.choices[0].message.content;

    console.log("User:", userPrompt);
    console.log("AI:", response);
  } catch (error) {
      console.error("Error:", error.message);
  }
};

main();
```

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

***

## AI/ML API Python library

We have started developing our own SDK to simplify the use of our service.

{% hint style="success" %}
If you’d like to contribute to expanding its functionality, feel free to reach out to us on [**Discord**](https://discord.com/invite/hvaUsJpVJf)!
{% endhint %}

### Installation

After obtaining your AIML API key, create an .env file and copy the required contents into it.

```shell
touch .env
```

Copy the code below, paste it into your `.env` file, and set your API key in `AIML_API_KEY="<YOUR_AIMLAPI_KEY>"`, replacing `<YOUR_AIMLAPI_KEY>` with your actual key:

```shell
AIML_API_KEY = "<YOUR_AIMLAPI_KEY>"
AIML_API_URL = "https://api.aimlapi.com/v1"
```

Install the package:

```shell
# install from PyPI
pip install aimlapi-sdk-python
```

### Request Example

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

```python
from aiml_api import AIML_API

api = AIML_API()

completion = api.chat.completions.create(
    model = "mistralai/Mistral-7B-Instruct-v0.2",
    messages = [
        {"role": "user", "content": "Explain the importance of low-latency LLMs"},
    ],
    temperature = 0.7,
    max_tokens = 256,
)

response = completion.choices[0].message.content
print("AI:", response)
```

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

To execute the script, use:

```shell
python3 <your_script_name>.py
```

***

## Next Steps

* [Check our full list of model IDs](/api-references/model-database)
* [Browse and compare AI models, including GPT, Claude, and many others, using the Playground](https://aimlapi.com/app/)
* [Learn more about special text model capabilities](/capabilities/completion-or-chat-models)
* [Join the community: get help and share your projects in our Discord](https://discord.com/invite/hvaUsJpVJf)

[^1]: An SDK (Software Development Kit) is a **client-side library** that wraps around the REST API.


# Toolbox

Ready-made tools — web search, page extraction, screenshots, news and social data and more — callable with your AI/ML API key from agents, MCP clients and your own apps.

**Toolbox** is a set of ready-made actions your LLM can use: web search, reading a web page as Markdown, website screenshots, news and social media search, company and domain data, and hundreds more. You call them with the **same AI/ML API key** you use for models. There is no separate account to sign up for and no third-party key to manage, and usage is billed to your AI/ML API balance.

Use them when a model needs **fresh or external data**, or needs to **act**, beyond what it already knows. Typical cases: a research agent that searches and cites sources, a support bot that reads a customer's page, or an app that builds a report with a live screenshot.

## Ways to use them

| You are building…                                     | Use                                                               | Who runs the tool |
| ----------------------------------------------------- | ----------------------------------------------------------------- | ----------------- |
| An agent in **Claude Code, Cursor, Claude Desktop**   | [MCP](/quickstart/mcp) — the `tools_*` tools appear automatically | your MCP client   |
| Your **own app or pipeline**                          | the REST API below                                                | your code         |
| An app on **chat/completions** with function calling  | tool definitions in `tools[]` + `/v1/tools/run`                   | your code         |
| A one-call agent on **/v1/responses** (OpenAI models) | our MCP server as a `{"type": "mcp"}` tool                        | the model         |

**Base URL:** `https://tools.aimlapi.com`. **Auth:** `Authorization: Bearer <YOUR_AIMLAPI_KEY>`.

## Quickstart: MCP

The fastest way in. One command, no API key to paste, and the whole Toolbox shows up in your agent.

{% tabs %}
{% tab title="Claude Code" %}

```bash
claude mcp add --transport http --scope user aimlapi https://mcp.aimlapi.com/mcp
```

Then, in a Claude Code session, run `/mcp`, pick **aimlapi** and choose **Authenticate** — a browser opens for you to sign in to AI/ML API.

`--scope user` makes the server available in every project; drop it to add it to the current folder only. Do not pass `--header` — that switches the client to API-key auth instead of the browser sign-in.
{% endtab %}

{% tab title="Cursor" %}
Add to `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (project), with no `headers` block — leaving it out is what triggers the sign-in:

```json
{
  "mcpServers": {
    "aimlapi": {
      "url": "https://mcp.aimlapi.com/mcp"
    }
  }
}
```

Then open **Cursor Settings → Tools & Integrations**, find **aimlapi**, click **···→ Enable**, then **Login**.
{% endtab %}

{% tab title="Claude Desktop" %}
**Settings → Connectors → Add custom connector**, name it `AIMLAPI` and point it at:

```
https://mcp.aimlapi.com/mcp
```

Click **Add**, then **Connect** on the new connector and sign in. Adding alone does not authenticate it — the tools stay inactive until you click **Connect**.
{% endtab %}
{% endtabs %}

**What you get.** Four tools that hand the agent the whole catalog — it searches for what it needs, checks the price, and runs it:

```
tools_search → tools_inspect → tools_run → tools_run_status
```

Ask for something that needs live data and the agent works it out by itself:

> *"Find three fresh news items about the Model Context Protocol and give me the links."*

It calls `tools_search` to find a news tool, `tools_inspect` to see the input it takes, then `tools_run`. You pay only for the run; the other three calls are free. Results arrive marked `"untrusted": true`, so the agent treats them as data rather than instructions.

The same connection also exposes the model tools — chat, images, embeddings, balance. See [MCP](/quickstart/mcp) for the full client list, OAuth details and troubleshooting.

## REST: search → inspect → run

**1. Find a tool.** Describe what you need in plain words.

```bash
curl https://tools.aimlapi.com/v1/tools/search \
  -H "Authorization: Bearer $AIMLAPI_KEY" -H "Content-Type: application/json" \
  -d '{"query": "web search", "limit": 5}'
```

```json
[{ "id": "web/search", "name": "web_search", "description": "Search the web and return a list of relevant pages.",
   "pricing": { "type": "tiered", "amount_usd": 0.0091 } }, …]
```

**2. Check its input and price.**

```bash
curl https://tools.aimlapi.com/v1/tools/inspect \
  -H "Authorization: Bearer $AIMLAPI_KEY" -H "Content-Type: application/json" \
  -d '{"tool": "web/search"}'
```

The response contains `input_schema` (what to send in `input`) and `price_usd`.

**3. Run it.**

```bash
curl https://tools.aimlapi.com/v1/tools/run \
  -H "Authorization: Bearer $AIMLAPI_KEY" -H "Content-Type: application/json" \
  -d '{"tool": "web/search", "input": {"query": "Model Context Protocol news", "max_results": 3},
       "max_cost_usd": 0.05, "wait_ms": 30000, "idempotency_key": "my-run-001"}'
```

```json
{ "id": "7lC_vqHA6L8m2TloNMJZQ", "tool": "web/search", "status": "completed", "is_error": false,
  "cost": { "quoted_usd": 0.0091, "actual_usd": 0.0091, "credits": 18200, "over_max": false },
  "output": { "results": [{ "url": "https://…", "title": "…", "snippet": "…", "published_at": "…" }] } }
```

* **`200`**: the run is finished, and the result is in `output`.
* **`202`**: the run is still working (`"status": "queued"`). Poll `GET /v1/tools/runs/{id}` after `next_poll_hint_ms` milliseconds until the status is `completed`, `failed`, `stopped` or `timed_out`.
* A run that executed but failed returns `"is_error": true` with `error.message`. If `error.retryable` is `true`, it is worth trying again.

## Function calling in chat/completions

Every tool can be exported as a ready function definition in the format your model expects: `openai` (chat/completions), `openai-responses`, `anthropic` or `gemini`. The model decides when to call the tool, and your code runs it.

```python
import json, requests
from openai import OpenAI

KEY = "<YOUR_AIMLAPI_KEY>"
TOOLS = "https://tools.aimlapi.com/v1/tools"
H = {"Authorization": f"Bearer {KEY}"}
client = OpenAI(base_url="https://api.aimlapi.com/v1", api_key=KEY)

tool_id = "web/search"  # ids contain "/", so encode it in the URL path
definition = requests.get(f"{TOOLS}/web%2Fsearch/definition?format=openai", headers=H).json()["definition"]

messages = [{"role": "user", "content": "What's new in the Model Context Protocol? Cite sources."}]
reply = client.chat.completions.create(model="gpt-4o-mini", messages=messages, tools=[definition])
msg = reply.choices[0].message

if msg.tool_calls:
    messages.append(msg)
    for call in msg.tool_calls:
        args = {k: v for k, v in json.loads(call.function.arguments).items() if v is not None}
        run = requests.post(f"{TOOLS}/run", headers=H, json={
            "tool": tool_id, "input": args, "max_cost_usd": 0.05, "wait_ms": 30000}).json()
        messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(run.get("output"))})
    reply = client.chat.completions.create(model="gpt-4o-mini", messages=messages, tools=[definition])

print(reply.choices[0].message.content)
```

Tips:

* Definitions use strict mode, so optional fields arrive as `null`. Drop them before calling `/run`.
* Pass the model a compact version of `output`, not the whole payload. Some tools return large results.

## One call with /v1/responses (OpenAI models)

Give the model our MCP server, and it will search, run tools and answer in a single request:

```json
{
  "model": "gpt-4.1",
  "input": "Find 3 fresh news items about the Model Context Protocol, with links.",
  "tools": [{
    "type": "mcp",
    "server_label": "aimlapi",
    "server_url": "https://mcp.aimlapi.com/mcp",
    "headers": { "Authorization": "Bearer <YOUR_AIMLAPI_KEY>" },
    "allowed_tools": ["tools_search", "tools_inspect", "tools_run", "tools_run_status"],
    "require_approval": "never"
  }]
}
```

Send it to `POST https://api.aimlapi.com/v1/responses`. The `output` array shows each `mcp_call` and ends with the model's message.

## The four MCP tools

Set up in [Quickstart: MCP](#quickstart-mcp) above. These are the tools your agent gets:

| MCP tool           | What it does                                                   |
| ------------------ | -------------------------------------------------------------- |
| `tools_search`     | finds tools for a task                                         |
| `tools_inspect`    | returns a tool's input schema and price                        |
| `tools_run`        | runs the tool: returns the result, or a `run_id` for long runs |
| `tools_run_status` | checks a long run                                              |

Results come back under `result` with `"untrusted": true`, so the agent treats them as data and not as instructions.

## Pricing, limits and safety

* **You only pay for runs.** Search, inspect, definitions and run status are free.
* **`max_cost_usd`** caps a run. You are never charged more than this amount, and the default is $0.25. Some tools with variable pricing require it explicitly; the price is shown by `inspect`.
* **`idempotency_key`** makes retries safe: a repeated call with the same key and input returns the same run without charging again.
* **Treat tool output as untrusted.** It comes from the open web. Never let a model follow instructions found inside it, and say so in your system prompt.

| Error code                                    | Meaning                                                                       |
| --------------------------------------------- | ----------------------------------------------------------------------------- |
| `400 invalid_input`                           | `input` does not match the tool's `input_schema`; the message names the field |
| `400 max_cost_required` / `max_cost_exceeded` | set or raise `max_cost_usd`                                                   |
| `403 insufficient_funds`                      | top up your balance                                                           |
| `404 tool_not_found` / `410 tool_unavailable` | search again for an alternative                                               |
| `429 rate_limited`                            | slow down and retry after `Retry-After`                                       |


# Service Endpoints

Account and catalogue endpoints: model list with prices, deprecations, live model speed, balance, API keys, usage and per-request logs.


# Account Balance

GET /v2/billing returns the account balance in USD; /v2/billing/detail and /v2/billing/transactions add settings and history. Header: Authorization: Bearer \<AIMLAPI\_KEY>.

<table data-header-hidden data-full-width="true"><thead><tr><th width="220" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><a href="#get-balance-info">Get balance info</a></td><td valign="top"><mark style="color:$success;"><strong><code>GET</code></strong></mark> <code>https://api.aimlapi.com/v2/billing</code></td></tr><tr><td valign="top"><a href="#get-detailed-billing-info">Get detailed billing info</a></td><td valign="top"><mark style="color:$success;"><strong><code>GET</code></strong></mark> <code>https://api.aimlapi.com/v2/billing/detail</code></td></tr><tr><td valign="top"><a href="#get-account-transactions">Get account transactions</a></td><td valign="top"><mark style="color:$success;"><strong><code>GET</code></strong></mark> <code>https://api.aimlapi.com/v2/billing/transactions</code></td></tr><tr><td valign="top"><a href="#get-account-balance-info">Get account balance info</a> <em>(legacy)</em></td><td valign="top"><mark style="color:$success;"><strong><code>GET</code></strong></mark> <code>https://api.aimlapi.com/v1/billing/balance</code></td></tr></tbody></table>

To make a request, you only need your AIMLAPI key obtained from your [account dashboard](https://aimlapi.com/app/keys).

### Get balance info

Returns a user's balance.

## GET /v2/billing

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v2/billing":{"get":{"operationId":"_v2_billing","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"–","title":"–"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"type":"object","properties":{"current_balance":{"type":"number","description":"current user balance in USD."},"currency":{"type":"string","description":"balance currency (always USD)"}},"required":["current_balance","currency"]}}}}}}}}}
```

***

### Get detailed billing info

Returns detailed billing information, balance and auto top-up settings.

## GET /v2/billing/detail

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v2/billing/detail":{"get":{"operationId":"_v2_billing_detail","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"–","title":"–"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"type":"object","properties":{"user_id":{"type":"number","description":"User ID."},"email":{"type":"string","description":"User email."},"current_balance":{"type":"number","description":"Current balance in USD."},"currency":{"type":"string","description":"Currency (always USD)."},"autotopup_settings":{"type":"object","description":"Auto top-up settings.","properties":{"is_enabled":{"type":"boolean","description":"Whether auto top-up is enabled."},"threshold":{"type":"number","description":"Balance threshold that triggers auto top-up (USD)."},"amount":{"type":"number","description":"Auto top-up amount (USD)."},"currency":{"type":"string","description":"Auto top-up currency (always USD)."}},"required":["user_id","email","current_balance","currency","autotopup_settings"]}}}}}}}}}}}
```

***

### Get account transactions

The account money feed: one entry per balance movement, either a successful top-up or a charge carrying the model that produced it. Authenticate with a **regular** AIML API key — there is no `key_prefix`, because a wallet belongs to the account, not to a key.

For a `MODEL_USAGE` charge, `reference_id` is the inference id — the same value returned in the `x-inference-id` response header and reported as `inference_id` in [Usage Logs](/api-references/service-endpoints/usage-logs).

{% hint style="info" %}
This is the account ledger — the same figures that move your balance — so it is what you reconcile against. [API Key Usage](/api-references/service-endpoints/api-key-usage) and [Usage Logs](/api-references/service-endpoints/usage-logs) come from the analytics pipeline instead, and are meant for attribution and budgeting.

A charge lands **after** you saw your response, and for async video after the generation reports `completed`, so reconciling the instant a generation finishes will under-count. Failed requests are never charged and have no entry here at all.
{% endhint %}

{% hint style="warning" %}
Page with the cursor, never with an offset. The ledger grows at the head, so a numeric offset silently skips or repeats entries between pages. Pass `pagination.next_cursor` back as `cursor` — it is opaque and accepted only in the exact form we issued, so re-encoding it is rejected with `400`.
{% endhint %}

Returns the account's balance movements, newest first.

## GET /v2/billing/transactions

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v2/billing/transactions":{"get":{"operationId":"_v2_billing_transactions","parameters":[{"name":"from","in":"query","required":false,"description":"Only return entries created at or after this moment, ISO-8601 with an offset.","schema":{"type":"string"}},{"name":"to","in":"query","required":false,"description":"Only return entries created before this moment, ISO-8601 with an offset. Must be later than `from`.","schema":{"type":"string"}},{"name":"direction","in":"query","required":false,"description":"Keep only money coming in (`TOPUP`) or money going out (`CHARGE`).","schema":{"type":"string","enum":["TOPUP","CHARGE"]}},{"name":"type","in":"query","required":false,"description":"Keep only entries of this kind.","schema":{"type":"string","enum":["PAYMENT","BONUS","REFUND","ADJUSTMENT","MODEL_USAGE","CREDITS_EXPIRED","INIT"]}},{"name":"limit","in":"query","required":false,"description":"Entries per page, 1-100.","schema":{"type":"integer","default":50,"minimum":1,"maximum":100}},{"name":"cursor","in":"query","required":false,"description":"Position to continue from, taken verbatim from the previous response's `pagination.next_cursor`. The value is opaque and is accepted only in the exact form we issued.","schema":{"type":"string"}}],"responses":{"200":{"description":"One entry per balance movement, newest first.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","description":"The requested page of ledger entries.","items":{"type":"object","properties":{"created_at":{"type":"string","description":"When the entry was recorded, in UTC."},"direction":{"type":"string","enum":["TOPUP","CHARGE"],"description":"Which way the money moved. `amount` is always positive, so this is what carries the sign."},"type":{"type":"string","enum":["PAYMENT","BONUS","REFUND","ADJUSTMENT","MODEL_USAGE","CREDITS_EXPIRED","INIT"],"description":"What produced the entry."},"amount":{"type":"object","description":"How much moved, always as a positive number.","properties":{"usd":{"type":"number"},"credits":{"type":"integer"}},"required":["usd","credits"]},"model":{"type":"string","nullable":true,"description":"Model that produced the charge. Null on top-ups, on charges that are not model usage, and when the model could not be resolved."},"reference_id":{"type":"string","nullable":true,"description":"Handle that ties the entry back to something you have. For `MODEL_USAGE` it is the inference id, for a payment it is the payment transaction id. Null when the entry has no caller-side handle, such as a bonus, an expiry or a manual adjustment."}},"required":["created_at","direction","type","amount","model","reference_id"]}},"pagination":{"type":"object","properties":{"next_cursor":{"type":"string","nullable":true,"description":"Pass this back as `cursor` to fetch the next page. Null on the last page."},"has_more":{"type":"boolean","description":"Whether another page follows this one."}},"required":["next_cursor","has_more"]}},"required":["data","pagination"]}}}}}}}}}
```

#### Errors

| Code  | When                                                                                                                                              |
| ----- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `400` | `to` not later than `from`; an unknown query parameter; `limit` outside 1–100; an unknown `direction` or `type`; a malformed or re-encoded cursor |
| `401` | Missing or invalid key                                                                                                                            |
| `403` | A management key — this route is for regular keys                                                                                                 |

***

### Get account balance info

{% hint style="warning" %}
This endpoint is considered legacy and is scheduled for future deprecation.\
Please plan to migrate to the `/v2/billing` and `/v2/billing/detail` endpoints documented above.
{% endhint %}

## GET /v1/billing/balance

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v1/billing/balance":{"get":{"operationId":"_v1_billing_balance","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"–","title":"–"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"type":"object","properties":{"balance":{"type":"number","description":"The total credits associated with the provided API key."},"lowBalance":{"type":"boolean","description":"True if the balance is below the threshold."},"lowBalanceThreshold":{"type":"number","description":"Threshold for switching to low balance status."},"lastUpdated":{"type":"string","format":"date-time","description":"The date of the request — i.e., the current date."},"autoDebitStatus":{"type":"string","description":"Indicates whether auto top-up is enabled for the plan."},"status":{"type":"string","description":"The status of the plan associated with the provided API key."},"statusExplanation":{"type":"string","description":"A more detailed explanation of the plan status."}},"required":["balance","lowBalance","lowBalanceThreshold","lastUpdated","autoDebitStatus","status","statusExplanation"]}}}}}}}}}
```


# Model Performance Metrics

GET /models/metrics, no key needed: live time to first token, tokens per second and duration per model, as p50 to p99.

<table data-header-hidden data-full-width="true"><thead><tr><th width="220" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><a href="#get-model-performance-metrics">Get model performance metrics</a></td><td valign="top"><mark style="color:$success;"><strong><code>GET</code></strong></mark> <code>https://api.aimlapi.com/models/metrics</code></td></tr></tbody></table>

`GET /models/metrics` reports how fast models are responding **right now** — `ttft_ms`, `tps` and `duration_ms` as p50/p75/p90/p99 over a short sliding window, per model.\
No API key is required for this request. You can also open [the endpoint](https://api.aimlapi.com/models/metrics) directly in a browser.

Use it to pick between models that are otherwise interchangeable, or to check whether slowness you are seeing is on your side. These are the same numbers the model cards in the dashboard show.

{% hint style="warning" %}
**A higher percentile of `tps` is better, not worse.** These are percentiles of the measured value itself, so `p99` of `ttft_ms` or `duration_ms` is the slow tail — but `p99` of `tps` is the *fastest* requests, and `p50` is the typical one. Comparing models on `tps` p99 compares their best cases.
{% endhint %}

{% hint style="info" %}
A model that served no successful requests inside the window is **absent from `models` entirely**. That is "no data", not "zero latency" — and since only successful requests are measured, a model that is failing everything drops off the list rather than showing bad numbers.

`aliases` does not split on commas: repeat the parameter, as in `?aliases=openai/gpt-5&aliases=google/veo-3`. Names are matched exactly against the `id` and `aliases` from the [Complete Model List](/api-references/service-endpoints/complete-model-list).
{% endhint %}

### Get model performance metrics

Returns latency percentiles per model over the current window.

## GET /models/metrics

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/models/metrics":{"get":{"operationId":"_models_metrics","parameters":[{"name":"aliases","in":"query","required":false,"description":"Keep only these models. Repeat the parameter once per model (`?aliases=openai/gpt-5&aliases=google/veo-3`), up to 100 values. Values are matched exactly, so a comma-separated list is read as one long name and matches nothing. Omit the parameter to get every measured model. Any other query parameter is rejected with 400.","schema":{"type":"string"}}],"responses":{"200":{"description":"Latency percentiles per model over the current window.","content":{"application/json":{"schema":{"type":"object","properties":{"window_seconds":{"type":"integer","description":"Length of the sliding window the percentiles were computed over."},"generated_at":{"type":"string","description":"When the aggregation was computed, in UTC."},"models":{"type":"array","description":"One entry per model that completed at least one successful request inside the window. Only successful requests are measured. Models with no such requests are absent from the list rather than reported as zero.","items":{"type":"object","properties":{"alias":{"type":"string","description":"Model name, matching an `id` or an alias from the model catalogue."},"endpoint":{"type":"string","description":"Endpoint the measurements were taken on."},"metrics":{"type":"object","description":"Only the metrics that apply to this model type and are backed by data in the window are present. A missing key means the metric does not apply, not that it is zero.","properties":{"ttft_ms":{"type":"object","description":"Time to first token, in milliseconds. Streaming text models only.","properties":{"p50":{"type":"number"},"p75":{"type":"number"},"p90":{"type":"number"},"p99":{"type":"number"}},"required":["p50","p75","p90","p99"]},"tps":{"type":"object","description":"Output tokens per second. Text models only. Note that these are percentiles of the throughput value itself, so a higher percentile is a faster request, not a slower one.","properties":{"p50":{"type":"number"},"p75":{"type":"number"},"p90":{"type":"number"},"p99":{"type":"number"}},"required":["p50","p75","p90","p99"]},"duration_ms":{"type":"object","description":"End-to-end request duration, in milliseconds.","properties":{"p50":{"type":"number"},"p75":{"type":"number"},"p90":{"type":"number"},"p99":{"type":"number"}},"required":["p50","p75","p90","p99"]}}}},"required":["alias","endpoint","metrics"]}}},"required":["window_seconds","generated_at","models"]}}}}}}}}}
```


# API Key Management

Create, list, update and delete API keys with /v1/keys and a management key.

<table data-header-hidden data-full-width="true"><thead><tr><th width="185.762939453125" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><a href="#create-an-api-key">Create a new API key</a></td><td valign="top"><mark style="color:$warning;"><strong><code>POST</code></strong></mark> <code>https://api.aimlapi.com/v1/keys</code></td></tr><tr><td valign="top"><a href="#list-api-keys">List API keys</a></td><td valign="top"><mark style="color:$success;"><strong><code>GET</code></strong></mark> <code>https://api.aimlapi.com/v1/keys</code></td></tr><tr><td valign="top"><a href="#get-the-api-key">Get the API key</a></td><td valign="top"><mark style="color:$success;"><strong><code>GET</code></strong></mark> <code>https://api.aimlapi.com/v1/key</code></td></tr><tr><td valign="top"><a href="#update-an-api-key">Update an API key</a></td><td valign="top"><mark style="color:purple;"><strong><code>PATCH</code></strong></mark> <code>https://api.aimlapi.com/v1/keys/{prefix}</code></td></tr><tr><td valign="top"><a href="#delete-an-api-key">Delete an API key</a></td><td valign="top"><mark style="color:$danger;"><strong><code>DELETE</code></strong></mark> <code>https://api.aimlapi.com/v1/keys/{prefix}</code></td></tr></tbody></table>

{% hint style="warning" %}
Before you start you should create [a management key](/faq/how-can-i-work-with-my-api-keys#management-keys).
{% endhint %}

### Create a new API key

Copy the created key and store it in a secure location. If the key is lost, create a new one.

## POST /v1/keys

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v1/keys":{"post":{"operationId":"KeysController_createKey_v1","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"Optional human-readable name of the API key."},"limit":{"type":"object","description":"Optional spending limit configuration.","properties":{"retention":{"type":"string","description":"Limit period.","enum":["no_reset","day","week","month"]},"threshold":{"type":"number","description":"Spending limit threshold for the selected period, in USD."}}},"scopes":{"type":"array","nullable":true,"description":"List of model access scopes assigned to the key. Defines which categories of models can be called using this API key.","items":{"type":"string","enum":["model:chat","model:responses","model:image","model:audio","model:video","model:embeddings","model:speech","model:ocr"]}}},"additionalProperties":false}}}},"responses":{"200":{"description":"API key creation result","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"name":{"type":"string","nullable":true,"description":"Human-readable, user-defined name for the API key."},"disabled":{"type":"boolean","description":"Indicates whether the key is disabled."},"prefix":{"type":"string","description":"Key prefix. This is the first 8 characters of your API key, visible in the dashboard."},"scopes":{"type":"array","nullable":true,"description":"List of model access scopes assigned to the key. Defines which categories of models can be called using this API key.","items":{"type":"string","enum":["model:chat","model:responses","model:image","model:audio","model:video","model:embeddings","model:speech","model:ocr"]}},"limit":{"type":"object","description":"Applied spending limits.","properties":{"retention":{"type":"string","description":"Limit period.","enum":["no_reset","day","week","month"]},"threshold":{"type":"number","description":"Spending limit threshold for the selected period, in USD"}}},"created_at":{"type":"string","format":"date-time","description":"Creation timestamp (UTC)."},"updated_at":{"type":"string","format":"date-time","description":"Last update timestamp (UTC)."},"monthly_usage":{"type":"number","description":"Current monthly usage amount."},"key":{"type":"string","description":"Full API key value (returned only at creation time)."}},"required":["disabled","prefix","scopes","created_at","updated_at","monthly_usage","key"]}},"required":["data"]}}}}}}}}}
```

***

### List API keys

Returns all API keys for your account, including each key’s settings and metadata.

## GET /v1/keys

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v1/keys":{"get":{"operationId":"KeysController_listKeys_v1","responses":{"200":{"description":"List of API keys, ordered from oldest to newest","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","nullable":true,"description":"Human-readable, user-defined name for the API key."},"prefix":{"type":"string","description":"Key prefix. This is the first 8 characters of your API key, visible in the dashboard. You can also obtain this value via the POST method (see the `prefix` field in its response)."},"disabled":{"type":"boolean","description":"Indicates whether the key is disabled."},"scopes":{"type":"array","nullable":true,"description":"List of model access scopes assigned to the key. Defines which categories of models can be called using this API key.","items":{"type":"string","enum":["model:chat","model:responses","model:image","model:audio","model:video","model:embeddings","model:speech","model:ocr"]}},"limit":{"nullable":true,"type":"object","description":"Spending limits configuration (if set).","properties":{"retention":{"type":"string","enum":["no_reset","day","week","month"]},"threshold":{"type":"number","description":"Spending limit threshold for the selected period, in USD."}}},"created_at":{"type":"string","format":"date-time","description":"Creation timestamp (UTC)."},"updated_at":{"type":"string","format":"date-time","description":"Last update timestamp (UTC)."},"monthly_usage":{"type":"number","description":"Current monthly usage amount."}},"required":["disabled","prefix","scopes","created_at","updated_at","monthly_usage"]}}},"required":["data"]}}}}}}}}}
```

***

### Get the API key

Retrieve parameters of the most recently used API key.

## GET /v1/key

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v1/key":{"get":{"operationId":"KeysController_getLatestKey_v1","responses":{"200":{"description":"Parameters of the latest API key","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"name":{"type":"string","nullable":true,"description":"Human-readable, user-defined name for the API key."},"disabled":{"type":"boolean","description":"Indicates whether the key is disabled."},"prefix":{"type":"string","description":"Key prefix. This is the first 8 characters of your API key, visible in the dashboard. You can also obtain this value via the POST method (see the `prefix` field in its response)."},"scopes":{"type":"array","nullable":true,"description":"List of model access scopes assigned to the key. Defines which categories of models can be called using this API key.","items":{"type":"string","enum":["model:chat","model:responses","model:image","model:audio","model:video","model:embeddings","model:speech","model:ocr"]}},"limit":{"nullable":true,"type":"object","description":"Spending limits configuration (if set).","properties":{"retention":{"type":"string","enum":["no_reset","day","week","month"]},"threshold":{"type":"number","description":"Spending limit threshold for the selected period, in USD."}}},"created_at":{"type":"string","format":"date-time","description":"Creation timestamp (UTC)."},"updated_at":{"type":"string","format":"date-time","description":"Last update timestamp (UTC)."},"monthly_usage":{"type":"number","description":"Current monthly usage amount."}},"required":["disabled","prefix","created_at","updated_at","monthly_usage"]}},"required":["data"]}}}}}}}}}
```

***

### Update an API key

## PATCH /v1/keys/{prefix}

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v1/keys/{prefix}":{"patch":{"operationId":"KeysController_patchKey_v1","parameters":[{"name":"prefix","in":"path","required":true,"description":"Prefix of the API key to update. Passed in the URL path. This is the first 8 characters of your API key, visible in the dashboard. You can also obtain this value via the GET method (see the `prefix` field in its response).","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"Optional human-readable name of the API key."},"disabled":{"type":"boolean","description":"Enable or disable the API key."},"limit":{"type":"object","description":"Optional spending limit configuration.","properties":{"retention":{"type":"string","description":"Limit period.","enum":["no_reset","day","week","month"]},"threshold":{"type":"number","description":"Spending limit threshold for the selected period, in USD"}}},"scopes":{"type":"array","nullable":true,"description":"List of model access scopes assigned to the key. Defines which categories of models can be called using this API key.","items":{"type":"string","enum":["model:chat","model:responses","model:image","model:audio","model:video","model:embeddings","model:speech","model:ocr"]}}}}}}},"responses":{"200":{"description":"Updated API key parameters","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"name":{"type":"string","nullable":true,"description":"Human-readable, user-defined name for the API key."},"disabled":{"type":"boolean","description":"Indicates whether the key is disabled."},"prefix":{"type":"string","description":"Key prefix. This is the first 8 characters of your API key, visible in the dashboard. You can also obtain this value via the GET method (see the `prefix` field in its response)."},"scopes":{"type":"array","nullable":true,"description":"List of model access scopes assigned to the key. Defines which categories of models can be called using this API key.","items":{"type":"string","enum":["model:chat","model:responses","model:image","model:audio","model:video","model:embeddings","model:speech","model:ocr"]}},"limit":{"nullable":true,"type":"object","description":"Spending limits configuration (if set).","properties":{"retention":{"type":"string","enum":["no_reset","day","week","month"]},"threshold":{"type":"number"}}},"created_at":{"type":"string","format":"date-time","description":"Creation timestamp (UTC)."},"updated_at":{"type":"string","format":"date-time","description":"Last update timestamp (UTC)."},"monthly_usage":{"type":"number","description":"Current monthly usage amount."}},"required":["disabled","prefix","scopes","created_at","updated_at","monthly_usage"]}},"required":["data"]}}}}}}}}}
```

***

### Delete an API key

## DELETE /v1/keys/{prefix}

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v1/keys/{prefix}":{"delete":{"operationId":"KeysController_postKeys_v1","parameters":[{"name":"prefix","in":"path","required":true,"description":"Prefix of the API key to delete. Passed in the URL path. This is the first 8 characters of the API key you want to delete. Passed in the URL path. This is the first 8 characters of your API key, visible in the dashboard. You can also obtain this value via the GET method (see the `prefix` field in its response).","schema":{"type":"string"}}],"responses":{"200":{"description":"Key deletion result","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"prefix":{"type":"string","description":"Prefix of the deleted API key."},"deleted":{"type":"boolean","description":"Indicates whether the key was successfully deleted."}},"required":["prefix","deleted"]}},"required":["data"]}}}}}}}}}
```


# API Key Usage

GET /v2/usage and /v2/usage/detail return what an API key spent over a period.

Query how much a given API key spent over a period of time.\
To make a request, you only need your AIMLAPI key obtained from your [account dashboard](https://aimlapi.com/app/keys).

Both endpoints take the same parameters and differ only in what they return: `/v2/usage/detail` adds a per-model breakdown.

## Choosing the time window

Pass **either** `period` **or** both `start` and `end` — not both at once:

* `period` is relative — `24h`, `7d`, that is a positive integer followed by `h` or `d`.
* `start` and `end` are absolute ISO-8601 timestamps.

The window cannot exceed **92 days**. For a longer report, request several windows and add them up.

{% hint style="info" %}
A timestamp without a UTC offset is read as **UTC**, not as your local time. Pass an explicit offset (`2026-07-01T00:00:00+03:00`) if you mean something else.

The response always echoes `start` and `end` resolved to UTC, so you can see exactly which window was measured.
{% endhint %}

## Choosing the key

| Your key       | `key_prefix`             | Result           |
| -------------- | ------------------------ | ---------------- |
| any key        | omitted                  | its own spend    |
| management key | provided                 | that key's spend |
| regular key    | provided, its own prefix | its own spend    |
| regular key    | provided, another prefix | `403`            |

Any key can read its own spend. Reading the spend of a **different** key requires a management key.

## Grouping the breakdown

`/v2/usage/detail` can additionally split the window into buckets. Pass `group_by`:

| Value       | Adds one entry per…      |
| ----------- | ------------------------ |
| `day`       | day in the window        |
| `model`     | model used in the window |
| `day,model` | model per day            |

```bash
curl -H 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
  'https://api.aimlapi.com/v2/usage/detail?period=30d&group_by=day,model&tz=Europe/Berlin'
```

Each entry in the resulting `groups` array carries its `spend`, `tokens` and a `requests` object. Omitting `group_by` leaves the response exactly as it was.

`tz` sets where the day boundary falls; it defaults to UTC and only affects `group_by=day`. The top-level `start` and `end` stay UTC regardless.

{% hint style="warning" %}
**Reconcile against `requests.charged`, not `requests.total`.**

A failed request is billed nothing — the hold is rolled back — so it has no charge behind it. `requests.total` counts every request in the group, `requests.charged` only the billed ones, and the top-level `requests` is the charged count. So `requests` equals the sum of `groups[].requests.charged`, and it matches the sum of `groups[].requests.total` only in a window where nothing failed.
{% endhint %}

{% hint style="info" %}
`tz` must be a **canonical IANA zone name matched exactly** — `Europe/Berlin`, `UTC`. Offset forms (`+05:00`) and other-case spellings (`utc`) are rejected with `400`.

`group_by` and `tz` are accepted on `/v2/usage/detail` only. A flat total has nowhere to put a breakdown, so `/v2/usage` answers `400` rather than silently ignoring them.
{% endhint %}

## Get key usage

Returns the total spend for a key over the requested window.

## GET /v2/usage

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v2/usage":{"get":{"operationId":"_v2_usage","parameters":[{"name":"period","in":"query","required":false,"description":"Relative window: a positive integer followed by `h` or `d`, for example `24h` or `7d`. Provide either `period` or both `start` and `end`, never both.","schema":{"type":"string"}},{"name":"start","in":"query","required":false,"description":"Window start, ISO-8601. A value without a UTC offset is read as UTC. Must be used together with `end`.","schema":{"type":"string"}},{"name":"end","in":"query","required":false,"description":"Window end, ISO-8601. Must not be earlier than `start`, and the window must not exceed 92 days.","schema":{"type":"string"}},{"name":"key_prefix","in":"query","required":false,"description":"Prefix of the key to report on. Omit it to get the spend of the key you are authenticating with. Reporting on a different key requires a management key.","schema":{"type":"string"}}],"responses":{"200":{"description":"Total spend for the key over the requested window.","content":{"application/json":{"schema":{"type":"object","properties":{"api_key_prefix":{"type":"string","nullable":true,"description":"The requested key prefix, or null when it was omitted and the answer is your own key's spend."},"start":{"type":"string","description":"Window start, resolved to UTC."},"end":{"type":"string","description":"Window end, resolved to UTC."},"spend":{"type":"number","description":"Total spend for the key over the window, in USD."},"currency":{"type":"string","description":"Spend currency (always USD)."},"requests":{"type":"integer","description":"Number of charged requests in the window."}},"required":["api_key_prefix","start","end","spend","currency","requests"]}}}}}}}}}
```

## Get detailed key usage

Returns the same total plus a per-model breakdown, sorted by spend.

## GET /v2/usage/detail

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v2/usage/detail":{"get":{"operationId":"_v2_usage_detail","parameters":[{"name":"period","in":"query","required":false,"description":"Relative window: a positive integer followed by `h` or `d`, for example `24h` or `7d`. Provide either `period` or both `start` and `end`, never both.","schema":{"type":"string"}},{"name":"start","in":"query","required":false,"description":"Window start, ISO-8601. A value without a UTC offset is read as UTC. Must be used together with `end`.","schema":{"type":"string"}},{"name":"end","in":"query","required":false,"description":"Window end, ISO-8601. Must not be earlier than `start`, and the window must not exceed 92 days.","schema":{"type":"string"}},{"name":"key_prefix","in":"query","required":false,"description":"Prefix of the key to report on. Omit it to get the spend of the key you are authenticating with. Reporting on a different key requires a management key.","schema":{"type":"string"}},{"name":"group_by","in":"query","required":false,"description":"Add a `groups` array to the response, grouped by `day`, by `model`, or by both (`day,model`). Omit it and the response keeps its original shape. Accepted on `/v2/usage/detail` only: `/v2/usage` returns a flat total with nowhere to put a breakdown and answers 400.","schema":{"type":"string","enum":["day","model","day,model"]}},{"name":"tz","in":"query","required":false,"description":"Time zone that defines the day boundary for `group_by=day`. Must be a canonical IANA zone name matched exactly, for example `Europe/Berlin` or `UTC`. Offset forms (`+05:00`) and other-case spellings (`utc`) are rejected with 400. Defaults to UTC. The top-level `start` and `end` stay UTC regardless.","schema":{"type":"string"}}],"responses":{"200":{"description":"Total spend for the key over the requested window, with a per-model breakdown.","content":{"application/json":{"schema":{"type":"object","properties":{"api_key_prefix":{"type":"string","nullable":true,"description":"The requested key prefix, or null when it was omitted and the answer is your own key's spend."},"start":{"type":"string","description":"Window start, resolved to UTC."},"end":{"type":"string","description":"Window end, resolved to UTC."},"spend":{"type":"number","description":"Total spend for the key over the window, in USD. This is the authoritative total: it is computed from the total, not by adding up models, so it can differ from that sum by a few nano-dollars."},"currency":{"type":"string","description":"Spend currency (always USD)."},"requests":{"type":"integer","description":"Number of charged requests in the window."},"models":{"type":"array","description":"Per-model breakdown, highest spend first.","items":{"type":"object","properties":{"model":{"type":"string","description":"Model name."},"spend":{"type":"number","description":"Spend for this model, in USD."},"requests":{"type":"integer","description":"Charged requests for this model."}},"required":["model","spend","requests"]}},"groups":{"type":"array","description":"Present only when `group_by` is supplied. One entry per group, carrying spend, tokens and request counts. Reconcile the top-level `requests` against `requests.charged`, never against `requests.total`.","items":{"type":"object","properties":{"day":{"type":"string","description":"Present when grouping by day. The day boundary follows `tz`, defaulting to UTC."},"model":{"type":"string","description":"Present when grouping by model."},"spend":{"type":"number","description":"Spend for this group, in USD."},"tokens":{"type":"object","description":"Token counts for this group.","properties":{"input":{"type":"integer"},"output":{"type":"integer"},"total":{"type":"integer"}},"required":["input","output","total"]},"requests":{"type":"object","description":"Request counts for this group. `total` counts every inference; `charged` counts only the billed ones. Failed inferences are billed nothing, so they appear in `total` and `failed` but not in `charged`.","properties":{"total":{"type":"integer"},"charged":{"type":"integer"},"succeeded":{"type":"integer"},"failed":{"type":"integer"}},"required":["total","charged","succeeded","failed"]}},"required":["spend","tokens","requests"]}}},"required":["api_key_prefix","start","end","spend","currency","requests","models"]}}}}}}}}}
```

{% hint style="info" %}
Need the individual requests rather than totals — what failed, what a specific call cost, which of your own customers it belonged to? See [Usage Logs](/api-references/service-endpoints/usage-logs).
{% endhint %}


# Usage Logs

GET /v2/logs returns one row per request with cost, tokens, status and ids for tracing.

<table data-header-hidden data-full-width="true"><thead><tr><th width="220" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><a href="#get-request-logs">Get request logs</a></td><td valign="top"><mark style="color:$success;"><strong><code>GET</code></strong></mark> <code>https://api.aimlapi.com/v2/logs</code></td></tr></tbody></table>

`GET /v2/logs` returns **one row per request** — what it cost, how many tokens it used, whether it succeeded, and the [ids you need to tie it back to your own systems](/capabilities/request-tracing-and-cost).\
The time window and key-selection rules are identical to [API Key Usage](/api-references/service-endpoints/api-key-usage); use that endpoint when you want totals rather than individual requests.

{% hint style="warning" %}
The `model` and `status` filters do **not** split on commas — repeat the parameter instead (`?status=succeeded&status=failed`). `?model=a,b` is read as one model literally named `a,b`, so it matches nothing and you get an empty page rather than an error.
{% endhint %}

{% hint style="info" %}
Unlike `/v2/usage`, this endpoint lists **failed requests too**, with a zero `cost`. A failed request is billed nothing — the hold is rolled back — so it never appears in the usage totals. That is why a row count here can exceed the `requests` figure `/v2/usage` reports for the same window.
{% endhint %}

### Get request logs

Returns the requests made in the window, with cost, tokens and correlation ids.

## GET /v2/logs

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v2/logs":{"get":{"operationId":"_v2_logs","parameters":[{"name":"period","in":"query","required":false,"description":"Relative window: a positive integer followed by `h` or `d`, for example `24h` or `7d`. Provide either `period` or both `start` and `end`, never both.","schema":{"type":"string"}},{"name":"start","in":"query","required":false,"description":"Window start, ISO-8601. A value without a UTC offset is read as UTC. Must be used together with `end`.","schema":{"type":"string"}},{"name":"end","in":"query","required":false,"description":"Window end, ISO-8601. Must not be earlier than `start`, and the window must not exceed 92 days.","schema":{"type":"string"}},{"name":"key_prefix","in":"query","required":false,"description":"Prefix of the key to report on. Omit it to list the requests made with the key you are authenticating with. Listing the requests of a different key requires a management key.","schema":{"type":"string"}},{"name":"model","in":"query","required":false,"description":"Keep only requests made to this model. Accepts `source/alias` (`openai/gpt-5`) or a bare alias (`gpt-5`), matched exactly. Repeat the parameter once per model to pass several, up to 50 values; a comma-separated list is read as one long name and matches nothing.","schema":{"type":"string"}},{"name":"status","in":"query","required":false,"description":"Keep only requests with this outcome. Repeat the parameter to accept both (`?status=succeeded&status=failed`); a comma-separated value is not a valid status and returns 400.","schema":{"type":"string","enum":["succeeded","failed"]}},{"name":"limit","in":"query","required":false,"description":"Rows per page, 1-100.","schema":{"type":"integer","default":50,"minimum":1,"maximum":100}},{"name":"offset","in":"query","required":false,"description":"Rows to skip before the page starts.","schema":{"type":"integer","default":0,"minimum":0}}],"responses":{"200":{"description":"One row per request made in the window, newest first.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","description":"The requested page of request rows.","items":{"type":"object","properties":{"created":{"type":"string","description":"When the request was made, in UTC."},"status":{"type":"string","enum":["succeeded","failed"],"description":"Outcome of the request. A failed request is billed nothing, so its cost is zero."},"origin":{"type":"string","enum":["api","playground"],"description":"Where the request came from."},"model":{"type":"string","description":"Model the request was made to, as `source/alias`."},"cost":{"type":"object","description":"What the request was charged.","properties":{"usd":{"type":"number"},"credits":{"type":"integer"}},"required":["usd","credits"]},"tokens":{"type":"object","description":"Token counts for the request. Zero for models that are not billed per token.","properties":{"input":{"type":"integer"},"output":{"type":"integer"},"total":{"type":"integer"}},"required":["input","output","total"]},"request_id":{"type":"string","nullable":true,"description":"Identifier of the individual HTTP call."},"inference_id":{"type":"string","description":"Identifier of the inference. This is the value returned in the `x-inference-id` response header, and the `reference_id` of the matching charge in `GET /v2/billing/transactions`."},"client_request_id":{"type":"string","nullable":true,"description":"The `X-Client-Request-Id` you sent with the request. Null when you sent none, and on rows recorded before this field existed."}},"required":["created","status","origin","model","cost","tokens","request_id","inference_id","client_request_id"]}},"pagination":{"type":"object","properties":{"limit":{"type":"integer"},"offset":{"type":"integer"},"total":{"type":"integer","description":"Total rows matching the query across all pages."},"has_more":{"type":"boolean","description":"Whether another page follows this one."}},"required":["limit","offset","total","has_more"]}},"required":["data","pagination"]}}}}}}}}}
```

***

### Errors

| Code  | When                                                                                                                     |
| ----- | ------------------------------------------------------------------------------------------------------------------------ |
| `400` | Neither `period` nor `start`+`end`, or both; a malformed date or period; `end` earlier than `start`; window over 92 days |
| `401` | Missing or invalid key                                                                                                   |
| `403` | A regular key naming another key's prefix                                                                                |
| `404` | The prefix is not yours, or is outside your key's scopes                                                                 |
| `429` | Over 200 requests per 60 seconds                                                                                         |

{% hint style="info" %}
These figures come from the analytics pipeline and are meant for **attribution and budgeting**. For the account ledger — what actually moved your balance, including top-ups — use [`GET /v2/billing/transactions`](/api-references/service-endpoints/account-balance#get-account-transactions).
{% endhint %}


# Complete Model List

GET /v1/models, no key needed: every model you can call now, with ids, aliases, endpoint types and request schemas; add include=pricing for prices.

<table data-header-hidden data-full-width="true"><thead><tr><th width="220" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><a href="#get-the-model-catalogue">Get the model catalogue</a></td><td valign="top"><mark style="color:$success;"><strong><code>GET</code></strong></mark> <code>https://api.aimlapi.com/v1/models</code></td></tr><tr><td valign="top"><a href="#looking-up-one-model">Look up one model</a></td><td valign="top"><mark style="color:$success;"><strong><code>GET</code></strong></mark> <code>https://api.aimlapi.com/model/{id}</code></td></tr></tbody></table>

`GET /v1/models` returns the live model catalogue — the machine-readable source for which models exist, what they are called, what they can do, and what they cost. Use it instead of scraping the model pages.\
No API key is required for this request. You can also simply open [this list](https://api.aimlapi.com/v1/models) in any web browser.

As of early 2026 the catalogue holds more than 400 models. By default each entry carries only its identity — pricing, modalities and capabilities are opt-in, so the default response stays small.

{% hint style="info" %}
`https://api.aimlapi.com/models` and `https://api.aimlapi.com/api/v1/models` serve exactly the same data. `/v1/models` is the canonical path and the one to use in new integrations — an OpenAI-compatible client configured with a base URL of `https://api.aimlapi.com/v1` reaches it by appending `/models`.
{% endhint %}

## Get the model catalogue

Returns the models matching the given filters, with the requested optional sections attached.

## GET /v1/models

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v1/models":{"get":{"operationId":"ModelsController_getModels_v1","parameters":[{"name":"include","in":"query","required":false,"description":"Attach optional sections to each model: `pricing`, `modalities`, `capabilities`, or `all` for every section. Comma-separated and repeated values are both accepted. Unknown values are ignored rather than rejected.","schema":{"type":"string"}},{"name":"details","in":"query","required":false,"description":"Shorthand for `include=all`.","schema":{"type":"string","enum":["true","1"]}},{"name":"id","in":"query","required":false,"description":"Keep models matching this id, or carrying it as an alias. Comma-separated or repeated values are combined with OR.","schema":{"type":"string"}},{"name":"type","in":"query","required":false,"description":"Keep models served through this endpoint type, for example `openai/chat-completions`.","schema":{"type":"string"}},{"name":"tags","in":"query","required":false,"description":"Keep models carrying this tag, for example `playground:video`. Comma-separated or repeated values are combined with OR.","schema":{"type":"string"}},{"name":"modalities","in":"query","required":false,"description":"Keep models with this modality among either their input or output modalities.","schema":{"type":"string"}},{"name":"input_modalities","in":"query","required":false,"description":"Keep models accepting this input modality.","schema":{"type":"string"}},{"name":"output_modalities","in":"query","required":false,"description":"Keep models producing this output modality.","schema":{"type":"string"}},{"name":"capabilities","in":"query","required":false,"description":"Keep models declaring this capability, for example `image_to_video`. Comma-separated or repeated values are combined with OR; combining with other filter parameters is AND.","schema":{"type":"string"}}],"responses":{"200":{"description":"The live model catalogue, filtered and expanded as requested. Responses carry an ETag.","content":{"application/json":{"schema":{"type":"object","properties":{"object":{"type":"string","description":"Always \"list\"."},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","description":"Canonical unique identifier of the model."},"aliases":{"type":"array","description":"Other names this model can still be requested under.","items":{"type":"string"}},"type":{"type":"string","description":"Endpoint type this model is served through."},"info":{"type":"object","description":"Model identity. Which keys are present varies by model type: context and output limits appear on text models, not on image or video ones.","properties":{"name":{"type":"string","description":"Human-readable model name."},"developer":{"type":"string","description":"Organization or company that developed the model."},"description":{"type":"string","description":"Short description of the model and its primary capabilities."},"releasedAt":{"type":"string","description":"Release date of the model."},"contextLength":{"type":"integer","description":"Maximum supported context window size in tokens. Text models only."},"outputMax":{"type":"integer","description":"Maximum number of tokens that can be generated in a single response. Text models only."},"cutoffAt":{"type":"string","description":"Training data cutoff date, where the developer publishes one."},"url":{"type":"string","description":"Public model landing page on the AIML API website. May be an empty string."},"docsUrl":{"type":"string","description":"Link to this model's page in the documentation portal."},"docsJson":{"type":"string","description":"Machine-readable OpenAPI description of this model's endpoint."}},"required":["name","developer"]},"tags":{"type":"array","description":"Free-form tags, for example `playground:chat` or `tier:tier_2`.","items":{"type":"string"}},"modalities":{"type":"object","description":"Present only with `?include=modalities` or `all`. Input and output modalities the model handles.","properties":{"input":{"type":"array","items":{"type":"string"}},"output":{"type":"array","items":{"type":"string"}}}},"capabilities":{"type":"array","description":"Present only with `?include=capabilities` or `all`. Declared capabilities.","items":{"type":"string"}},"pricing":{"type":"object","description":"Present only with `?include=pricing` or `all`. Read `kind` first: `fixed` quotes one rate per unit, `variants` quotes a rate per parameter combination, `variable` cannot be quoted ahead of the request.","properties":{"kind":{"type":"string","enum":["fixed","variants","variable"]},"currency":{"type":"string"},"units":{"type":"array","description":"Rates for a `fixed` price. Always read `price` together with `per`.","items":{"type":"object"}},"dimensions":{"type":"array","description":"Request parameters the rate depends on, for a `variants` price.","items":{"type":"string"}},"variants":{"type":"array","description":"One quoted rate per parameter combination, for a `variants` price.","items":{"type":"object"}}}}},"required":["id","aliases","type","info","tags"]}}},"required":["object","data"]}}}}}}}}}
```

## Asking for more per model

`include` attaches optional sections to each model — `pricing`, `modalities`, `capabilities`, or `all` (`?details=true` is a synonym for every section). Combine them freely, comma-separated. Unknown values are ignored rather than rejected, so a typo returns a valid response with that section missing.

```bash
curl 'https://api.aimlapi.com/v1/models?include=pricing,capabilities'

# what one specific model costs — a few kilobytes instead of the whole catalogue
curl 'https://api.aimlapi.com/v1/models?id=deepgram/aura-2&include=pricing'
```

## Filtering

Filters narrow *which models* come back, and are independent of `include` — you can filter on capabilities without asking for the capabilities section.

* **Several values, one parameter — OR.** `?capabilities=text_to_video,image_to_video` returns models that do either.
* **Several parameters — AND.** `?output_modalities=video&capabilities=audio_generation` returns models that do both.
* Values are **case-insensitive**, and may be given comma-separated (`?tags=a,b`) or repeated (`?tags=a&tags=b`). Both forms merge.
* `id` matches **an id or an alias**. An omitted parameter filters nothing.

```bash
# every model that turns an image into video
curl 'https://api.aimlapi.com/v1/models?capabilities=image_to_video'
```

## Looking up one model

`GET /model/{id}` returns a single model in the same projection, wrapped as `{"object": "model", "data": {…}}` instead of a list. It takes the same `include` and `details` parameters.

```bash
curl 'https://api.aimlapi.com/model/openai/gpt-4o?include=pricing'
```

Model ids containing slashes go into the path as they are — no escaping. The lookup matches aliases as well as ids, is case-insensitive, and returns `404` for a name that matches neither.

{% hint style="info" %}
Note the two differences from the catalogue route. The path is singular — `/model/`, not `/models/` — and it is **not** registered under `/v1`.

`GET /v1/models?id=openai/gpt-4o` answers the same question and stays on the catalogue route. Use whichever fits: the filter returns a list, possibly empty; the lookup returns one model or a `404`.
{% endhint %}

## Output examples by model type

Each item represents a single model. The `info` block is the part that varies by category — context and output limits are meaningful for a text model and absent from an image or video one — while `id`, `aliases`, `type` and `tags` are always present.

#### Example output item for a chat model

{% code overflow="wrap" %}

```json
{
  "id": "openai/gpt-4o",
  "info": {
    "releasedAt": "2025-08-07",
    "name": "GPT-4o",
    "developer": "Open AI",
    "description": "Multimodal AI model by OpenAI enhancing human-computer interaction.",
    "contextLength": 128000,
    "outputMax": 16384,
    "cutoffAt": "2023-10-01",
    "url": "https://aimlapi.com/models/gpt-4o-2024-08-06-api",
    "docsUrl": "https://docs.aimlapi.com/api-references/text-models-llm/openai/gpt-4o",
    "docsJson": "https://api.aimlapi.com/docs-json?model=openai%2Fgpt-4o&endpoint=openai%2Fchat-completions"
  },
  "type": "openai/chat-completions",
  "aliases": ["gpt-4o"],
  "tags": ["playground:chat", "tier:tier_2"]
}
```

{% endcode %}

#### Example output item for an image model

{% code overflow="wrap" %}

```json
{
  "id": "openai/gpt-image-1",
  "info": {
    "releasedAt": "2025-10-13",
    "name": "GPT Image 1",
    "developer": "Open AI",
    "description": "GPT Image 1 is OpenAI's first-generation image generation model combining language understanding with visual synthesis.",
    "url": "",
    "docsUrl": "https://docs.aimlapi.com/api-references/image-models/openai/gpt-image-1",
    "docsJson": "https://api.aimlapi.com/docs-json?model=openai%2Fgpt-image-1&endpoint=openai%2Fimage-generations"
  },
  "type": "openai/image-generations",
  "aliases": ["gpt-image-1"],
  "tags": ["playground:image", "tier:tier_2"]
}
```

{% endcode %}

#### Example output item for a video model

{% code overflow="wrap" %}

```json
{
  "id": "google/veo-2.0-generate-001",
  "info": {
    "releasedAt": "2025-11-25",
    "name": "Veo 2 Text-to-Video",
    "developer": "Google",
    "description": "Veo2: Google's advanced text-to-video model",
    "url": "https://aimlapi.com/models/veo-2-text-to-video-api",
    "docsUrl": "https://docs.aimlapi.com/api-references/video-models/google/veo2-text-to-video",
    "docsJson": "https://api.aimlapi.com/docs-json?model=google%2Fveo-2.0-generate-001&endpoint=internal%2Fvideo-generations%2Fsubmit"
  },
  "type": "internal/video-generations/submit",
  "aliases": ["veo-2.0-generate-001"],
  "tags": ["playground:video", "tier:tier_2"]
}
```

{% endcode %}

#### What `include` adds

Asking for the optional sections attaches them to the same item:

{% code overflow="wrap" %}

```json
{
  "id": "openai/gpt-4o",
  "modalities": { "input": ["image", "text"], "output": ["text"] },
  "capabilities": [
    "file_input",
    "parallel_tool_calls",
    "streaming",
    "structured_output",
    "tools",
    "vision"
  ],
  "pricing": {
    "kind": "fixed",
    "currency": "USD",
    "units": [
      { "name": "token", "measure": "output", "price": 3.25, "per": 1000000 }
    ]
  }
}
```

{% endcode %}

## Checking whether a model is still available

{% hint style="warning" %}
Match against **`id` and `aliases` together**, not `id` alone. A model may be published under a canonical id while the name you integrated against lives on as an alias — the alias keeps working, but it is not the `id` any more, so an `id`-only comparison reports a live model as gone.
{% endhint %}

{% code overflow="wrap" %}

```js
const res = await fetch('https://api.aimlapi.com/v1/models');
const { data } = await res.json();

const byName = new Map();
for (const model of data) {
  byName.set(model.id, model.id);
  for (const alias of model.aliases ?? []) byName.set(alias, model.id);
}

const canonical = byName.get(myModelId); // undefined ⇒ not in the catalogue
```

{% endcode %}

The same map de-duplicates your list: two names resolving to one canonical id are one model, not two.

{% hint style="info" %}
A name missing from this map is not necessarily a model that went away — it may also be one that never existed here. [`GET /v1/models/deprecations`](/api-references/service-endpoints/model-deprecations) tells the two apart, and names the id to migrate to where there is one.
{% endhint %}

## Reading prices

With `?include=pricing`, each model carries a `pricing` block. Read `kind` first — it decides how the rest is shaped.

{% hint style="warning" %}
Always read `per` together with `price`. `price` is the charge for `per` units, and `per` is not the same across models — `1000000` for most token rates, `1000` for some, `1` for per-second and per-megapixel rates. Comparing bare `price` values across models compares different bases and will be wrong by orders of magnitude.
{% endhint %}

```json
{
  "kind": "variants",
  "dimensions": ["resolution"],
  "variants": [
    { "when": { "resolution": "720p" },  "price": 0.39, "unit": "second", "per": 1 },
    { "when": { "resolution": "1080p" }, "price": 0.65, "unit": "second", "per": 1 }
  ]
}
```

Here a 5-second 1080p generation costs `0.65 × 5 = $3.25`. Prices are in USD and are what you are charged.

A model that can run in the [Batch API](/capabilities/batch-processing) also carries `pricing.batch`: its own `units` and `thresholds`, the price of the same model in a batch. A model without `pricing.batch` cannot run in a batch.

## Caching

Responses carry an `ETag`. Send it back as `If-None-Match` and you get `304 Not Modified` with an empty body when nothing changed:

```bash
curl -I 'https://api.aimlapi.com/v1/models?include=pricing'
# etag: W/"1440a0-uH6NONsG/9An5njw3kqMcYY5k8w"

curl -H 'If-None-Match: W/"1440a0-uH6NONsG/9An5njw3kqMcYY5k8w"' \
     'https://api.aimlapi.com/v1/models?include=pricing'
# 304
```

{% hint style="info" %}
The ETag covers the whole response, so it changes on any catalogue edit — a new model or a reworded description, not only a price change. Treat it as "something moved, re-read and diff", not as a price-change feed.
{% endhint %}


# Model Deprecations

GET /v1/models/deprecations, no key needed: models that are retiring, withdrawn (404) or folded into another id, with dates and the replacement id.

<table data-header-hidden data-full-width="true"><thead><tr><th width="220" valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top"><a href="#get-the-deprecation-feed">Get the deprecation feed</a></td><td valign="top"><mark style="color:$success;"><strong><code>GET</code></strong></mark> <code>https://api.aimlapi.com/v1/models/deprecations</code></td></tr></tbody></table>

`GET /v1/models/deprecations` lists the models that are retiring, have already been withdrawn, or were folded into another model — with the date it happened and the id to move to.\
No API key is required for this request. You can also open [the feed](https://api.aimlapi.com/v1/models/deprecations) directly in a browser.

It exists to answer the one question [`GET /v1/models`](/api-references/service-endpoints/complete-model-list) structurally cannot. A model missing from the catalogue may have been withdrawn, may have been folded into another id that still works, or may never have existed — and the catalogue returns the same "not here" for all three. Treating them alike is how a model-sync job ends up disabling models that are still serving.

{% hint style="info" %}
`https://api.aimlapi.com/models/deprecations` and `https://api.aimlapi.com/api/v1/models/deprecations` serve exactly the same data, as does `deprecated` in place of `deprecations` on any of the three. `/v1/models/deprecations` is the canonical path and the one to use in new integrations.
{% endhint %}

### Get the deprecation feed

Returns the deprecation entries matching the given filters, newest first.

## GET /v1/models/deprecations

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v1/models/deprecations":{"get":{"operationId":"_v1_models_deprecations","parameters":[{"name":"status","in":"query","required":false,"description":"Keep only entries in these states: `deprecated`, `superseded` or `withdrawn`. Values are case-insensitive and may be comma-separated (`?status=superseded,withdrawn`) or repeated (`?status=superseded&status=withdrawn`). Unknown values are ignored rather than rejected — a parameter holding no recognised value filters nothing and returns the whole feed.","schema":{"type":"string"}},{"name":"since","in":"query","required":false,"description":"Keep only entries whose `deprecated_at` or `shutdown_at` falls on or after this date. Plain `YYYY-MM-DD`, no time part. Entries carrying neither date are dropped, because there is nothing to compare against. A malformed value is ignored rather than rejected, so a broken poll returns the whole feed instead of a 400.","schema":{"type":"string"}}],"responses":{"200":{"description":"The deprecation feed, newest first.","content":{"application/json":{"schema":{"type":"object","properties":{"object":{"type":"string","description":"Always `list`."},"generated_at":{"type":"string","description":"When this response was built, in UTC. It moves on every call and is deliberately excluded from the ETag."},"data":{"type":"array","description":"One entry per model, ordered newest-first by the most recent date the entry carries (`shutdown_at`, else `deprecated_at`), then by `id`. A model published under several endpoint types still appears once.","items":{"type":"object","properties":{"id":{"type":"string","description":"The canonical public id the model was reachable under."},"aliases":{"type":"array","description":"Every other public id that used to reach it. Match your integrated model name against `id` and `aliases` together.","items":{"type":"string"}},"status":{"type":"string","description":"`deprecated` — still serving, retirement announced. `superseded` — folded into another model, the id still resolves. `withdrawn` — gone, requests return 404.","enum":["deprecated","superseded","withdrawn"]},"deprecated_at":{"type":"string","nullable":true,"description":"ISO date the retirement was announced, or the date we learned of it when the provider gave no notice. `null` when unknown."},"shutdown_at":{"type":"string","nullable":true,"description":"ISO date the model stopped, or is scheduled to stop, serving. Always `null` for `superseded` — those never stop — and `null` for a `deprecated` model whose provider has named no date yet."},"replaced_by":{"type":"string","nullable":true,"description":"Canonical id that supersedes this one, where one exists. For a `superseded` entry this is the model the old id now resolves to. `null` when there is no successor."},"reason":{"type":"string","nullable":true,"description":"`provider_delisted` — the model developer stopped serving it. `consolidated` — several ids were folded into one family model. `unknown` — no reason recorded. `null` on an entry read from a live model card.","enum":["provider_delisted","consolidated","unknown"]}},"required":["id","aliases","status","deprecated_at","shutdown_at","replaced_by","reason"]}}},"required":["object","generated_at","data"]}}}},"304":{"description":"Not Modified — the ETag you sent as If-None-Match still matches. Empty body."}}}}}}
```

***

## The three states

`status` is the field to branch on, and the difference between the three is what your integration should do next.

| `status`     | Does the id still work?                             | What to do                                                         |
| ------------ | --------------------------------------------------- | ------------------------------------------------------------------ |
| `deprecated` | **Yes** — still serving, retirement announced       | Plan the migration before `shutdown_at`. Nothing breaks today.     |
| `superseded` | **Yes** — folded into another model, still resolves | Nothing is broken. Switch to `replaced_by` when convenient.        |
| `withdrawn`  | **No** — requests return `404`                      | Switch to `replaced_by`, or pick a replacement from the catalogue. |

{% hint style="warning" %}
`superseded` is not a soft `withdrawn`. The id still resolves — it lives on as an alias of `replaced_by` — and `shutdown_at` is always `null` for these entries. Conflating the two is exactly the false positive this feed exists to prevent.

```bash
# a superseded id, resolved by the catalogue to the model it was folded into
curl 'https://api.aimlapi.com/v1/models?id=aura-2-zeus-en'
# -> {"object":"list","data":[{"id":"deepgram/aura-2", ...}]}
```

{% endhint %}

A `deprecated` model is read from its live model card, so it announces its own sunset while it still works. Once a real retirement date is set, it is dropped from `GET /v1/models` — but it keeps serving, and [`GET /model/{id}`](/api-references/service-endpoints/complete-model-list#looking-up-one-model) still returns its card with the sunset dates attached. The other two states come from a durable record instead: a withdrawn model has no card left to read.

## Response shape

```json
{
  "object": "list",
  "generated_at": "2026-08-24T13:59:21.643Z",
  "data": [
    {
      "id": "openai/gpt-5.3-chat",
      "aliases": ["gpt-5.3-chat"],
      "status": "withdrawn",
      "deprecated_at": "2026-08-10",
      "shutdown_at": "2026-08-10",
      "replaced_by": "openai/gpt-5.3-codex",
      "reason": "provider_delisted"
    },
    {
      "id": "aura-2-zeus-en",
      "aliases": ["deepgram/aura-2-zeus-en", "#g1_aura-2-zeus-en"],
      "status": "superseded",
      "deprecated_at": "2026-06-26",
      "shutdown_at": null,
      "replaced_by": "deepgram/aura-2",
      "reason": "consolidated"
    }
  ]
}
```

Dates are plain `YYYY-MM-DD`. `deprecated_at` is the date the provider announced the retirement, or the date we learned of it when they gave no notice; `shutdown_at` is the date it stopped, or will stop, serving. `reason` is `provider_delisted`, `consolidated` or `unknown` — and `null` on an entry read from a live model card.

Entries are ordered newest-first by the most recent date they carry, then by `id`. A model published under several endpoint types appears once: the sunset belongs to the model, not to the route.

{% hint style="warning" %}
Match your integrated model name against **`id` and `aliases` together**, never `id` alone. The name you originally integrated against is often the alias rather than the canonical id, and an `id`-only comparison will miss the entry that explains what happened to it.
{% endhint %}

## Filtering

Both filters are optional, and both fail open: an unrecognised value is ignored rather than rejected. This is a discovery surface, and a typo in a polling job should not turn every poll into a `400`.

* **`status`** — case-insensitive, comma-separated (`?status=superseded,withdrawn`) or repeated (`?status=superseded&status=withdrawn`). A parameter holding no recognised value filters nothing and returns the whole feed.
* **`since`** — plain `YYYY-MM-DD`, no time part. Keeps entries whose `deprecated_at` **or** `shutdown_at` falls on or after that date. Entries carrying neither date are dropped, because there is nothing to compare against.

```bash
# what has been withdrawn since the start of the month
curl 'https://api.aimlapi.com/v1/models/deprecations?status=withdrawn&since=2026-08-01'

# everything still serving with a retirement already announced
curl 'https://api.aimlapi.com/v1/models/deprecations?status=deprecated'
```

## Polling and caching

Responses carry a weak `ETag` and `Cache-Control: public, max-age=300`. Send the tag back as `If-None-Match` and you get `304 Not Modified` with an empty body when nothing changed:

```bash
curl -I 'https://api.aimlapi.com/v1/models/deprecations'
# etag: W/"-1EFj0Jxxt7B2mx5LT-MXoCShLk"

curl -H 'If-None-Match: W/"-1EFj0Jxxt7B2mx5LT-MXoCShLk"' \
     'https://api.aimlapi.com/v1/models/deprecations'
# 304
```

{% hint style="info" %}
The tag is computed over `data` only. `generated_at` changes on every call, so including it would make every poll a cache miss — the tag moves only when the feed's contents actually move. Polling daily is plenty; the payload is small and changes rarely.
{% endhint %}

## Keeping an integration in sync

The feed and the catalogue answer different halves of the same question, so read both. The catalogue says what you can use today; the feed explains anything the catalogue no longer lists.

{% code overflow="wrap" %}

```js
const [catalogue, feed] = await Promise.all([
  fetch('https://api.aimlapi.com/v1/models').then((r) => r.json()),
  fetch('https://api.aimlapi.com/v1/models/deprecations').then((r) => r.json()),
]);

// every live name -> its canonical id
const live = new Map();
for (const model of catalogue.data) {
  live.set(model.id, model.id);
  for (const alias of model.aliases ?? []) live.set(alias, model.id);
}

// every retired name -> the entry explaining it
const retired = new Map();
for (const entry of feed.data) {
  retired.set(entry.id, entry);
  for (const alias of entry.aliases ?? []) retired.set(alias, entry);
}

function check(modelId) {
  const entry = retired.get(modelId);

  if (entry?.status === 'withdrawn') {
    return { ok: false, migrateTo: entry.replaced_by }; // 404s now — must move
  }
  if (entry) {
    // deprecated or superseded: still serving, migrate on your own schedule
    return { ok: true, migrateTo: entry.replaced_by, by: entry.shutdown_at };
  }
  if (live.has(modelId)) {
    return { ok: true }; // healthy
  }
  return { ok: false, migrateTo: null }; // unknown name — check for a typo
}
```

{% endcode %}

The last branch is the one worth keeping separate. A name in neither list was never a model id here, which is a different problem from a model that went away — and it is the case a catalogue-only check silently reports as a deprecation.

{% hint style="info" %}
Looking for a replacement by hand rather than in code? [All Model IDs](/api-references/model-database) lists the current catalogue alongside its [deprecated models](/api-references/model-database#deprecated-no-longer-supported-models) section.
{% endhint %}


# All Model IDs

A full list of available models.

{% hint style="info" %}
If you need to select models based on specific parameters for your task, visit the [dedicated page on our official website](https://aimlapi.com/models/), which offers convenient filtering options. On the selected model’s page, you can find detailed technical and commercial information.
{% endhint %}

{% hint style="success" %}
To fetch the complete model list via the API, see [the API reference](/api-references/service-endpoints/complete-model-list) for the relevant service endpoint.
{% endhint %}

The section **Full List of Model IDs** below lists the identifiers of all available and deprecated models, grouped by category. These IDs are used to specify the exact models in your code, like this:

<figure><img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-c8f02b4738bc2873d0edfe070cf6d4c30e0d2bb5%2Fmodel_ID.png?alt=media" alt="" width="442"><figcaption></figcaption></figure>

If you already know the model ID, use the page search function (<kbd>Ctrl+F</kbd> for Win/Linux, <kbd>Command+F</kbd> for Mac) to locate it. The hyperlink will take you directly to the model's API Reference page.

{% hint style="success" %}
**New Model Request**

Can't find the model you need? Join our [Discord community](https://discord.gg/8CwhkUuCR6) to propose new models for integration into our API offerings. Your contributions help us grow and serve you better.
{% endhint %}

## Full List of Model IDs

### Text Models (LLM)

<table data-header-hidden="false" data-header-sticky data-full-width="true"><thead><tr><th width="297.4000244140625">Model ID + API Reference link</th><th width="134.20001220703125">Developer</th><th width="105.79998779296875">Context</th><th>Model Card</th></tr></thead><tbody><tr><td><a href="/api-references/text-models-llm/openai/gpt-4o">gpt-4o-2024-08-06</a></td><td>Open AI</td><td>128,000</td><td><a href="https://aimlapi.com/models/gpt-4o-2024-08-06-api">GPT-4o-2024-08-06</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-4o">gpt-4o-2024-05-13</a></td><td>Open AI</td><td>128,000</td><td><a href="https://aimlapi.com/models/gpt-4o-2024-05-13-api">GPT-4o-2024-05-13</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-4o-mini">gpt-4o-mini</a></td><td>Open AI</td><td>128,000</td><td><a href="https://aimlapi.com/models/chat-gpt-4o-mini">Chat GPT 4o mini</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-4o-mini">gpt-4o-mini-2024-07-18</a></td><td>Open AI</td><td>128,000</td><td><a href="https://aimlapi.com/models/chat-gpt-4o-mini">GPT 4o mini</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/o3">openai/o3-2025-04-16</a></td><td>Open AI</td><td>200,000</td><td><a href="https://aimlapi.com/models/o3">o3</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/o3-pro">openai/o3-pro</a></td><td>Open AI</td><td>200,000</td><td><a href="https://aimlapi.com/models/o3-pro">o3-pro</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-4.1">openai/gpt-4.1-2025-04-14</a></td><td>Open AI</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gpt-4-1">GPT-4.1</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-4.1-mini">openai/gpt-4.1-mini-2025-04-14</a></td><td>Open AI</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gpt-4-1-mini-api">GPT-4.1 Mini</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-oss-20b">openai/gpt-oss-20b</a></td><td>Open AI</td><td>128,000</td><td><a href="https://aimlapi.com/models/gpt-oss-20b">GPT OSS 20B</a></td></tr><tr><td><a href="/api-references/text-models-llm/tencent/hy3">tencent/hy3</a></td><td>Tencent</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/inclusionai/ling-3.0-flash-vl-free">inclusionai/ling-3.0-flash-vl</a></td><td>inclusionAI</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/liquidai/lfm-2.5-24b-a2b">liquid/lfm-2.5-24b-a2b</a></td><td>LiquidAI</td><td>128,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/inclusionai/ling-3.0-flash-free">inclusionai/ling-3.0-flash</a></td><td>inclusionAI</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.8-27b">alibaba/qwen3.8-27b</a></td><td>Alibaba Cloud</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/motif-technologies/motif-3">motif-technologies/motif-3</a></td><td>Motif Technologies</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/deepseek-ai/deepseek-v4-pro-0813">deepseek/deepseek-v4-pro-0813</a></td><td>DeepSeek AI</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/deepseek-ai/deepseek-v4-flash-vision-exp">deepseek/deepseek-v4-flash-vision-exp</a></td><td>DeepSeek AI</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/stepfun/step-5-preview">stepfun/step-5-preview</a></td><td>StepFun</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/xiaomi/mimo-v2.6-flash">xiaomi/mimo-v2.6-flash</a></td><td>Xiaomi</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/xiaomi/mimo-v2.6-pro">xiaomi/mimo-v2.6-pro</a></td><td>Xiaomi</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/meta/muse-spark-open">meta/muse-spark-open</a></td><td>Meta</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/upstage/solar-mini4">upstage/solar-mini4</a></td><td>Upstage</td><td>524,288</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/perceptron/perceptron-mk1.5">perceptron/perceptron-mk1.5</a></td><td>Perceptron</td><td>36,864</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/xiaomi/mimo-v2.6-pro-ultraspeed">xiaomi/mimo-v2.6-pro-ultraspeed</a></td><td>Xiaomi</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/deepseek-ai/deepseek-flash">deepseek/deepseek-v4.1-flash</a></td><td>DeepSeek AI</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/thinking-machines/inkling">thinkingmachines/inkling</a></td><td>Thinking Machines</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/meta/muse-glimmer-30b">meta/muse-glimmer-30b</a></td><td>Meta</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/thinking-machines/inkling-small">thinkingmachines/inkling-small</a></td><td>Thinking Machines</td><td>524,288</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/nvidia/nemotron-3.5-content-safety">nvidia/nemotron-3.5-content-safety</a></td><td>Nvidia</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-oss-120b">openai/gpt-oss-120b</a></td><td>Open AI</td><td>128,000</td><td><a href="https://aimlapi.com/models/gpt-oss-120b">GPT OSS 120B</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-latest">openai/gpt-latest</a></td><td>Open AI</td><td>400,000</td><td><a href="https://aimlapi.com/models/gpt-latest">GPT Latest</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-mini-latest">openai/gpt-mini-latest</a></td><td>Open AI</td><td>400,000</td><td><a href="https://aimlapi.com/models/gpt-mini-latest">GPT Mini Latest</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5.6-luna">openai/gpt-5.6-luna</a></td><td>Open AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5.6-luna-pro">openai/gpt-5.6-luna-pro</a></td><td>Open AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-6.1-terra-pro">openai/gpt-6.1-terra-pro</a></td><td>Open AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/moonshot/kimi-k3.1-pro">moonshot/kimi-k3-1-pro</a></td><td>Moonshot</td><td>1,048,576</td><td><a href="https://www.kimi.ai/blog/kimi-k3-1-pro">Kimi K3.1 Pro</a></td></tr><tr><td><a href="/api-references/text-models-llm/moonshot/kimi-k3.1-pro-highspeed">moonshot/kimi-k3-1-pro-highspeed</a></td><td>Moonshot</td><td>1,048,576</td><td><a href="https://www.kimi.ai/blog/kimi-k3-1-pro">Kimi K3.1 Pro Highspeed</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-6.1-sol">openai/gpt-6.1-sol</a></td><td>Open AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-6-sol">openai/gpt-6-sol</a></td><td>Open AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-6-luna">openai/gpt-6-luna</a></td><td>Open AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-6-astra">openai/gpt-6-astra</a></td><td>Open AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5.6-terra-pro">openai/gpt-5.6-terra-pro</a></td><td>Open AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5.6-terra">openai/gpt-5.6-terra</a></td><td>Open AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5.6-sol-pro">openai/gpt-5.6-sol-pro</a></td><td>Open AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5.6-sol">openai/gpt-5.6-sol</a></td><td>Open AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-chat-latest">openai/gpt-chat-latest</a></td><td>Open AI</td><td>400,000</td><td><a href="https://aimlapi.com/models/gpt-chat-latest">GPT Chat Latest</a></td></tr><tr><td><a href="/api-references/text-models-llm/tencent/hy-mt2-1.8b">tencent/hy-mt2-1.8b</a></td><td>Tencent</td><td>8,192</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/scaledown/summarize">scaledown/summarize</a></td><td>ScaleDown</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/moondream/moondream3-preview">moondream/moondream3-preview</a></td><td>Moondream</td><td>32,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/moondream/moondream3.1-9b-a2b">moondream/moondream3.1-9b-a2b</a></td><td>Moondream</td><td>32,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/tencent/hy-mt2-7b">tencent/hy-mt2-7b</a></td><td>Tencent</td><td>8,192</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/tencent/hy-mt2-30b-a3b">tencent/hy-mt2-30b-a3b</a></td><td>Tencent</td><td>8,192</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5">openai/gpt-5-2025-08-07</a></td><td>Open AI</td><td>400,000</td><td><a href="https://aimlapi.com/models/gpt-5">GPT-5</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5-mini">openai/gpt-5-mini-2025-08-07</a></td><td>Open AI</td><td>400,000</td><td><a href="https://aimlapi.com/models/gpt-5-mini">GPT-5 Mini</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5-nano">openai/gpt-5-nano-2025-08-07</a></td><td>Open AI</td><td>400,000</td><td><a href="https://aimlapi.com/models/gpt-5-nano">GPT-5 Nano</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5-1">openai/gpt-5-1</a></td><td>Open AI</td><td>128,000</td><td><a href="https://aimlapi.com/models/gpt-5-1">GPT-5.1</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5.2">openai/gpt-5-2</a></td><td>Open AI</td><td>400,000</td><td><a href="https://aimlapi.com/models/gpt-5-2">GPT-5.2</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5.2-pro">openai/gpt-5-2-pro</a></td><td>Open AI</td><td>400,000</td><td><a href="https://aimlapi.com/models/gpt-5-2-pro">GPT-5.2 Pro</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5.3-codex">openai/gpt-5-3-codex</a></td><td>Open AI</td><td>400,000</td><td><a href="https://aimlapi.com/models/gpt-5-3-codex">GPT-5.3 Codex</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5-4">openai/gpt-5-4</a></td><td>Open AI</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gpt-5-4">GPT-5.4</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5-4-pro">openai/gpt-5-4-pro</a></td><td>Open AI</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gpt-5-4-pro">GPT-5.4 Pro</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5-5">openai/gpt-5-5</a></td><td>Open AI</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gpt-5-5">GPT-5.5</a></td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5-5-pro">openai/gpt-5-5-pro</a></td><td>Open AI</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gpt-5-5-pro">GPT 5.5 Pro</a></td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-4.6-opus">anthropic/claude-opus-4-6</a></td><td>Anthropic</td><td>200,000</td><td><a href="https://aimlapi.com/models/claude-opus-4-6">Claude 4.6 Opus</a></td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-sonnet-5">anthropic/claude-sonnet-5</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen-plus">qwen-plus</a></td><td>Alibaba Cloud</td><td>131,000</td><td><a href="https://aimlapi.com/models/qwen-plus-api">Qwen Plus</a></td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3-32b">alibaba/qwen3-32b</a></td><td>Alibaba Cloud</td><td>131,000</td><td><a href="https://aimlapi.com/models/qwen3-32b">Qwen3-32B</a></td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3-coder-480b-a35b-instruct">alibaba/qwen3-coder-480b-a35b-instruct</a></td><td>Alibaba Cloud</td><td>262,000</td><td><a href="https://aimlapi.com/models/qwen3-coder-480b-a35b-instruct">Qwen3 Coder</a></td></tr><tr><td><a href="/api-references/text-models-llm/baidu/ernie-5.0">baidu/ernie-5.0</a></td><td>Baidu</td><td>128,000</td><td>-</td></tr><tr><td><a href="broken://pages/ZsDbJIgnKik2dL64L5Nq">alibaba/glm-5.2</a></td><td>Zhipu AI</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3-235b-a22b-thinking-2507">alibaba/qwen3-235b-a22b-thinking-2507</a></td><td>Alibaba Cloud</td><td>262,000</td><td><a href="https://aimlapi.com/models/qwen3-235b-a22b">Qwen3 235B A22B Thinking</a></td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3-next-80b-a3b-instruct">alibaba/qwen3-next-80b-a3b-instruct</a></td><td>Alibaba Cloud</td><td>262,000</td><td><a href="https://aimlapi.com/models/qwen3-next-80b-a3b-instruct">Qwen3-Next-80B-A3B Instruct</a></td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.5-plus">alibaba/qwen3.5-plus-20260218</a></td><td>Alibaba Cloud</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/qwen3-5-plus">Qwen3.5 Plus</a></td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.5-omni-plus">alibaba/qwen3.5-omni-plus</a></td><td>Alibaba Cloud</td><td>256,000</td><td><a href="https://aimlapi.com/models/qwen3-5-omni-plus">Qwen3.5 Omni Plus</a></td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.5-omni-flash">alibaba/qwen3.5-omni-flash</a></td><td>Alibaba Cloud</td><td>256,000</td><td><a href="https://aimlapi.com/models/qwen3-5-omni-flash">Qwen3.5 Omni Flash</a></td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.8-omni-flash">alibaba/qwen3.8-omni-flash</a></td><td>Alibaba Cloud</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.5-flash">alibaba/qwen3.5-flash</a></td><td>Alibaba Cloud</td><td>262,144</td><td><em>Coming Soon</em></td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.6-27b">alibaba/qwen3.6-27b</a></td><td>Alibaba Cloud</td><td>262,144</td><td><a href="https://aimlapi.com/models/qwen-3-6-27b">Qwen 3.6 27B</a></td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.6-35b-a3b">alibaba/qwen3.6-35b-a3b</a></td><td>Alibaba Cloud</td><td>262,144</td><td><a href="https://aimlapi.com/models/qwen3-6-35b-a3b">Qwen3.6-35B-A3B</a></td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.6-flash">alibaba/qwen3.6-flash</a></td><td>Alibaba Cloud</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/qwen3-5-flash">Qwen3.5 Flash</a></td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.6-plus">alibaba/qwen3.6-plus</a></td><td>Alibaba Cloud</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/qwen3-6-plus">Qwen3.6-Plus</a></td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.7-max">alibaba/qwen3.7-max</a></td><td>Alibaba Cloud</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/qwen3-7-max">Qwen3.7 Max</a></td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.8-max">alibaba/qwen3.8-max</a></td><td>Alibaba Cloud</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.8-flash">alibaba/qwen3.8-flash</a></td><td>Alibaba Cloud</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.7-plus">alibaba/qwen3.7-plus</a></td><td>Alibaba Cloud</td><td>1,000,000</td><td>Qwen3.7 Plus</td></tr><tr><td><a href="/api-references/text-models-llm/anthracite/magnum-v4">anthracite-org/magnum-v4-72b</a></td><td>Anthracite</td><td>32,000</td><td><a href="https://aimlapi.com/models/magnum-v4-72b-api">Magnum v4 72B</a></td></tr><tr><td><a href="/api-references/text-models-llm/baidu/ernie-4.5-vl-424b-a47b">baidu/ernie-4.5-vl-424b-a47b</a></td><td>Baidu</td><td>123,000</td><td><a href="https://aimlapi.com/models/ernie-4-5-vl">ERNIE 4.5 VL</a></td></tr><tr><td><a href="/api-references/text-models-llm/baidu/ernie-5.5-flash-preview">baidu/ernie-5.5-flash-preview</a></td><td>Baidu</td><td>1,024,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/bytedance/seed-1.8">bytedance/seed-1-8</a></td><td>ByteDance</td><td>256,000</td><td><a href="https://aimlapi.com/models/seed-1-8">Seed 1.8</a></td></tr><tr><td><a href="/api-references/text-models-llm/bytedance/dola-seed-2.0-mini">bytedance/dola-seed-2-0-mini</a></td><td>ByteDance</td><td>256,000</td><td><a href="https://aimlapi.com/models/dola-seed-2-0-mini">Dola Seed 2.0 Mini</a></td></tr><tr><td><a href="/api-references/text-models-llm/bytedance/dola-seed-2.0-lite">bytedance/dola-seed-2-0-lite</a></td><td>ByteDance</td><td>256,000</td><td><a href="https://aimlapi.com/models/dola-seed-2-0-lite">Dola Seed 2.0 Lite</a></td></tr><tr><td><a href="/api-references/text-models-llm/bytedance/dola-seed-2.0-pro">bytedance/dola-seed-2-0-pro</a></td><td>ByteDance</td><td>256,000</td><td><a href="https://aimlapi.com/models/dola-seed-2-0-pro">Dola Seed 2.0 Pro</a></td></tr><tr><td><a href="/api-references/text-models-llm/bytedance/dola-seed-2.0-code">bytedance/dola-seed-2-0-code</a></td><td>ByteDance</td><td>256,000</td><td><a href="https://aimlapi.com/models/dola-seed-2-0-code">Dola Seed 2.0 Code</a></td></tr><tr><td><a href="/api-references/text-models-llm/cohere/command-a">cohere/command-a</a></td><td>Cohere</td><td>256,000</td><td><a href="https://aimlapi.com/models/command-a">Command A</a></td></tr><tr><td><a href="/api-references/text-models-llm/deepseek/deepseek-chat-v3.1">deepseek/deepseek-chat-v3.1</a></td><td>DeepSeek</td><td>128,000</td><td><a href="https://aimlapi.com/models/deepseek-v3-1-chat">DeepSeek V3.1 Chat</a></td></tr><tr><td><a href="/api-references/text-models-llm/deepseek/deepseek-reasoner-v3.1">deepseek/deepseek-reasoner-v3.1</a></td><td>DeepSeek</td><td>128,000</td><td><a href="https://aimlapi.com/models/deepseek-v3-1-reasoner">DeepSeek V3.1 Reasoner</a></td></tr><tr><td><a href="/api-references/text-models-llm/deepseek/deepseek-reasoner-v3.2-exp-thinking">deepseek/deepseek-thinking-v3.2-exp</a></td><td>DeepSeek</td><td>128,000</td><td><a href="https://aimlapi.com/models/deepseek-v3-2-exp-thinking">DeepSeek V3.2-Exp Thinking</a></td></tr><tr><td><a href="/api-references/text-models-llm/deepseek/deepseek-reasoner-v3.2-exp-non-thinking">deepseek/deepseek-non-thinking-v3.2-exp</a></td><td>DeepSeek</td><td>128,000</td><td><a href="https://aimlapi.com/models/deepseek-v3-2-exp-non-thinking">DeepSeek V3.2-Exp Non-Thinking</a></td></tr><tr><td><a href="/api-references/text-models-llm/deepseek/deepseek-reasoner-v3.1-terminus">deepseek/deepseek-reasoner-v3.1-terminus</a></td><td>DeepSeek</td><td>128,000</td><td><a href="https://aimlapi.com/models/deepseek-v3-1-terminus-reasoning">DeepSeek V3.1 Terminus Reasoning</a></td></tr><tr><td><a href="/api-references/text-models-llm/deepseek/deepseek-non-reasoner-v3.1-terminus">deepseek/deepseek-non-reasoner-v3.1-terminus</a></td><td>DeepSeek</td><td>128,000</td><td><a href="https://aimlapi.com/models/deepseek-v3-1-terminus-non-reasoning">DeepSeek V3.1 Terminus Non-Reasoning</a></td></tr><tr><td><a href="/api-references/text-models-llm/deepseek/deepseek-v4-pro">deepseek/deepseek-v4-pro</a></td><td>DeepSeek</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/deepseek-v4-pro">DeepSeek V4 Pro</a></td></tr><tr><td><a href="/api-references/text-models-llm/deepseek/deepseek-v4-flash">deepseek/deepseek-v4-flash</a></td><td>DeepSeek</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/deepseek-4">DeepSeek 4 Flash</a></td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-2.5-flash-lite-preview">google/gemini-2.5-flash-lite-preview</a></td><td>Google</td><td>1,000,000</td><td>–</td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-2.5-flash">google/gemini-2.5-flash</a></td><td>Google</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gemini-2-5-flash-api">Gemini 2.5 Flash</a></td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-3-flash-preview">google/gemini-3-flash-preview</a></td><td>Google</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gemini-3-flash">Gemini 3 Flash</a></td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-2.5-pro">google/gemini-2.5-pro</a></td><td>Google</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gemini-pro-2-5-api">Gemini 2.5 Pro</a></td></tr><tr><td><a href="/api-references/text-models-llm/google/gemma-4-26b-a4b-it">google/gemma-4-26b-a4b-it-maas</a></td><td>Google</td><td>262,144</td><td>-</td></tr><tr><td><a href="broken://pages/Wcg4CJ4mitpEkX6EYccl">zhipu/glm-5-3</a></td><td>Zhipu AI</td><td>1,024,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-5.3">zhipu/glm-5.3</a></td><td>Zhipu AI</td><td>1,024,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-3-6-flash">google/gemini-3-6-flash</a></td><td>Google</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-4-argon">google/gemini-4-argon</a></td><td>Google</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-3-8-flash">google/gemini-3-8-flash</a></td><td>Google</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-3-7-flash">google/gemini-3-7-flash</a></td><td>Google</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-3-5-flash-lite">google/gemini-3-5-flash-lite</a></td><td>Google</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-4-hydrogen">google/gemini-4-hydrogen</a></td><td>Google</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-3-5-flash-lite">google/gemini-3.5-flash-lite</a></td><td>Google</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/google/gemma-3">google/gemma-3-4b-it</a></td><td>Google</td><td>128,000</td><td><a href="https://aimlapi.com/models/gemma-3-4b-api">Gemma 3 (4B)</a></td></tr><tr><td><a href="/api-references/text-models-llm/google/gemma-3">google/gemma-3-12b-it</a></td><td>Google</td><td>128,000</td><td><a href="https://aimlapi.com/models/gemma-3-12b-api">Gemma 3 (12B)</a></td></tr><tr><td><a href="/api-references/text-models-llm/google/gemma-3">google/gemma-3-27b-it</a></td><td>Google</td><td>128,000</td><td><a href="https://aimlapi.com/models/gemma-3-27b-api">Gemma 3 (27B)</a></td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-3-1-pro-preview">google/gemini-3-1-pro-preview</a></td><td>Google</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gemini-3-1-pro">Gemini 3.1 Pro</a></td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-3-1-flash-lite-preview">google/gemini-3-1-flash-lite-preview</a></td><td>Google</td><td>1,048,576</td><td><a href="https://aimlapi.com/models/gemini-3-1-flash">Gemini 3.1 Flash Lite</a></td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-3-1-flash-lite">google/gemini-3-1-flash-lite</a></td><td>Google</td><td>1,050,000</td><td><a href="https://aimlapi.com/models/gemini-3-1-flash">Gemini 3.1 Flash Lite</a></td></tr><tr><td><a href="/api-references/text-models-llm/google/gemma-4-31b-it">google/gemma-4-31b-it</a></td><td>Google</td><td>262,000</td><td><a href="https://aimlapi.com/models/gemma-4-31b">Gemma 4 31B</a></td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-3-5-flash">google/gemini-3-5-flash</a></td><td>Google</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gemini-3-5-flash">Gemini 3.5 Flash</a></td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-3-pro-image">google/gemini-3-pro-image</a></td><td>Google</td><td>65,536</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/google/gemma-2-27b-it">google/gemma-2-27b-it</a></td><td>Google</td><td>8,192</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-3.1-pro-preview-customtools">google/gemini-3.1-pro-preview-customtools</a></td><td>Google</td><td>1,048,756</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-3.1-flash-image">google/gemini-3.1-flash-image</a></td><td>Google</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/gryphe/mythomax-l2-13b">gryphe/mythomax-l2-13b</a></td><td>Gryphe</td><td>4,000</td><td><a href="https://aimlapi.com/models/mythomax-l2-13b">MythoMax-L2 (13B)</a></td></tr><tr><td><a href="/api-references/text-models-llm/meta/llama-3.3-70b-instruct-turbo">meta-llama/Llama-3.3-70B-Instruct-Turbo</a></td><td>Meta</td><td>128,000</td><td><a href="https://aimlapi.com/models/meta-llama-3-3-70b-instruct-turbo-api">Meta Llama 3.3 70B Instruct Turbo</a></td></tr><tr><td><a href="/api-references/text-models-llm/minimax/m1">minimax/m1</a></td><td>MiniMax</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/minimax-m1">MiniMax M1</a></td></tr><tr><td><a href="/api-references/text-models-llm/minimax/m2">minimax/m2</a></td><td>MiniMax</td><td>200,000</td><td><a href="https://aimlapi.com/models/minimax-m2">MiniMax M2</a></td></tr><tr><td><a href="/api-references/text-models-llm/minimax/m2-her">minimax/m2-her</a></td><td>MiniMax</td><td>200,000</td><td><a href="https://aimlapi.com/models/minimax-m2-her">MiniMax M2-her</a></td></tr><tr><td><a href="/api-references/text-models-llm/minimax/m2-1">minimax/m2-1</a></td><td>MiniMax</td><td>204,800</td><td><a href="https://aimlapi.com/models/minimax-m2-1">MiniMax M2.1</a></td></tr><tr><td><a href="/api-references/text-models-llm/minimax/m2.1-highspeed">minimax/m2-1-highspeed</a></td><td>MiniMax</td><td>204,800</td><td><a href="https://aimlapi.com/models/minimax-m2-1-highspeed">MiniMax M2.1 Highspeed</a></td></tr><tr><td><a href="/api-references/text-models-llm/minimax/m2-5">minimax/m2-5-20260218</a></td><td>MiniMax</td><td>204,800</td><td><a href="https://aimlapi.com/models/minimax-m2-5">MiniMax M2.5</a></td></tr><tr><td><a href="/api-references/text-models-llm/minimax/m2-5-highspeed">minimax/m2-5-highspeed-20260218</a></td><td>MiniMax</td><td>204,800</td><td><a href="https://aimlapi.com/models/minimax-m2-5">MiniMax M2.5</a></td></tr><tr><td><a href="/api-references/text-models-llm/minimax/m2-7">minimax/m2-7-20260402</a></td><td>MiniMax</td><td>204,800</td><td><a href="https://aimlapi.com/models/minimax-m2-7">MiniMax M2.7</a></td></tr><tr><td><a href="/api-references/text-models-llm/minimax/m2.7-highspeed">minimax/m2-7-highspeed</a></td><td>MiniMax</td><td>204,800</td><td><a href="https://aimlapi.com/models/minimax-m2-7-highspeed">MiniMax M2.7 Highspeed</a></td></tr><tr><td><a href="/api-references/text-models-llm/minimax/m3">minimax/minimax-m3</a></td><td>MiniMax</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/minimax-m3">MiniMax M3</a></td></tr><tr><td><a href="/api-references/text-models-llm/minimax/minimax-m3.1-flash">minimax/minimax-m3.1-flash</a></td><td>Minimax AI</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/mistral-nemo">mistralai/mistral-nemo</a></td><td>Mistral AI</td><td>128,000</td><td><a href="https://aimlapi.com/models/mistral-nemo-api">Mistral Nemo</a></td></tr><tr><td><a href="/api-references/text-models-llm/moonshot/kimi-k2-6">moonshot/kimi-k2-6</a></td><td>Moonshot</td><td>256,000</td><td><a href="https://aimlapi.com/models/kimi-k2-6">Kimi K2.6</a></td></tr><tr><td><a href="/api-references/text-models-llm/moonshot/kimi-k2-7-code">moonshot/kimi-k2-7-code</a></td><td>Moonshot</td><td>262,000</td><td><a href="https://aimlapi.com/models/kimi-k2-7-code">Kimi K2.7 Code</a></td></tr><tr><td><a href="/api-references/text-models-llm/moonshot/kimi-k2-7-code-highspeed">moonshot/kimi-k2-7-code-highspeed</a></td><td>Moonshot</td><td>262,144</td><td><a href="https://aimlapi.com/models/kimi-k2-7-code-highspeed">Kimi K2.7 Code Highspeed</a></td></tr><tr><td><a href="/api-references/text-models-llm/meituan/longcat-2.0">meituan/longcat-2.0</a></td><td>Meituan</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/sakana-ai/fugu-ultra">sakana/fugu-ultra</a></td><td>Sakana AI</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/fugu-ultra">Sakana Fugu Ultra</a></td></tr><tr><td><a href="/api-references/text-models-llm/sakana-ai/fugu-max">sakana/fugu-max</a></td><td>Sakana AI</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/sakana-ai/fugu-ultra-v2">sakana/fugu-ultra-v2</a></td><td>Sakana AI</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/sakana-ai/sakana-namazu">sakana/sakana-namazu</a></td><td>Sakana AI</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.8-2.4t-a95b">alibaba/qwen3.8-2.4t-a95b</a></td><td>Alibaba Cloud</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/unbiased/pareto">unbiased/pareto</a></td><td>Unbiased</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/unbiased/pareto-26.10-preview">unbiased/pareto-26.10-preview</a></td><td>Unbiased</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/tencent/hy4-preview">tencent/hy4-preview</a></td><td>Tencent</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/inception/mercury-3">inception/mercury-3</a></td><td>Inception</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/tencent/hy4">tencent/hy4</a></td><td>Tencent</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/google/gemini-4-carbon">google/gemini-4-carbon</a></td><td>Google</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/nousresearch/hermes-4-405b">nousresearch/hermes-4-405b</a></td><td>NousResearch</td><td>131,000</td><td><a href="https://aimlapi.com/models/hermes-4-405b">Hermes 4 405b</a></td></tr><tr><td><a href="/api-references/text-models-llm/nvidia/nemotron-3-ultra-550b-a55b">nvidia/nemotron-3-ultra-550b-a55b</a></td><td>NVIDIA</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/nemotron-3-ultra">Nemotron 3 Ultra 550b</a></td></tr><tr><td><a href="/api-references/text-models-llm/nvidia/nemotron-3-nano-30b-a3b">nvidia/nemotron-3-nano-30b-a3b</a></td><td>NVIDIA</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/nemotron-3-nano-30b-a3b">Nemotron 3 Nano 30B</a></td></tr><tr><td><a href="/api-references/text-models-llm/nvidia/nemotron-3.5-lightning">nvidia/nemotron-3.5-lightning</a></td><td>Nvidia</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/nvidia/nemotron-3-super-120b-a12b">nvidia/nemotron-3-super-120b-a12b</a></td><td>NVIDIA</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/nemotron-3-super-120b-a12b">Nemotron 3 Super 120B</a></td></tr><tr><td><a href="/api-references/text-models-llm/perplexity/sonar">perplexity/sonar</a></td><td>Perplexity</td><td>128,000</td><td><a href="https://aimlapi.com/models/perplexity-sonar">Sonar</a></td></tr><tr><td><a href="/api-references/text-models-llm/perplexity/sonar-pro">perplexity/sonar-pro</a></td><td>Perplexity</td><td>200,000</td><td><a href="https://aimlapi.com/models/perplexity-sonar-pro">Sonar Pro</a></td></tr><tr><td><a href="/api-references/text-models-llm/stepfun/step3.7-flash">stepfun/step-3.7-flash</a></td><td>StepFun</td><td>256,000</td><td><a href="https://aimlapi.com/models/step-3-7-flash">Step 3.7 Flash</a></td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-3-beta">x-ai/grok-3-beta</a></td><td>xAI</td><td>131,000</td><td><a href="https://aimlapi.com/models/grok-3-beta-api">Grok 3 Beta</a></td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-3-mini-beta">x-ai/grok-3-mini-beta</a></td><td>xAI</td><td>131,000</td><td><a href="https://aimlapi.com/models/grok-3-beta-mini-api">Grok 3 Beta Mini</a></td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-code-fast-1">x-ai/grok-code-fast-1</a></td><td>xAI</td><td>256,000</td><td><a href="https://aimlapi.com/models/grok-code-fast-1">Grok Code Fast 1</a></td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-4-fast-non-reasoning">x-ai/grok-4-fast-non-reasoning</a></td><td>xAI</td><td>2,000,000</td><td><a href="https://aimlapi.com/models/grok-4-fast">Grok 4 Fast</a></td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-4-fast-reasoning">x-ai/grok-4-fast-reasoning</a></td><td>xAI</td><td>2,000,000</td><td><a href="https://aimlapi.com/models/grok-4-fast-reasoning">Grok 4 Fast Reasoning</a></td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-4-1-fast-non-reasoning">x-ai/grok-4-1-fast-non-reasoning</a></td><td>xAI</td><td>2,000,000</td><td><a href="https://aimlapi.com/models/grok-4-1-fast-non-reasoning">Grok 4.1 Fast Non-Reasoning</a></td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-4-1-fast-reasoning">x-ai/grok-4-1-fast-reasoning</a></td><td>xAI</td><td>2,000,000</td><td><a href="https://aimlapi.com/models/grok-4-1-fast-reasoning">Grok 4.1 Fast Reasoning</a></td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-4-5">x-ai/grok-4-5</a></td><td>X AI</td><td>500,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-4-7">x-ai/grok-4-7</a></td><td>X AI</td><td>500,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-4-6">x-ai/grok-4-6</a></td><td>X AI</td><td>500,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-4-20-non-reasoning">x-ai/grok-4-20-0309-non-reasoning</a></td><td>xAI</td><td>2,000,000</td><td><a href="https://aimlapi.com/models/grok-4-20">Grok 4.20 Non-Reasoning</a></td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-4-20-reasoning">x-ai/grok-4-20-0309-reasoning</a></td><td>xAI</td><td>2,000,000</td><td><a href="https://aimlapi.com/models/grok-4-20">Grok 4.20 Reasoning</a></td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-4-3">x-ai/grok-4-3</a></td><td>X AI</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/xai/grok-build-0-1">x-ai/grok-build-0-1</a></td><td>xAI</td><td>256,000</td><td><a href="https://aimlapi.com/models/grok-build-0-1">Grok Build 0.1</a></td></tr><tr><td><a href="/api-references/text-models-llm/xiaomi/mimo-v2.5">xiaomi/mimo-v2.5</a></td><td>Xiaomi</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/mimo-v2-5">MiMo V2.5</a></td></tr><tr><td><a href="/api-references/text-models-llm/amazon/nova-2-lite-v1">amazon/nova-2-lite-v1</a></td><td>Amazon</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/deepseek-ai/deepseek-v4-flash-latest">deepseek/deepseek-v4-flash-latest</a></td><td>DeepSeek AI</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/bytedance/seed-2-1-turbo">bytedance-seed/seed-2-1-turbo</a></td><td>ByteDance</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/meta/muse-spark-1.1">meta/muse-spark-1.1</a></td><td>Meta</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/meta/muse-spark-1.3">meta/muse-spark-1.3</a></td><td>Meta</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/meta/muse-spark-1.2">meta/muse-spark-1.2</a></td><td>Meta</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/meta/muse-wonder">meta/muse-wonder</a></td><td>Meta</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/meta/muse-ember">meta/muse-ember</a></td><td>Meta</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/venice/dolphin-mistral-24b-venice-edition">cognitivecomputations/dolphin-mistral-24b-venice-edition</a></td><td>Venice</td><td>128,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-sonnet-latest">anthropic/claude-sonnet-latest</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-opus-latest">anthropic/claude-opus-latest</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-sonnet-5.5">anthropic/claude-sonnet-5-5</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-haiku-5-5">anthropic/claude-haiku-5-5</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-fable-5-2">anthropic/claude-fable-5.2</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-fable-5-2">anthropic/claude-fable-5-2</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-opus-5.5">anthropic/claude-opus-5-5</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-fable-5.1">anthropic/claude-fable-5-1</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-opus-5">anthropic/claude-opus-5</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-haiku-latest">anthropic/claude-haiku-latest</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-fable-latest">anthropic/claude-fable-latest</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/anthropic/claude-sonnet-4">anthropic/claude-sonnet-4</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-4.5v">z-ai/glm-4.5v</a></td><td>Zhipu AI</td><td>65,536</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-5.3-flash">z-ai/glm-5.3-flash</a></td><td>Zhipu AI</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-5v-turbo">z-ai/glm-5v-turbo</a></td><td>Zhipu AI</td><td>202,752</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-5-turbo">z-ai/glm-5-turbo</a></td><td>Zhipu AI</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-4.7-flash">z-ai/glm-4.7-flash</a></td><td>Zhipu AI</td><td>202,752</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-4.6v">z-ai/glm-4.6v</a></td><td>Zhipu AI</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/zhipu-ai-1/glm-5.3-flashx">z-ai/glm-5.3-flashx</a></td><td>Zhipu AI</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/writer/palmyra-x5">writer/palmyra-x5</a></td><td>Writer</td><td>1,040,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/upstage/solar-pro4">upstage/solar-pro4</a></td><td>Upstage</td><td>524,288</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/undi95/remm-slerp-l2-13b">undi95/remm-slerp-l2-13b</a></td><td>undi95</td><td>6,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/thedrummer/cydonia-24b-v4.1">thedrummer/cydonia-24b-v4.1</a></td><td>TheDrummer</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/thedrummer/unslopnemo-12b">thedrummer/unslopnemo-12b</a></td><td>TheDrummer</td><td>32,768</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/thedrummer/skyfall-36b-v2">thedrummer/skyfall-36b-v2</a></td><td>TheDrummer</td><td>32,768</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5-image">openai/gpt-5-image</a></td><td>Open AI</td><td>400,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5.4-nano">openai/gpt-5.4-nano</a></td><td>Open AI</td><td>400,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-5.4-pro">openai/gpt-5.4-pro</a></td><td>Open AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/openai/gpt-6.1-terra">openai/gpt-6.1-terra</a></td><td>Open AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/nousresearch/hermes-3-llama-3.1-405b">nousresearch/hermes-3-llama-3.1-405b</a></td><td>NousResearch</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/nousresearch/hermes-3-llama-3.1-70b">nousresearch/hermes-3-llama-3.1-70b</a></td><td>NousResearch</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/morph/morph-v3-fast">morph/morph-v3-fast</a></td><td>Morph</td><td>81,920</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/morph/morph-v3-large">morph/morph-v3-large</a></td><td>Morph</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/moonshot/kimi-k2">moonshotai/kimi-k2</a></td><td>Moonshot</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/moonshot/kimi-k2-thinking">moonshotai/kimi-k2-thinking</a></td><td>Moonshot</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/moonshot/kimi-k2-0905">moonshotai/kimi-k2-0905</a></td><td>Moonshot</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/codestral-2508">mistralai/codestral-2508</a></td><td>Mistral AI</td><td>256,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/mistral-saba">mistralai/mistral-saba</a></td><td>Mistral AI</td><td>32,768</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/voxtral-small-24b-2507">mistralai/voxtral-small-24b-2507</a></td><td>Mistral AI</td><td>32,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/mixtral-8x22b-instruct">mistralai/mixtral-8x22b-instruct</a></td><td>Mistral AI</td><td>65,536</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/mistral-small-3.2-24b-instruct">mistralai/mistral-small-3.2-24b-instruct</a></td><td>Mistral AI</td><td>128,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/mistral-small-3.1-24b-instruct">mistralai/mistral-small-3.1-24b-instruct</a></td><td>Mistral AI</td><td>128,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/mistral-small-2603">mistralai/mistral-small-2603</a></td><td>Mistral AI</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/mistral-small-24b-instruct-2501">mistralai/mistral-small-24b-instruct-2501</a></td><td>Mistral AI</td><td>32,768</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/mistral-medium-3.1">mistralai/mistral-medium-3.1</a></td><td>Mistral AI</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/ministral-8b-2512">mistralai/ministral-8b-2512</a></td><td>Mistral AI</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/ministral-3b-2512">mistralai/ministral-3b-2512</a></td><td>Mistral AI</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/ministral-14b-2512">mistralai/ministral-14b-2512</a></td><td>Mistral AI</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/mistral-large-4-0">mistralai/mistral-large-4-0</a></td><td>Mistral AI</td><td>524,288</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mancer/weaver">mancer/weaver</a></td><td>Mancer</td><td>8,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/inception/mercury-2">inception/mercury-2</a></td><td>Inception</td><td>128,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/inception/mercury-2.5">inception/mercury-2.5</a></td><td>Inception</td><td>260,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/ibm/granite-4.2-8b">ibm-granite/granite-4.2-8b</a></td><td>IBM</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/prismml/ternary-bonsai-2-27b">prism-ml/ternary-bonsai-2-27b</a></td><td>PrismML</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/prismml/ternary-bonsai-2-9b">prism-ml/ternary-bonsai-2-9b</a></td><td>PrismML</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/reflection/beam-1.0-501b-a23b">reflection/beam-1.0-501b-a23b</a></td><td>Reflection</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/nvidia/nemotron-3.5-super-vl">nvidia/nemotron-3.5-super-vl</a></td><td>Nvidia</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/elorian/glimpse">elorian/glimpse</a></td><td>Elorian</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/inclusionai/ling-3.1-flash">inclusionai/ling-3.1-flash</a></td><td>inclusionAI</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/fireworks/ember-1">fireworks/ember-1</a></td><td>Fireworks</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/thinking-machines/inkling-2-small">thinkingmachines/inkling-2-small</a></td><td>Thinking Machines</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen3.8-max-prime">alibaba/qwen3.8-max-prime</a></td><td>Alibaba Cloud</td><td>1,000,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/cohere/command-r-08-2024">cohere/command-r-08-2024</a></td><td>Cohere</td><td>128,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/bytedance/seed-1.6">bytedance-seed/seed-1.6</a></td><td>ByteDance Seed</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/bytedance-seed/seed-2.0-lite">bytedance-seed/seed-2.0-lite</a></td><td>ByteDance Seed</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/bytedance-seed/seed-2.0-mini">bytedance-seed/seed-2.0-mini</a></td><td>ByteDance Seed</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/bytedance/seed-1.6-flash">bytedance-seed/seed-1.6-flash</a></td><td>ByteDance Seed</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/amazon/nova-pro-v1">amazon/nova-pro-v1</a></td><td>Amazon</td><td>300,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/amazon/nova-micro-v1">amazon/nova-micro-v1</a></td><td>Amazon</td><td>128,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/amazon/nova-lite-v1">amazon/nova-lite-v1</a></td><td>Amazon</td><td>300,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/aionlabs/aion-rp-llama-3.1-8b">aion-labs/aion-rp-llama-3.1-8b</a></td><td>AionLabs</td><td>32,768</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/aionlabs/aion-2.0">aion-labs/aion-2.0</a></td><td>AionLabs</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/aionlabs/aion-3.0-mini">aion-labs/aion-3.0-mini</a></td><td>AionLabs</td><td>131,072</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/aionlabs/aion-3.5">aion-labs/aion-3.5</a></td><td>AionLabs</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/aionlabs/aion-3.5-mini">aion-labs/aion-3.5-mini</a></td><td>AionLabs</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/xiaomi/mimo-v2.5-pro">xiaomi/mimo-v2.5-pro</a></td><td>Xiaomi</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/mimo-v2-5-pro">MiMo V2.5 Pro</a></td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-4.5-air">zhipu/glm-4.5-air</a></td><td>Zhipu</td><td>128,000</td><td><a href="https://aimlapi.com/models/glm-4-5-air">GLM-4.5 Air</a></td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-4.5">zhipu/glm-4.5</a></td><td>Zhipu</td><td>128,000</td><td><a href="https://aimlapi.com/models/glm-4-5">GLM-4.5</a></td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-4.6">zhipu/glm-4.6</a></td><td>Zhipu</td><td>200,000</td><td><a href="/api-references/text-models-llm/zhipu/glm-4.6">GLM-4.6</a></td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-4.7">zhipu/glm-4.7</a></td><td>Zhipu</td><td>200,000</td><td><a href="https://aimlapi.com/models/glm-4-7">GLM-4.7</a></td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-5">zhipu/glm-5</a></td><td>Zhipu</td><td>200,000</td><td><a href="https://aimlapi.com/models/glm-5">GLM-5</a></td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-5.1">zhipu/glm-5-1</a></td><td>Zhipu</td><td>200,000</td><td><a href="https://aimlapi.com/models/glm-5-1"><em>GLM-5.1</em></a></td></tr><tr><td><a href="/api-references/text-models-llm/zhipu/glm-5.2">zhipu/glm-5-2</a></td><td>Zhipu</td><td>200,000</td><td><a href="https://aimlapi.com/models/glm-5-2">GLM-5.2</a></td></tr><tr><td><a href="/api-references/text-models-llm/poolside/laguna-s-2.1">poolside/laguna-s-2.1</a></td><td>Poolside</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/inference.net/schematron-v2-small">inference-net/schematron-v2-small</a></td><td>Inference.net</td><td>128,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/ml-api/dynamic-router">aimlapi/dynamic-router</a></td><td>AI/ML API</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/liquid-ai/d1-router">liquid/d1-router</a></td><td>Liquid AI</td><td>1,050,000</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/stealth/crouton-alpha">stealth/crouton-alpha</a></td><td>Stealth</td><td>1,048,576</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/inclusionai/ling-3.0-tiny-free">inclusionai/ling-3.0-tiny</a></td><td>inclusionAI</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/mistral-ai/devstral-2512">mistralai/devstral-2512</a></td><td>Mistral AI</td><td>262,144</td><td>-</td></tr><tr><td><a href="/api-references/text-models-llm/alibaba-cloud/qwen-max">qwen-max</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-max-2025-09-23-api">Qwen Max</a></td></tr><tr><td><a href="/api-references/text-models-llm/stealth/ox-alpha">stealth/ox-alpha</a></td><td>Stealth</td><td>1,048,576</td><td>-</td></tr></tbody></table>

## Image Models

<table data-header-hidden="false" data-header-sticky data-full-width="true"><thead><tr><th width="274.20001220703125">Model ID + API Reference link</th><th width="123.39996337890625">Developer</th><th width="103.79998779296875">Context</th><th>Model Card</th></tr></thead><tbody><tr><td><a href="/api-references/image-models/alibaba-cloud/qwen-image">alibaba/qwen-image</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/qwen-image">Qwen Image</a></td></tr><tr><td><a href="/api-references/image-models/alibaba-cloud/z-image-turbo">alibaba/z-image-turbo</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/z-image-turbo">Z-Image Turbo</a></td></tr><tr><td><a href="/api-references/image-models/alibaba-cloud/z-image-turbo-lora">alibaba/z-image-turbo-lora</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/z-image-turbo-lora">Z-Image Turbo LoRA</a></td></tr><tr><td><a href="/api-references/image-models/alibaba-cloud/wan2.2-t2i-plus">alibaba/wan2.2-t2i-plus</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-2-t2i-plus">Wan 2.2 Plus</a></td></tr><tr><td><a href="/api-references/image-models/alibaba-cloud/wan2.2-t2i-flash">alibaba/wan2.2-t2i-flash</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-2-t2i-flash">Wan 2.2 Flash</a></td></tr><tr><td><a href="/api-references/image-models/alibaba-cloud/wan2.5-t2i-preview">alibaba/wan2.5-t2i-preview</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-5-t2i-preview">Wan 2.5 Preview</a></td></tr><tr><td><a href="/api-references/image-models/alibaba-cloud/wan-2-6-image">alibaba/wan-2-6-image</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-6">Wan 2.6</a></td></tr><tr><td><a href="/api-references/image-models/alibaba-cloud/wan2.7-image">alibaba/wan-2-7-image</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-7">Wan 2.7 Image</a></td></tr><tr><td><a href="/api-references/image-models/alibaba-cloud/wan2.7-image-pro">alibaba/wan-2-7-image-pro</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-7-pro">Wan 2.7 Image Pro</a></td></tr><tr><td><a href="/api-references/image-models/alibaba-cloud/qwen-image-2.0">alibaba/qwen-image-2-0</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/qwen-image-2-0">Qwen Image 2.0</a></td></tr><tr><td><a href="/api-references/image-models/alibaba-cloud/qwen-image-2.0-pro">alibaba/qwen-image-2-0-pro</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/qwen-image-2-0-pro">Qwen Image 2.0 Pro</a></td></tr><tr><td><a href="/api-references/image-models/bytedance/dreamina-creative-upscale">bytedance/dreamina-creative-upscale</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/byteplus-dreamina-creative-upscale">Dreamina Creative Upscale</a></td></tr><tr><td><a href="/api-references/image-models/bytedance/seedream-v4-text-to-image">bytedance/seedream-v4-text-to-image</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedream-4">Seedream 4 Text-to-Image</a></td></tr><tr><td><a href="/api-references/image-models/bytedance/seedream-v4-edit-image-to-image">bytedance/seedream-v4-edit</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedream-4-edit">Seedream 4 Edit</a></td></tr><tr><td><a href="/api-references/image-models/bytedance/uso">bytedance/uso</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/uso">USO</a></td></tr><tr><td><a href="/api-references/image-models/bytedance/seedream-4-5">bytedance/seedream-4-5</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedream-4-5">Seedream 4.5</a></td></tr><tr><td><a href="/api-references/image-models/bytedance/seedream-5.0-lite-preview">bytedance/seedream-5-0-lite-preview</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seadream-5-0-lite">Seadream 5.0 Lite</a></td></tr><tr><td><a href="/api-references/image-models/bytedance/seedream-5-0-pro">bytedance/seedream-5-0-pro</a></td><td>ByteDance</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/bytedance/dola-seedream-5-0-pro">bytedance/dola-seedream-5-0-pro</a></td><td>ByteDance</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/flux/flux-pro">flux-pro</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-1-pro-api">FLUX.1 [pro]</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-realism">flux-realism</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-realism-lora-api">FLUX Realism LoRA</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-dev">flux/dev</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-1-dev-api">FLUX.1 [dev]</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-dev-image-to-image">flux/dev/image-to-image</a></td><td>Flux</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/flux/flux-schnell">flux/schnell</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-1-schnell-api">FLUX.1 [schnell]</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-kontext-max-text-to-image">flux/kontext-max/text-to-image</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-1-kontext-max">FLUX.1 Kontext [max]</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-kontext-max-image-to-image">flux/kontext-max/image-to-image</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-1-kontext-max">FLUX.1 Kontext [max]</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-kontext-pro-text-to-image">flux/kontext-pro/text-to-image</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-1-kontext-pro">Flux.1 Kontext [pro]</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-kontext-pro-image-to-image">flux/kontext-pro/image-to-image</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-1-kontext-pro">Flux.1 Kontext [pro]</a></td></tr><tr><td><a href="/api-references/image-models/beeble/switchx-image-to-image">beeble/switchx-image-to-image</a></td><td>Beeble</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/flux/flux-srpo-text-to-image">flux/srpo</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-1-srpo-t2i">FLUX.1 SRPO Text-to-Image</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-srpo-image-to-image">flux/srpo/image-to-image</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-1-srpo-i2i">FLUX.1 SRPO Image-to-Image</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-2">blackforestlabs/flux-2</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-2-text-to-image">FLUX.2</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-2-edit">blackforestlabs/flux-2-edit</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-2-edit">FLUX.2 Edit</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-2-lora">blackforestlabs/flux-2-lora</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-2-lora">Flux 2 LoRA</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-2-lora-edit">blackforestlabs/flux-2-lora-edit</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-2-lora-edit">Flux 2 LoRA Edit</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-2-pro">blackforestlabs/flux-2-pro</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-2-pro-text-to-image">FLUX.2 [pro]</a></td></tr><tr><td><a href="/api-references/image-models/flux/flux-2-pro-edit">blackforestlabs/flux-2-pro-edit</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-2-pro-image-editing">FLUX.2 [pro] Edit</a></td></tr><tr><td><a href="/api-references/image-models/google/gemini-2.5-flash-image-edit">google/nano-banana-edit</a></td><td>Google</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/google/gemini-2.5-flash-image">google/gemini-2.5-flash-image</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/gemini-2-5-flash-image">Gemini 2.5 Flash Image</a></td></tr><tr><td><a href="/api-references/image-models/meta/muse-image">meta/muse-image</a></td><td>Meta</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/meta/muse-image-edit">meta/muse-image-edit</a></td><td>Meta</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/minimax-ai/minimax-h3-image">minimax/h3-image</a></td><td>Minimax AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/minimax-ai/minimax-h3-image-highspeed">minimax/h3-image-highspeed</a></td><td>Minimax AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/minimax-ai/image-01">minimax/image-01</a></td><td>Minimax AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/google/gemini-2.5-flash-image-edit">google/gemini-2.5-flash-image-edit</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/gemini-2-5-flash-image-edit">Gemini 2.5 Flash Image Edit</a></td></tr><tr><td><a href="/api-references/image-models/google/gemini-3-pro-image-preview-edit">google/gemini-3-pro-image-edit</a></td><td>Google</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/google/nano-banana-2.1">google/gemini-nano-banana-2.1</a></td><td>Google</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/google/gemini-3.1-flash-lite-image">google/gemini-3-1-flash-lite-image</a></td><td>Google</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/kling-ai/image-o1">klingai/image-o1</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-image-o1">Kling Image O1</a></td></tr><tr><td><a href="/api-references/image-models/luma-ai/uni-1">luma/uni-1</a></td><td>Luma AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/luma-ai/uni-1-max">luma/uni-1-max</a></td><td>Luma AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/openai/gpt-image-1-mini">openai/gpt-image-1-mini</a></td><td>OpenAI</td><td></td><td><a href="https://aimlapi.com/models/gpt-image-1-mini">GPT Image 1 Mini</a></td></tr><tr><td><a href="/api-references/image-models/openai/gpt-image-2.5-flare">openai/gpt-image-2.5-flare</a></td><td>Open AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/openai/gpt-image-2.5-sunburst">openai/gpt-image-2.5-sunburst</a></td><td>Open AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/openai/gpt-image-2.6-flare">openai/gpt-image-2.6-flare</a></td><td>Open AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/openai/gpt-image-2.6-sunburst">openai/gpt-image-2.6-sunburst</a></td><td>Open AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/openai/gpt-image-1-mini">openai/gpt-image-1-5</a></td><td>OpenAI</td><td></td><td><a href="https://aimlapi.com/models/gpt-image-1-5">GPT Image 1.5</a></td></tr><tr><td><a href="/api-references/image-models/openai/gpt-image-2">openai/gpt-image-2</a></td><td>OpenAI</td><td></td><td><a href="https://aimlapi.com/models/gpt-image-2">GPT Image 2</a></td></tr><tr><td><a href="/api-references/image-models/recraftai/recraft-v3">recraft-v3</a></td><td>Recraft AI</td><td></td><td><a href="https://aimlapi.com/models/recraft-v3">Recraft v3</a></td></tr><tr><td><a href="/api-references/image-models/stability-ai/stable-diffusion-v3-medium">stable-diffusion-v3-medium</a></td><td>Stability AI</td><td></td><td><a href="https://aimlapi.com/models/stable-diffusion-3-api">Stable Diffusion 3</a></td></tr><tr><td><a href="/api-references/image-models/stability-ai/stable-diffusion-v35-large">stable-diffusion-v35-large</a></td><td>Stability AI</td><td></td><td><a href="https://aimlapi.com/models/stable-diffusion-3-5-large-api">Stable Diffusion 3.5 Large</a></td></tr><tr><td><a href="/api-references/image-models/tencent/hunyuan-image-v3-text-to-image">hunyuan/hunyuan-image-v3-text-to-image</a></td><td>Tencent</td><td></td><td><a href="https://aimlapi.com/models/hunyuanimage-3-0">HunyuanImage 3.0</a></td></tr><tr><td><a href="/api-references/image-models/alibaba-cloud/qwen-image-3">alibaba/qwen-image-3</a></td><td>Alibaba Cloud</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/alibaba-cloud/qwen-image-3-edit">alibaba/qwen-image-3-edit</a></td><td>Alibaba Cloud</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/topaz-labs/sharpen">topaz-labs/sharpen</a></td><td>Topaz Labs</td><td></td><td><a href="https://aimlapi.com/models/sharpen">Sharpen</a></td></tr><tr><td><a href="/api-references/image-models/topaz-labs/sharpen-generative">topaz-labs/sharpen-gen</a></td><td>Topaz Labs</td><td></td><td><a href="https://aimlapi.com/models/sharpen">Sharpen Generative</a></td></tr><tr><td><a href="/api-references/image-models/xai/grok-imagine-image">x-ai/grok-imagine-image</a></td><td>xAI</td><td></td><td><a href="https://aimlapi.com/models/grok-imagine-image">Grok Imagine</a></td></tr><tr><td><a href="/api-references/image-models/x-ai/grok-imagine-image-2.0">x-ai/grok-imagine-image-2.0</a></td><td>X AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/image-models/xai/grok-imagine-image-pro">x-ai/grok-imagine-image-pro</a></td><td>xAI</td><td></td><td><a href="https://aimlapi.com/models/grok-imagine-image-pro">Grok Imagine Image Pro</a></td></tr></tbody></table>

### Video Models

<table data-header-hidden="false" data-header-sticky data-full-width="true"><thead><tr><th width="302.199951171875">Model ID + API Reference link</th><th width="117.53338623046875">Developer</th><th width="99.7999267578125">Context</th><th>Model Card</th></tr></thead><tbody><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.1-plus-text-to-video">alibaba/wan2.1-t2v-plus</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan2-1-plus">Wan2.1 Plus</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.1-turbo-text-to-video">alibaba/wan2.1-t2v-turbo</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan2-1-turbo">Wan2.1 Turbo</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.2-plus-text-to-video">alibaba/wan2.2-t2v-plus</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan2-2-t2v">Wan 2.2 T2V</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.5-preview-text-to-video">alibaba/wan2.5-t2v-preview</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-5-text-to-video">Wan 2.5 Text-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.5-preview-image-to-video">alibaba/wan2.5-i2v-preview</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-5-image-to-video">Wan 2.5 Image-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.2-14b-animate-replace-image-to-video">alibaba/wan2.2-14b-animate-replace</a></td><td>Alibaba Cloud</td><td></td><td><a href="/api-references/video-models/alibaba-cloud/wan-2.2-14b-animate-replace-image-to-video">Wan 2.2 14b animate replace</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.2-14b-animate-move-image-to-video">alibaba/wan2.2-14b-animate-move</a></td><td>Alibaba Cloud</td><td></td><td><a href="/api-references/video-models/alibaba-cloud/wan-2.2-14b-animate-move-image-to-video">Wan 2.2 14b animate move</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan2.2-vace-fun-a14b-reframe-image-to-video">alibaba/wan2.2-vace-fun-a14b-reframe</a></td><td>Alibaba Cloud</td><td></td><td><a href="/api-references/video-models/alibaba-cloud/wan2.2-vace-fun-a14b-reframe-image-to-video">Wan 2.2 vace fun 14b reframe</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan2.2-vace-fun-a14b-outpainting-image-to-video">alibaba/wan2.2-vace-fun-a14b-outpainting</a></td><td>Alibaba Cloud</td><td></td><td><a href="/api-references/video-models/alibaba-cloud/wan2.2-vace-fun-a14b-outpainting-image-to-video">Wan 2.2 vace fun 14b outpainting</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan2.2-vace-fun-a14b-inpainting-image-to-video">alibaba/wan2.2-vace-fun-a14b-inpainting</a></td><td>Alibaba Cloud</td><td></td><td><a href="/api-references/video-models/alibaba-cloud/wan2.2-vace-fun-a14b-inpainting-image-to-video">Wan 2.2 vace fun 14b inpainting</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan2.2-vace-fun-a14b-pose-image-to-video">alibaba/wan2.2-vace-fun-a14b-pose</a></td><td>Alibaba Cloud</td><td></td><td><a href="/api-references/video-models/alibaba-cloud/wan2.2-vace-fun-a14b-pose-image-to-video">Wan 2.2 vace fun 14b pose</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.5-preview-text-to-video">alibaba/wan2.5-t2v-preview</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-5-t2i-preview">Wan 2.5 Preview</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.5-preview-image-to-video">alibaba/wan2.5-i2v-preview</a></td><td>Alibaba Cloud</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.6-text-to-video">alibaba/wan-2-6-t2v</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-6-text-to-video">Wan 2.6 Text-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.6-image-to-video">alibaba/wan-2-6-i2v</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-6-image-to-video">Wan 2.6 Image-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.6-reference-to-video">alibaba/wan-2-6-r2v</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-6-reference-to-video">Wan 2.6 Reference-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.6-flash-image-to-video">alibaba/wan-2-6-image-to-video-flash</a></td><td>Alibaba Cloud</td><td></td><td>Wan 2.6 Image-to-Video Flash</td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/happy-horse-1.0">alibaba/happyhorse-1-0</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/happy-horse">Happy Horse 1.0</a></td></tr><tr><td><a href="/api-references/video-models/minimax-ai/recast">minimax/h3-max-recast</a></td><td>Minimax AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.7-text-to-video">alibaba/wan-2-7-t2v</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-7-video">Wan 2.7</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.7-image-to-video">alibaba/wan-2-7-i2v</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-7-video">Wan 2.7</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-2.7-reference-to-video">alibaba/wan-2-7-r2v</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/wan-2-7-video"><em>Wan 2.7</em></a></td></tr><tr><td><a href="/api-references/video-models/bytedance/seedance-1.0-pro-text-to-video">bytedance/seedance-1-0-pro-t2v</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedance-1-0-pro">Seedance 1.0 Pro</a></td></tr><tr><td><a href="/api-references/video-models/bytedance/seedance-1.0-pro-image-to-video">bytedance/seedance-1-0-pro-i2v</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedance-1-0-pro">Seedance 1.0 Pro</a></td></tr><tr><td><a href="/api-references/video-models/bytedance/seedance-1.0-pro-fast">bytedance/seedance-1-0-pro-fast</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedance-1-0-pro-fast">Seedance 1.0 Pro Fast</a></td></tr><tr><td><a href="/api-references/video-models/bytedance/omnihuman">bytedance/omnihuman</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/omnihuman">OmniHuman</a></td></tr><tr><td><a href="/api-references/video-models/bytedance/omnihuman-1.5">bytedance/omnihuman/v1.5</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/omnihuman-v1-5">OmniHuman v1.5</a></td></tr><tr><td><a href="/api-references/video-models/bytedance/seedance-1.5-pro">bytedance/seedance-1-5-pro</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedance-1-5-pro">Seedance 1.5 Pro</a></td></tr><tr><td><a href="/api-references/video-models/bytedance/seedance-2.0">bytedance/seedance-2-0</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedance-2">Seedance 2.0</a></td></tr><tr><td><a href="/api-references/video-models/bytedance/seedance-2.5">bytedance/seedance-2-5</a></td><td>ByteDance</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/bytedance/dreamina-seedance-2-5">bytedance/dreamina-seedance-2-5</a></td><td>ByteDance</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/google/gemini-omni-flash-preview">google/gemini-omni-flash-preview</a></td><td>Google</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/google/gemini-omni-1-1-flash">google/gemini-omni-1.1-flash</a></td><td>Google</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/google/gemini-omni-1.2-flash">google/gemini-omni-1.2-flash</a></td><td>Google</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/bytedance/seedance-2-0-mini">bytedance/dreamina-seedance-2-0-mini</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedance-2-0-mini">Seedance 2.0 Mini</a></td></tr><tr><td><a href="/api-references/video-models/bytedance/seedance-2.0-fast">bytedance/seedance-2-0-fast</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedance-2-fast">Seedance 2.0 Fast</a></td></tr><tr><td><a href="/api-references/video-models/alibaba-cloud/wan-3-0-video">alibaba/wan-3-0-video</a></td><td>Alibaba Cloud</td><td></td><td>-</td></tr><tr><td><a href="broken://pages/bNrucwrctbpfOI2D2els">alibaba/wan3.0-video</a></td><td>Alibaba Cloud</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/google/veo-3-1-text-to-video">google/veo-3.1-t2v</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-1-text-to-video">Veo 3.1 Text-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/google/veo-3-1-text-to-video-fast">google/veo-3.1-t2v-fast</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-1-fast-text-to-video">Veo 3.1 Fast Text-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/google/veo-3-1-image-to-video">google/veo-3.1-i2v</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-1-image-to-video">Veo 3.1 Image-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/google/veo-3-1-image-to-video-fast">google/veo-3.1-i2v-fast</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-1-fast-image-to-video">Veo 3.1 Fast Image-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/google/veo-3-1-reference-to-video">google/veo-3.1-reference-to-video</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-1-reference-to-video">Veo 3.1 Reference-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/google/veo-3-1-first-last-image-to-video">google/veo-3.1-first-last-image-to-video</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-1-first-last-frame-to-video">Veo 3.1 First-Last Frame-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/google/veo-3-1-first-last-image-to-video-fast">google/veo-3.1-first-last-image-to-video-fast</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-1-fast-first-last-frame-to-video">Veo 3.1 Fast First-Last Frame-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/google/veo-3.1-extend-video">google/veo3-1-extend-video</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-1-extend-video">Veo 3.1 Extend Video</a></td></tr><tr><td><a href="/api-references/video-models/google/veo-3.1-fast-extend-video">google/veo3-1-fast-extend-video</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-1-fast-extend-video">Veo 3.1 Fast Extend Video</a></td></tr><tr><td><a href="/api-references/video-models/google/veo-3.1-lite-generate-preview">google/veo-3-1-lite-generate-preview</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-1-lite">Veo 3.1 Lite</a></td></tr><tr><td><a href="/api-references/video-models/google/veo-3.1-lite-generate">google/veo-3.1-lite-generate-001</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-1-lite">Veo 3.1 Lite</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/v2.5-turbo-pro-image-to-video">klingai/v2.5-turbo/pro/image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-v2-5-turbo-pro-i2v">Kling Video v2.5 Turbo Pro Image-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/v2.5-turbo-pro-text-to-video">klingai/v2.5-turbo/pro/text-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-v2-5-turbo-pro-t2v">Kling Video v2.5 Turbo Pro Text-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/avatar-standard">klingai/avatar-standard</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-ai-avatar-standard">Kling AI Avatar Standard</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/avatar-pro">klingai/avatar-pro</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-ai-avatar-pro">Kling AI Avatar Pro</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/video-v2-6-pro-text-to-video">klingai/video-v2-6-pro-text-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-2-6-pro-text-to-video">Kling 2.6 Pro Text-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/video-v2.6-pro-image-to-video">klingai/video-v2-6-pro-image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-2-6-pro-image-to-video">Kling 2.6 Pro Image-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/video-o1-image-to-video">klingai/video-o1-image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-o1-image-to-video">Kling Video O1 Image to Video</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/video-o1-reference-to-video">klingai/video-o1-reference-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-o1-reference-to-video">Kling Video O1 Reference-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/video-o1-video-to-video-edit">klingai/video-o1-video-to-video-edit</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-o1-video-to-video-edit">Kling Video O1 Video to Video Edit</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/video-o1-video-to-video-reference">klingai/video-o1-video-to-video-reference</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-o1-video-to-video-reference">Kling Video O1 Video-to-Video Reference</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/v3-standard-text-to-video">klingai/video-v3-standard-text-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-v3-standard">Kling Video v3 Standard</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/v3-standard-image-to-video">klingai/video-v3-standard-image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-v3-standard">Kling Video v3 Standard</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/v3-omni-720p-image-to-video">klingai/video-v3-omni-720p-image-to-video</a></td><td>Kling AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/kling-ai/v3-omni-1080p-image-to-video">klingai/video-v3-omni-1080p-image-to-video</a></td><td>Kling AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/kling-ai/v3-pro-text-to-video">klingai/video-v3-pro-text-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-v3-pro">Kling Video v3 Pro</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/v3-omni-720p-text-to-video">klingai/video-v3-omni-720p-text-to-video</a></td><td>Kling AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/kling-ai/v3-omni-1080p-text-to-video">klingai/video-v3-omni-1080p-text-to-video</a></td><td>Kling AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/kling-ai/v3-pro-image-to-video">klingai/video-v3-pro-image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-v3-pro">Kling Video v3 Pro</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/v3-turbo-pro-image-to-video">klingai/video-v3-turbo-pro-image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-v3-standard-turbo-image-to-video">Kling Video V3 Standard Turbo Image to Video</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/v4-image-to-video">kling-video/v4/image-to-video</a></td><td>Kling AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/kling-ai/v3-turbo-pro-text-to-video">klingai/video-v3-turbo-pro-text-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-v3-turbo-pro-text-to-video">Kling Video V3 Turbo Pro Text to Video</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/v4-text-to-video">kling-video/v4/text-to-video</a></td><td>Kling AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/kling-ai/v3-standard-text-to-video">klingai/video-v3-standard-turbo-text-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-v3-standard-turbo-text-to-video">Kling Video V3 Standard Turbo Text to Video</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/v3-turbo-pro-image-to-video">klingai/video-v3-turbo-pro-image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-v3-turbo-pro-image-to-video">Kling Video V3 Turbo Pro Image to Video</a></td></tr><tr><td><a href="/api-references/video-models/kling-ai/v4-reference-to-video">kling-video/v4/reference-to-video</a></td><td>Kling AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/kling-ai/v4-video-to-video-edit">kling-video/v4/video-to-video/edit</a></td><td>Kling AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/krea/krea-wan-14b-text-to-video">krea/krea-wan-14b/text-to-video</a></td><td>Krea</td><td></td><td><a href="https://aimlapi.com/models/krea-wan-14b-text-to-video">Krea WAN 14B Text-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/krea/krea-wan-14b-video-to-video">krea/krea-wan-14b/video-to-video</a></td><td>Krea</td><td></td><td><a href="https://aimlapi.com/models/krea-wan-14b-video-to-video">Krea WAN 14B Video-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/beeble/switchx-video-to-video">beeble/switchx-video-to-video</a></td><td>Beeble</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/ltxv/ltxv-2">ltxv/ltxv-2</a></td><td>LTXV</td><td></td><td><a href="https://aimlapi.com/models/ltxv-2-text-to-video">LTXV 2</a></td></tr><tr><td><a href="/api-references/video-models/ltxv/ltxv-2-fast">ltxv/ltxv-2-fast</a></td><td>LTXV</td><td></td><td><a href="https://aimlapi.com/models/ltxv-2-fast-text-to-video">LTXV 2 Fast</a></td></tr><tr><td><a href="/api-references/video-models/luma-ai/luma-ray-2">luma/ray-2</a></td><td>Luma AI</td><td></td><td><a href="https://aimlapi.com/models/ray-2">Ray 2</a></td></tr><tr><td><a href="/api-references/video-models/luma-ai/luma-ray-flash-2">luma/ray-flash-2</a></td><td>Luma AI</td><td></td><td><a href="https://aimlapi.com/models/ray-flash-2">Ray Flash 2</a></td></tr><tr><td><a href="/api-references/video-models/luma-ai/ray-3.2">luma/ray-3.2</a></td><td>Luma AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/magic/text-to-video">magic/text-to-video</a></td><td>Magic</td><td></td><td><a href="https://aimlapi.com/models/magic-video">Magic Video</a></td></tr><tr><td>magic/image-to-video</td><td>Magic</td><td></td><td><a href="https://aimlapi.com/models/magic-video">Magic Video</a></td></tr><tr><td><a href="/api-references/video-models/magic/video-to-video">magic/video-to-video</a></td><td>Magic</td><td></td><td><a href="https://aimlapi.com/models/magic-video">Magic Video</a></td></tr><tr><td><a href="/api-references/video-models/minimax/video-01">video-01</a></td><td>MiniMax</td><td></td><td><a href="https://aimlapi.com/models/minimax-video-01-api">MiniMax Video-01</a></td></tr><tr><td><a href="/api-references/video-models/minimax/video-01-live2d">video-01-live2d</a></td><td>MiniMax</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/minimax/hailuo-02">minimax/hailuo-02</a></td><td>MiniMax</td><td></td><td><a href="https://aimlapi.com/models/hailuo-02">Hailuo 02</a></td></tr><tr><td><a href="/api-references/video-models/minimax/h3">minimax/h3</a></td><td>Minimax AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/minimax-ai/minimax-h3-highspeed">minimax/h3-highspeed</a></td><td>Minimax AI</td><td></td><td><a href="https://platform.minimax.io/docs/api-reference/video-generation-v2-create">MiniMax H3 Highspeed</a></td></tr><tr><td><a href="/api-references/video-models/minimax-ai/minimax-h3-lite">minimax/h3-lite</a></td><td>Minimax AI</td><td></td><td><a href="https://platform.minimax.io/docs/api-reference/video-generation-v2-create">MiniMax H3 Lite</a></td></tr><tr><td><a href="/api-references/video-models/minimax/h3-max">minimax/h3-max</a></td><td>Minimax AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/minimax/hailuo-2.3">minimax/hailuo-2.3</a></td><td>MiniMax</td><td></td><td><a href="https://aimlapi.com/models/hailuo-2-3">Hailuo 2.3</a></td></tr><tr><td><a href="/api-references/video-models/minimax/hailuo-2.3-fast">minimax/hailuo-2.3-fast</a></td><td>MiniMax</td><td></td><td><a href="https://aimlapi.com/models/hailuo-2-3-fast">Hailuo 2.3 Fast</a></td></tr><tr><td><a href="/api-references/video-models/pixverse/v5-text-to-video">pixverse/v5/text-to-video</a></td><td>PixVerse</td><td></td><td><a href="https://aimlapi.com/models/pixverse-v5-t2v">Pixverse v5 Text-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/pixverse/v5-image-to-video">pixverse/v5/image-to-video</a></td><td>PixVerse</td><td></td><td><a href="https://aimlapi.com/models/pixverse-v5-i2v">Pixverse v5 Image-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/pixverse/v5-transition">pixverse/v5/transition</a></td><td>PixVerse</td><td></td><td><a href="https://aimlapi.com/models/pixverse-v5-transition">Pixverse v5 Transition</a></td></tr><tr><td><a href="/api-references/video-models/pixverse/v5-5-text-to-video">pixverse/v5-5-text-to-video</a></td><td>PixVerse</td><td></td><td><a href="https://aimlapi.com/models/pixverse-v5-5-text-to-video">PixVerse V5.5 Text-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/pixverse/v5-5-image-to-video">pixverse/v5-5-image-to-video</a></td><td>PixVerse</td><td></td><td><a href="https://aimlapi.com/models/pixverse-v5-5-image-to-video">Pixverse v5.5 Image-to-Video</a></td></tr><tr><td><a href="/api-references/video-models/pixverse/lip-sync">pixverse/lip-sync</a></td><td>PixVerse</td><td></td><td><em>-</em></td></tr><tr><td><a href="/api-references/video-models/pixverse/text-to-video">pixverse/v6-max/text-to-video</a></td><td>Pixverse</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/runway/gen4_turbo">runway/gen4_turbo</a></td><td>Runway</td><td></td><td><a href="https://aimlapi.com/models/runway-gen-4-turbo-api">Runway Gen-4 Turbo</a></td></tr><tr><td><a href="/api-references/video-models/runway/act_two">runway/act_two</a></td><td>Runway</td><td></td><td><a href="https://aimlapi.com/models/runway-act-two">Runway Act Two</a></td></tr><tr><td><a href="/api-references/video-models/sber-ai/kandinsky5-text-to-video">sber-ai/kandinsky5-t2v</a></td><td>Sber AI</td><td></td><td><a href="https://aimlapi.com/models/kandinsky-5-standard">Kandinsky 5 Standard</a></td></tr><tr><td><a href="/api-references/video-models/sber-ai/kandinsky5-distill-text-to-video">sber-ai/kandinsky5-distill-t2v</a></td><td>Sber AI</td><td></td><td><a href="https://aimlapi.com/models/kandinsky-5-distill">Kandinsky 5 Distill</a></td></tr><tr><td><a href="/api-references/video-models/tencent/hunyuan-video-foley">tencent/hunyuan-video-foley</a></td><td>Tencent</td><td></td><td><a href="https://aimlapi.com/models/hunyuanvideo-foley">HunyuanVideo Foley</a></td></tr><tr><td><a href="/api-references/video-models/veed/fabric-1.0">veed/fabric-1.0</a></td><td>Veed</td><td></td><td><a href="/api-references/video-models/veed/fabric-1.0">fabric-1.0</a></td></tr><tr><td><a href="/api-references/video-models/xai/grok-imagine-video">x-ai/grok-imagine-video</a></td><td>xAI</td><td></td><td><a href="https://aimlapi.com/models/grok-imagine-video">Grok Imagine Video</a></td></tr><tr><td><a href="/api-references/video-models/xai/grok-imagine-video-1.5-preview">x-ai/grok-imagine-video-1.5-preview</a></td><td>xAI</td><td></td><td><a href="https://aimlapi.com/models/grok-imagine-video-1-5-preview">Grok Imagine Video 1.5</a></td></tr><tr><td><a href="/api-references/video-models/black-forest-labs/flux-3-video-draft-i2v">blackforestlabs/flux-3-video-draft-i2v</a></td><td>Black Forest Labs</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/black-forest-labs/flux-3-video-i2v">blackforestlabs/flux-3-video-i2v</a></td><td>Black Forest Labs</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/black-forest-labs/flux-3-video-draft-t2v">blackforestlabs/flux-3-video-draft-t2v</a></td><td>Black Forest Labs</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/black-forest-labs/flux-3-video-t2v">blackforestlabs/flux-3-video-t2v</a></td><td>Black Forest Labs</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/black-forest-labs/flux-3-video-draft-v2v">blackforestlabs/flux-3-video-draft-v2v</a></td><td>Black Forest Labs</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/black-forest-labs/flux-3-video-v2v">blackforestlabs/flux-3-video-v2v</a></td><td>Black Forest Labs</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/heygen/avatar-iii">heygen/avatar-iii</a></td><td>HeyGen</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/heygen/avatar-iv">heygen/avatar-iv</a></td><td>HeyGen</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/heygen/avatar-v">heygen/avatar-v</a></td><td>HeyGen</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/heygen/image-to-video">heygen/image-to-video</a></td><td>HeyGen</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/heygen/lipsync-precision">heygen/lipsync-precision</a></td><td>HeyGen</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/heygen/lipsync-speed">heygen/lipsync-speed</a></td><td>HeyGen</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/heygen/video-1-image-to-video">heygen/video-1-image-to-video</a></td><td>HeyGen</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/heygen/video-1-reference-to-video">heygen/video-1-reference-to-video</a></td><td>HeyGen</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/heygen/video-1-text-to-video">heygen/video-1-text-to-video</a></td><td>HeyGen</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/heygen/video-translation-audio-only">heygen/video-translation-audio-only</a></td><td>HeyGen</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/heygen/video-translation-precision">heygen/video-translation-precision</a></td><td>HeyGen</td><td></td><td>-</td></tr><tr><td><a href="/api-references/video-models/heygen/video-translation-speed">heygen/video-translation-speed</a></td><td>HeyGen</td><td></td><td>-</td></tr></tbody></table>

### Voice/Speech Models

#### Speech-to-Text

<table data-header-hidden="false" data-header-sticky data-full-width="true"><thead><tr><th width="266.20001220703125">Model ID + API Reference link</th><th width="132.79998779296875">Developer</th><th width="103.5999755859375">Context</th><th>Model Card</th></tr></thead><tbody><tr><td><a href="/api-references/speech-models/speech-to-text/assembly-ai/slam-1">aai/slam-1</a></td><td>Assembly AI</td><td></td><td><a href="https://aimlapi.com/models/slam-1">Slam 1</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/assembly-ai/universal">aai/universal</a></td><td>Assembly AI</td><td></td><td><a href="https://aimlapi.com/models/universal">Universal</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/deepgram/nova-3">nova-3</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/deepgram-nova-3">Nova-3</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/deepgram/nova-3-general">nova-3-general</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/deepgram-nova-3-general">Nova-3 General</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/deepgram/nova-3-medical">nova-3-medical</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/deepgram-nova-3-medical">Nova-3 Medical</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/deepgram/nova-2">#g1_nova-2-automotive</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/deepgram-nova-2">Deepgram Nova-2</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/deepgram/nova-2">#g1_nova-2-conversationalai</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/deepgram-nova-2">Deepgram Nova-2</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/deepgram/nova-2">#g1_nova-2-drivethru</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/deepgram-nova-2">Deepgram Nova-2</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/deepgram/nova-2">#g1_nova-2-finance</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/deepgram-nova-2">Deepgram Nova-2</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/deepgram/nova-2">#g1_nova-2-general</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/deepgram-nova-2">Deepgram Nova-2</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/deepgram/nova-2">#g1_nova-2-medical</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/deepgram-nova-2">Deepgram Nova-2</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/deepgram/nova-2">#g1_nova-2-meeting</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/deepgram-nova-2">Deepgram Nova-2</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/deepgram/nova-2">#g1_nova-2-phonecall</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/deepgram-nova-2">Deepgram Nova-2</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/deepgram/nova-2">#g1_nova-2-video</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/deepgram-nova-2">Deepgram Nova-2</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/deepgram/nova-2">#g1_nova-2-voicemail</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/deepgram-nova-2">Deepgram Nova-2</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/openai/whisper-tiny">#g1_whisper-tiny</a></td><td>OpenAI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/openai/whisper-small">#g1_whisper-small</a></td><td>OpenAI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/openai/whisper-base">#g1_whisper-base</a></td><td>OpenAI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/openai/whisper-medium">#g1_whisper-medium</a></td><td>OpenAI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/openai/whisper-large">#g1_whisper-large</a></td><td>OpenAI</td><td></td><td><a href="https://aimlapi.com/models/whisper">Whisper</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/openai/gpt-4o-transcribe">openai/gpt-4o-transcribe</a></td><td>OpenAI</td><td></td><td><a href="https://aimlapi.com/models/gpt-4o-transcribe">GPT-4o Transcribe</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/openai/gpt-4o-mini-transcribe">openai/gpt-4o-mini-transcribe</a></td><td>OpenAI</td><td></td><td><a href="https://aimlapi.com/models/gpt-4o-mini-transcribe">GPT-4o Mini Transcribe</a></td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/elevenlabs/scribe_v2">elevenlabs/scribe_v2</a></td><td>Elevenlabs</td><td></td><td>-</td></tr><tr><td><a href="/api-references/speech-models/speech-to-text/google/gemini-3.5-transcribe">google/gemini-3.5-transcribe</a></td><td>Google</td><td></td><td>-</td></tr></tbody></table>

#### Text-to-Speech

<table data-header-hidden="false" data-header-sticky><thead><tr><th width="284.4000244140625">Model ID</th><th width="132.79998779296875">Developer</th><th width="112">Context</th><th>Model Card</th></tr></thead><tbody><tr><td><a href="/api-references/speech-models/text-to-speech/alibaba-cloud/qwen3-tts-flash">alibaba/qwen3-tts-flash</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/qwen3-tts-flash">Qwen3-TTS-Flash</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura">#g1_aura-angus-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura">Aura</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura">#g1_aura-arcas-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura">Aura</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura">#g1_aura-asteria-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura">Aura</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura">#g1_aura-athena-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura">Aura</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura">#g1_aura-helios-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura">Aura</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura">#g1_aura-hera-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura">Aura</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura">#g1_aura-luna-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura">Aura</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura">#g1_aura-orion-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura">Aura</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura">#g1_aura-orpheus-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura">Aura</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura">#g1_aura-perseus-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura">Aura</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura">#g1_aura-stella-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura">Aura</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura">#g1_aura-zeus-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura">Aura</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-amalthea-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-andromeda-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-apollo-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-arcas-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-aries-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-asteria-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-athena-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-atlas-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-aurora-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-callista-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-cora-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-cordelia-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-delia-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-draco-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-electra-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-harmonia-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-helena-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-hera-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-hermes-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-hyperion-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-iris-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-janus-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-juno-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-jupiter-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-luna-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-mars-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-minerva-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-neptune-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-odysseus-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-ophelia-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-orion-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-orpheus-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-pandora-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-phoebe-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-pluto-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-saturn-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-selene-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-thalia-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-theia-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-vesta-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-zeus-en</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-celeste-es</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-estrella-es</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/deepgram/aura-2">#g1_aura-2-nestor-es</a></td><td>Deepgram</td><td></td><td><a href="https://aimlapi.com/models/aura-2">Aura 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/elevenlabs/eleven_multilingual_v2">elevenlabs/eleven_multilingual_v2</a></td><td>ElevenLabs</td><td></td><td><a href="https://aimlapi.com/models/eleven-multilingual-v2">ElevenLabs Multilingual v2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/elevenlabs/eleven_turbo_v2_5">elevenlabs/eleven_turbo_v2_5</a></td><td>ElevenLabs</td><td></td><td><a href="https://aimlapi.com/models/eleven-turbo-v2-5">ElevenLabs Turbo v2.5</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/hume-ai/octave-2">hume/octave-2</a></td><td>Hume AI</td><td></td><td><a href="https://aimlapi.com/models/octave-2">Octave 2</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/inworld/tts-1">inworld/tts-1</a></td><td>Inworld</td><td></td><td><a href="https://aimlapi.com/models/inworld-tts-1">Inworld TTS-1</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/inworld/tts-1-max">inworld/tts-1-max</a></td><td>Inworld</td><td></td><td><a href="https://aimlapi.com/models/inworld-tts-1-max">Inworld TTS-1-Max</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/inworld/tts-1-5-mini">inworld/tts-1-5-mini</a></td><td>Inworld</td><td></td><td><a href="https://aimlapi.com/models/inworld-tts-1-5-mini">Inworld TTS-1.5-Mini</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/inworld/tts-1-5-max">inworld/tts-1-5-max</a></td><td>Inworld</td><td></td><td><em>Coming Soon</em></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/microsoft/vibevoice-1.5b">microsoft/vibevoice-1.5b</a></td><td>Microsoft</td><td></td><td><a href="https://aimlapi.com/models/vibevoice-1-5b">VibeVoice 1.5B</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/microsoft/vibevoice-7b">microsoft/vibevoice-7b</a></td><td>Microsoft</td><td></td><td><a href="https://aimlapi.com/models/vibevoice-7b">VibeVoice 7B</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/heygen/voice-1">heygen/voice-1</a></td><td>HeyGen</td><td></td><td>-</td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/elevenlabs/eleven_v4">elevenlabs/eleven_v4</a></td><td>Elevenlabs</td><td></td><td>-</td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/elevenlabs/eleven_v4_turbo">elevenlabs/eleven_v4_turbo</a></td><td>Elevenlabs</td><td></td><td>-</td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/bytedance/seed-audio-1.0">bytedance/seed-audio-1-0</a></td><td>ByteDance</td><td></td><td>-</td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/openai/tts-1">openai/tts-1</a></td><td>OpenAI</td><td></td><td><a href="https://aimlapi.com/models/tts-1">TTS-1</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/openai/tts-1-hd">openai/tts-1-hd</a></td><td>OpenAI</td><td></td><td><a href="https://aimlapi.com/models/tts-1-hd">TTS-1 HD</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/openai/gpt-4o-mini-tts">openai/gpt-4o-mini-tts</a></td><td>OpenAI</td><td></td><td><a href="https://aimlapi.com/models/gpt-4o-mini-tts">GPT-4o-mini-TTS</a></td></tr><tr><td><a href="/api-references/speech-models/text-to-speech/heygen/voice-1-turbo">heygen/voice-1-turbo</a></td><td>HeyGen</td><td></td><td>-</td></tr></tbody></table>

#### Voice Chat

<table data-header-hidden="false" data-header-sticky data-full-width="true"><thead><tr><th width="284.4000244140625">Model ID</th><th width="132.79998779296875">Developer</th><th width="105.5999755859375">Context</th><th>Model Card</th></tr></thead><tbody><tr><td><a href="/api-references/speech-models/voice-chat/elevenlabs/v3_alpha">elevenlabs/v3_alpha</a></td><td>ElevenLabs</td><td></td><td><a href="https://aimlapi.com/models/eleven-v3-alpha">Eleven v3 Alpha</a></td></tr><tr><td><a href="/api-references/speech-models/voice-chat/minimax/speech-2.5-turbo-preview">minimax/speech-2.5-turbo-preview</a></td><td>MiniMax</td><td></td><td><a href="https://aimlapi.com/models/minimax-speech-2-5-turbo">MiniMax Speech 2.5 Turbo</a></td></tr><tr><td><a href="/api-references/speech-models/voice-chat/minimax/speech-2.5-hd-preview">minimax/speech-2.5-hd-preview</a></td><td>MiniMax</td><td></td><td><a href="https://aimlapi.com/models/minimax-speech-2-5-hd">MiniMax Speech 2.5 HD</a></td></tr><tr><td><a href="/api-references/speech-models/voice-chat/minimax/speech-2.6-turbo">minimax/speech-2.6-turbo</a></td><td>MiniMax</td><td></td><td><a href="https://aimlapi.com/models/minimax-speech-2-6-turbo">MiniMax Speech 2.6 Turbo</a></td></tr><tr><td><a href="/api-references/speech-models/voice-chat/minimax/speech-2.6-hd">minimax/speech-2.6-hd</a></td><td>MiniMax</td><td></td><td><a href="https://aimlapi.com/models/minimax-speech-2-6-hd">MiniMax Speech 2.6 HD</a></td></tr><tr><td><a href="/api-references/speech-models/voice-chat/minimax/speech-2.8-turbo">minimax/speech-2.8-turbo</a></td><td>MiniMax</td><td></td><td><a href="https://aimlapi.com/models/minimax-speech-2-8-turbo">Speech 2.8 Turbo</a></td></tr><tr><td><a href="/api-references/speech-models/voice-chat/minimax/speech-2.8-hd">minimax/speech-2.8-hd</a></td><td>MiniMax</td><td></td><td><a href="https://aimlapi.com/models/minimax-speech-2-8-hd">Speech 2.8 HD</a></td></tr></tbody></table>

### Realtime Models

<table data-header-hidden="false" data-header-sticky data-full-width="true"><thead><tr><th width="284.4000244140625">Model ID + API Reference link</th><th width="132.79998779296875">Developer</th><th width="105.5999755859375">Context</th><th>Model Card</th></tr></thead><tbody><tr><td><a href="/api-references/realtime-models/openai/gpt-realtime-2.1">openai/gpt-realtime-2.1</a></td><td>OpenAI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/realtime-models/openai/gpt-realtime-2.1-mini">openai/gpt-realtime-2.1-mini</a></td><td>OpenAI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/realtime-models/openai/gpt-live-1">openai/gpt-live-1</a></td><td>OpenAI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/realtime-models/xai/grok-voice-think-fast-2.0">x-ai/grok-voice-think-fast-2.0</a></td><td>xAI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/realtime-models/google/gemini-3.8-live">google/gemini-3.8-live</a></td><td>Google</td><td></td><td>-</td></tr></tbody></table>

### Music Models

<table data-header-hidden="false" data-header-sticky data-full-width="true"><thead><tr><th width="266.20001220703125">Model ID</th><th width="134.4000244140625">Developer</th><th width="102.60009765625">Context</th><th>Model Card</th></tr></thead><tbody><tr><td><a href="/api-references/music-models/elevenlabs/eleven_music">elevenlabs/eleven_music</a></td><td>ElevenLabs</td><td></td><td><a href="https://aimlapi.com/models/elevenmusic">Eleven Music</a></td></tr><tr><td><a href="/api-references/music-models/elevenlabs/eleven_music_v2_5">elevenlabs/eleven_music_v2_5</a></td><td>Elevenlabs</td><td></td><td>-</td></tr><tr><td><a href="/api-references/music-models/google/lyria-2">google/lyria2</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/lyria-2">Lyria 2</a></td></tr><tr><td><a href="/api-references/music-models/stability-ai/stable-audio">stable-audio</a></td><td>Stability AI</td><td></td><td><a href="https://aimlapi.com/models/stable-audio">Stable Audio</a></td></tr><tr><td><a href="/api-references/music-models/minimax/minimax-music-legacy">minimax-music</a></td><td>Minimax AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/music-models/minimax/music-1.5">minimax/music-1.5</a></td><td>Minimax AI</td><td></td><td><a href="https://aimlapi.com/models/minimax-music-1-5">MiniMax Music 1.5</a></td></tr><tr><td><a href="/api-references/music-models/minimax/music-2.0">minimax/music-2.0</a></td><td>Minimax AI</td><td></td><td><a href="https://aimlapi.com/models/minimax-music-2-0">MiniMax Music 2.0</a></td></tr><tr><td><a href="/api-references/music-models/mureka/region-edit">mureka/region-edit</a></td><td>Mureka</td><td></td><td><a href="https://www.mureka.ai">Mureka Region Edit</a></td></tr><tr><td><a href="/api-references/music-models/mureka/remix">mureka/v8/remix</a></td><td>Mureka</td><td></td><td><a href="https://www.mureka.ai">Mureka 8 Remix</a></td></tr><tr><td><a href="/api-references/music-models/mureka/instrumental">mureka/v9.5/instrumental</a></td><td>Mureka</td><td></td><td><a href="https://www.mureka.ai">Mureka V9.5 Instrumental</a></td></tr><tr><td><a href="/api-references/music-models/mureka/extend">mureka/v8/extend</a></td><td>Mureka</td><td></td><td><a href="https://www.mureka.ai">Mureka 8 Extend</a></td></tr><tr><td><a href="/api-references/music-models/mureka/transcribe">mureka/transcribe</a></td><td>Mureka</td><td></td><td><a href="https://www.mureka.ai">Mureka Transcribe</a></td></tr><tr><td><a href="/api-references/music-models/mureka/v9.5">mureka/v9.5</a></td><td>Mureka</td><td></td><td><a href="https://www.mureka.ai">Mureka V9.5</a></td></tr><tr><td><a href="/api-references/music-models/mureka/describe">mureka/describe</a></td><td>Mureka</td><td></td><td><a href="https://www.mureka.ai">Mureka Describe</a></td></tr><tr><td><a href="/api-references/music-models/mureka/stem">mureka/stem</a></td><td>Mureka</td><td></td><td><a href="https://www.mureka.ai">Mureka Stem Separation</a></td></tr><tr><td><a href="/api-references/music-models/minimax/music-2-6">minimax/music-2.6</a></td><td>Minimax AI</td><td></td><td><a href="https://aimlapi.com/models/minimax-music-2-6">MiniMax Music 2.6</a></td></tr><tr><td><a href="/api-references/music-models/minimax/music-cover">minimax/music-cover</a></td><td>Minimax AI</td><td></td><td><em>Coming Soon</em></td></tr></tbody></table>

### Vision Models

#### Optical Character Recognition (OCR)

<table data-header-hidden="false" data-header-sticky data-full-width="true"><thead><tr><th width="266.20001220703125">Model ID + API Reference link</th><th width="132.79998779296875">Developer</th><th width="103.5999755859375">Context</th><th>Model Cardg</th></tr></thead><tbody><tr><td><a href="/api-references/vision-models/ocr-optical-character-recognition/google/google-ocr">gc-document-ai</a></td><td>Google</td><td></td><td>-</td></tr><tr><td><a href="/api-references/vision-models/ocr-optical-character-recognition/mistral-ai/mistral-ocr">mistral/mistral-ocr-latest</a></td><td>Mistral AI</td><td></td><td><a href="https://aimlapi.com/models/mistral-ocr-latest-api">Mistral OCR Latest</a></td></tr><tr><td><a href="/api-references/vision-models/ocr-optical-character-recognition/mistral-ai/mistral-ocr-4-0">mistral/mistral-ocr-4-0</a></td><td>Mistral AI</td><td></td><td>-</td></tr><tr><td><a href="/api-references/vision-models/ocr-optical-character-recognition/zhipu/glm-ocr">zhipu/glm-ocr</a></td><td>Zhipu</td><td></td><td><a href="https://aimlapi.com/models/glm-ocr">GLM-OCR</a></td></tr></tbody></table>

### 3D-Generating Models

<table data-header-hidden="false" data-header-sticky data-full-width="true"><thead><tr><th width="265.4000244140625">Model ID + API Reference link</th><th width="134.39996337890625">Developer</th><th width="104">Context</th><th>Model Card</th></tr></thead><tbody><tr><td><a href="/api-references/3d-generating-models/meshy/meshy-6-image-to-3d">meshy/meshy-6-image-to-3d</a></td><td>Meshy</td><td></td><td>-</td></tr><tr><td><a href="/api-references/3d-generating-models/tencent/hunyuan-part">tencent/hunyuan-part</a></td><td>Tencent</td><td></td><td><a href="https://aimlapi.com/models/hunyuan-part">Hunyuan Part</a></td></tr></tbody></table>

### Embedding Models

<table data-header-hidden="false" data-header-sticky data-full-width="true"><thead><tr><th width="274.20001220703125">Model ID + API Reference link</th><th width="124.20001220703125">Developer</th><th width="103.60009765625">Context</th><th>Model Card</th></tr></thead><tbody><tr><td><a href="/api-references/embedding-models/alibaba-cloud/qwen-text-embedding-v3">alibaba/qwen-text-embedding-v3</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-text-embedding-v3">Qwen Text Embedding v3</a></td></tr><tr><td><a href="/api-references/embedding-models/alibaba-cloud/qwen-text-embedding-v4">alibaba/qwen-text-embedding-v4</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-text-embedding-v4">Qwen Text Embedding v4</a></td></tr><tr><td><a href="/api-references/embedding-models/anthropic/voyage-2">voyage-2</a></td><td>Anthropic</td><td>4,000</td><td>-</td></tr><tr><td><a href="/api-references/embedding-models/anthropic/voyage-code-2">voyage-code-2</a></td><td>Anthropic</td><td>16,000</td><td>-</td></tr><tr><td><a href="/api-references/embedding-models/anthropic/voyage-finance-2">voyage-finance-2</a></td><td>Anthropic</td><td>32,000</td><td>-</td></tr><tr><td><a href="/api-references/embedding-models/anthropic/voyage-large-2">voyage-large-2</a></td><td>Anthropic</td><td>16,000</td><td>-</td></tr><tr><td><a href="/api-references/embedding-models/anthropic/voyage-large-2-instruct">voyage-large-2-instruct</a></td><td>Anthropic</td><td>16,000</td><td><a href="https://aimlapi.com/models/voyage-large-2-instruct-api">Voyage Large 2 Instruct</a></td></tr><tr><td><a href="/api-references/embedding-models/anthropic/voyage-law-2">voyage-law-2</a></td><td>Anthropic</td><td>16,000</td><td>-</td></tr><tr><td><a href="/api-references/embedding-models/anthropic/voyage-multilingual-2">voyage-multilingual-2</a></td><td>Anthropic</td><td>32,000</td><td>-</td></tr><tr><td><a href="/api-references/embedding-models/google/text-multilingual-embedding-002">text-multilingual-embedding-002</a></td><td>Google</td><td>2,000</td><td>-</td></tr><tr><td><a href="/api-references/embedding-models/openai/text-embedding-3-small">text-embedding-3-small</a></td><td>Open AI</td><td>8,000</td><td>-</td></tr><tr><td><a href="/api-references/embedding-models/openai/text-embedding-3-large">text-embedding-3-large</a></td><td>Open AI</td><td>8,000</td><td><a href="https://aimlapi.com/models/text-embedding-3-large">Text-embedding-3-large</a></td></tr><tr><td><a href="/api-references/embedding-models/openai/text-embedding-ada-002">text-embedding-ada-002</a></td><td>Open AI</td><td>8,000</td><td><a href="https://aimlapi.com/models/text-embedding-ada-002">Text-embedding-ada-002</a></td></tr></tbody></table>

***

### Decision Models

<table data-header-hidden="false" data-header-sticky data-full-width="true"><thead><tr><th width="274.20001220703125">Model ID + API Reference link</th><th width="124.20001220703125">Developer</th><th width="103.60009765625">Context</th><th>Model Card</th></tr></thead><tbody><tr><td><a href="/api-references/decision-models/typesafe/jev">typesafe/jev</a></td><td>TypeSafe AI</td><td>32 000</td><td>-</td></tr></tbody></table>

### <img src="https://3927338786-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FROMd1X5PuqtikJ48n2N9%2Fuploads%2Fgit-blob-bd52cb24a7111f901f5b2c34cbc9be2750893356%2Foffline-label.png?alt=media" alt="" data-size="line"> Deprecated / No Longer Supported Models

{% hint style="danger" %}
These models are no longer available for API or Playground calls.\
Their description and API reference pages have also been removed from this documentation portal.
{% endhint %}

<table data-header-hidden="false" data-header-sticky data-full-width="true"><thead><tr><th width="316">Model ID</th><th width="135">Developer</th><th width="102">Context</th><th>Model Card</th></tr></thead><tbody><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-3.5-turbo</a></td><td>Open AI</td><td>16,000</td><td><a href="https://aimlapi.com/models/chat-gpt-3-5">Chat GPT 3.5 Turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-3.5-turbo-0125</a></td><td>Open AI</td><td>16,000</td><td><a href="https://aimlapi.com/models/chat-gpt-3-5-turbo-0125">Chat GPT-3.5 Turbo 0125</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-3.5-turbo-1106</a></td><td>Open AI</td><td>16,000</td><td><a href="https://aimlapi.com/models/chat-gpt-3-5-turbo-1106">Chat GPT-3.5 Turbo 1106</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">o1</a></td><td>Open AI</td><td>200,000</td><td><a href="https://aimlapi.com/models/openai-o1-api">OpenAI o1</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">o3-mini</a></td><td>Open AI</td><td>200,000</td><td><a href="https://aimlapi.com/models/openai-o3-mini-api">OpenAI o3 mini</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/gpt-4.1-nano-2025-04-14</a></td><td>Open AI</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gpt-4-1-nano-api">GPT-4.1 Nano</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/o4-mini-2025-04-16</a></td><td>Open AI</td><td>200,000</td><td><a href="https://aimlapi.com/models/gpt-o4-mini-2025-04-16">GPT-o4-mini-2025-04-16</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/gpt-5-1-codex</a></td><td>Open AI</td><td>400,000</td><td><a href="https://aimlapi.com/models/gpt-5-1-codex">GPT-5.1 Codex</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/gpt-5-1-codex-mini</a></td><td>Open AI</td><td>400,000</td><td><a href="https://aimlapi.com/models/gpt-5-1-codex-mini">GPT-5.1 Codex Mini</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/gpt-5-2-chat-latest</a></td><td>Open AI</td><td>400,000</td><td><a href="https://aimlapi.com/models/gpt-5-2-chat-latest">GPT-5.2 Chat Latest</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/gpt-5-2-codex</a></td><td>Open AI</td><td>400,000</td><td><a href="https://aimlapi.com/models/gpt-5-2-codex">GPT-5.2 Codex</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">anthropic/claude-opus-4.1claude-opus-4-1claude-opus-4-1-20250805</a></td><td>Anthropic</td><td>200,000</td><td><a href="https://aimlapi.com/models/claude-opus-4-1">Claude Opus 4.1</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">claude-sonnet-4-5-20250929anthropic/claude-sonnet-4.5claude-sonnet-4-5</a></td><td>Anthropic</td><td>200,000</td><td><a href="https://aimlapi.com/models/claude-4-5-sonnet">Claude 4.5 Sonnet</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">anthropic/claude-haiku-4.5claude-haiku-4-5claude-haiku-4-5-20251001</a></td><td>Anthropic</td><td>200,000</td><td><a href="https://aimlapi.com/models/claude-4-5-haiku">Claude 4.5 Haiku</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">anthropic/claude-opus-4-5claude-opus-4-5claude-opus-4-5-20251101</a></td><td>Anthropic</td><td>200,000</td><td>Claude 4.5 Opus</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">anthropic/claude-sonnet-4.6anthropic/claude-sonnet-4-6-20260218</a></td><td>Anthropic</td><td>200,000</td><td><a href="https://aimlapi.com/models/claude-sonnet-4-6">Claude Sonnet 4.6</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">anthropic/claude-opus-4-7claude-opus-4-7</a></td><td>Anthropic</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/claude-opus-4-7">Claude Opus 4.7</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">anthropic/claude-opus-4-8claude-opus-4-8</a></td><td>Anthropic</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/claude-opus-4-8">Claude Opus 4.8</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">qwen-turbo</a></td><td>Alibaba Cloud</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/qwen-turbo-api">Qwen Turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">mistral/labs-leanstral-1-5</a></td><td>Mistral AI</td><td>256,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">alibaba/qwen3-next-80b-a3b-thinking</a></td><td>Alibaba Cloud</td><td>262,000</td><td><a href="https://aimlapi.com/models/qwen3-next-80b-a3b-thinking">Qwen3-Next-80B-A3B Thinking</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">alibaba/qwen3-max-preview</a></td><td>Alibaba Cloud</td><td>258,000</td><td>Qwen3-Max Preview</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">alibaba/qwen3-max-instruct</a></td><td>Alibaba Cloud</td><td>262,000</td><td>Qwen3-Max Instruct</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">qwen3-omni-30b-a3b-captioner</a></td><td>Alibaba Cloud</td><td>65,000</td><td>qwen3-omni-30b-a3b-captioner</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">alibaba/qwen3-vl-32b-instruct</a></td><td>Alibaba Cloud</td><td>126,000</td><td><a href="https://aimlapi.com/models/qwen3-vl-32b-instruct">Qwen3 VL 32B Instruct</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">alibaba/qwen3-vl-32b-thinking</a></td><td>Alibaba Cloud</td><td>126,000</td><td><a href="https://aimlapi.com/models/qwen3-vl-32b-thinking">Qwen3 VL 32B Thinking</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">alibaba/qwen3.6-max-preview</a></td><td>Alibaba Cloud</td><td>262,144</td><td><a href="https://aimlapi.com/models/qwen3-6-max-preview">Qwen3.6 Max Preview</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">deepseek-chat ordeepseek/deepseek-chat ordeepseek/deepseek-chat-v3-0324</a></td><td>DeepSeek</td><td>128,000</td><td><a href="https://aimlapi.com/models/deepseek-v3">DeepSeek V3</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">deepseek/deepseek-r1 ordeepseek-reasoner</a></td><td>DeepSeek</td><td>128,000</td><td><a href="https://aimlapi.com/models/deepseek-r1-api">DeepSeek R1</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/gemma-3n-e4b-it</a></td><td>Google</td><td>8,192</td><td><a href="https://aimlapi.com/models/gemma-3n-4b">Gemma 3n 4B</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/llama-3.3-70b-versatile</a></td><td>Meta</td><td>131,000</td><td>Llama 3.3 70B Versatile</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">MiniMax-Text-01</a></td><td>MiniMax</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/minimax-text-01-api">MiniMax-Text-01</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">upstage/solar-pro-3</a></td><td>Upstage</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">aimlapi/jev-router</a></td><td>AIMLAPI</td><td>1,050,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">alibaba/qwen-image-edit</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/qwen-image-edit">Qwen Image Edit</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">flux-pro/v1.1</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-1-1-pro-api">FLUX 1.1 [pro]</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">flux-pro/v1.1-ultra</a></td><td>Flux</td><td></td><td><a href="https://aimlapi.com/models/flux-1-1-pro-ultra-api">FLUX 1.1 [pro ultra]</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">imagen-3.0-generate-002</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/imagen-3-api">Imagen 3</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/imagen4/preview</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/imagen-4-preview">Imagen 4 Preview</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/imagen-4.0-generate-001</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/imagen-4-0-generate-001">Imagen 4.0 Generate</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/imagen-4.0-fast-generate-001</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/imagen-4-0-fast-generate-001">Imagen 4.0 Fast Generate</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/imagen-4.0-ultra-generate-001</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/imagen-4-0-ultra-generate-001">Imagen 4.0 Ultra Generate</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/nano-banana-progoogle/gemini-3-pro-image-preview</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/gemini-3-pro-image">Gemini 3 Pro Image (Nano Banana Pro)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/nano-banana-pro-editgoogle/gemini-3-pro-image-preview-edit</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/gemini-3-pro-image-edit">Gemini 3 Pro Image Edit (Nano Banana Pro)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/nano-banana-2google/gemini-3-1-flash-image-preview</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/nano-banana-2">Gemini 3.1 Flash Image (Nano Banana 2)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/gpt-image-1</a></td><td>OpenAI</td><td></td><td><a href="https://aimlapi.com/models/gpt-image-1">gpt-image-1</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">reve/create-image</a></td><td>Reve</td><td></td><td><a href="https://aimlapi.com/models/reve-create-image">Reve Create Image</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">reve/edit-image</a></td><td>Reve</td><td></td><td><a href="https://aimlapi.com/models/reve-edit-image">Reve Edit Image</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">reve/remix-edit-image</a></td><td>Reve</td><td></td><td><a href="https://aimlapi.com/models/reve-remix-image">Reve Remix Image</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">alibaba/wan2.2-vace-fun-14b-depth</a></td><td>Alibaba Cloud</td><td></td><td>Wan 2.2 vace fun 14b depth</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">alibaba/happyhorse-1.1</a></td><td>Alibaba Cloud</td><td></td><td><a href="https://aimlapi.com/models/happy-horse-1-1">Happy Horse 1.1</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">veo2</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-2-text-to-video-api">Veo2 Text-to-Video</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">veo2/image-to-video</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-2-image-to-video-api">Veo2 Image-to-Video</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/veo3</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3">Veo 3</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/veo-3.0-i2v</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-0-i2v">Veo 3 I2V</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/veo-3.0-fast</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-0-fast">Veo 3 Fast</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/veo-3.0-i2v-fast</a></td><td>Google</td><td></td><td><a href="https://aimlapi.com/models/veo-3-i2v-fast">Veo 3 I2V Fast</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kling-video/v1/standard/image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-ai-image-to-video">Kling AI (image-to-video)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kling-video/v1/pro/image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-ai-image-to-video">Kling AI (image-to-video)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kling-video/v1/pro/text-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-ai-text-to-video-api">Kling AI (text-to-video)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kling-video/v1.6/standard/text-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-1-6-standard">Kling 1.6 Standard</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kling-video/v1.6/standard/image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-1-6-standard">Kling 1.6 Standard</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kling-video/v1.6/pro/image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-1-6-pro-api">Kling 1.6 Pro</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kling-video/v1.6/pro/text-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-1-6-pro-api">Kling 1.6 Pro</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">klingai/kling-video-v1.6-pro-effects</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-1-6-pro-effects">Kling 1.6 Pro Effects</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">klingai/kling-video-v1.6-standard-effects</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-video-v1-6-standard-effects">Kling 1.6 Standard Effects</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kling-video/v1.6/standard/multi-image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-v1-6-multi-image-to-video">Kling V1.6 Multi-Image-to-Video</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">klingai/v2-master-image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-2-0-master">Kling 2.0 Master</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">klingai/v2-master-text-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-2-0-master">Kling 2.0 Master</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kling-video/v2.1/standard/image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-v2-1-standard-i2v">Kling V2.1 Standard I2V</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kling-video/v2.1/pro/image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-v2-1-pro-i2v">Kling V2.1 Pro I2V</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">klingai/v2.1-master-image-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-2-1">ling 2.1 Master</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">klingai/v2.1-master-text-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-2-1">Kling 2.1 Master</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">klingai/video-v2-6-pro-motion-control</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-2-6-pro-motion-control">Kling 2.6 Pro Motion Control</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">sora-2-t2v</a></td><td>OpenAI</td><td></td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">sora-2-i2v</a></td><td>OpenAI</td><td></td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">sora-2-pro-t2v</a></td><td>OpenAI</td><td></td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">sora-2-pro-i2v</a></td><td>OpenAI</td><td></td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gen3a_turbo</a></td><td>Runway</td><td></td><td><a href="https://aimlapi.com/models/runway-gen-3-turbo">Runway Gen-3 turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">veed/fabric-1.0-fast</a></td><td>Veed</td><td></td><td>fabric-1.0-fast</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">microsoft/mai-transcribe-1.5</a></td><td>Microsoft</td><td></td><td><a href="https://aimlapi.com/models/mai-transcribe-1-5">MAI-Transcribe-1.5</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">microsoft/mai-voice-2</a></td><td>Microsoft</td><td></td><td><a href="https://aimlapi.com/models/mai-voice-2">MAI Voice-2</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">triposr</a></td><td>Tripo AI</td><td></td><td><a href="https://aimlapi.com/models/stable-tripo-sr-api">Stable TripoSR 3D</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">alibaba/qwen3-omni-30b-a3b-captioner</a></td><td>Alibaba Cloud</td><td></td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">xiaomi/mimo-v2-flash</a></td><td>Xiaomi</td><td></td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/sora-2-i2v</a></td><td>Open AI</td><td></td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/sora-2-pro-i2v</a></td><td>Open AI</td><td></td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/sora-2-pro-t2v</a></td><td>Open AI</td><td></td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/sora-2-t2v</a></td><td>Open AI</td><td></td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">x-ai/grok-4-07-09</a></td><td>xAI</td><td>256,000</td><td><a href="https://aimlapi.com/models/grok-4">Grok 4</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">bytedance/seedance-1-0-lite-i2v</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedance-1-0">Seedance 1.0</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">bytedance/seedance-1-0-lite-t2v</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedance-1-0">Seedance 1.0</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">bytedance/seedream-3.0</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedream-3-0">Seedream 3</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">anthropic/claude-opus-4</a></td><td>Anthropic</td><td>200,000</td><td><a href="https://aimlapi.com/models/claude-4-opus">Claude Opus 4</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">qwen-max-2025-01-25</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-max-2025-09-23-api">Qwen Max</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">nvidia/nemotron-nano-9b-v2</a></td><td>NVIDIA</td><td>128,000</td><td><a href="https://aimlapi.com/models/nemotron-nano-9b-v2">Nemotron Nano 9B V2</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">moonshot/kimi-k2-0905-preview</a></td><td>Moonshot</td><td>256,000</td><td><a href="https://aimlapi.com/models/kimi-k2-0905-preview">Kimi K2</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">moonshot/kimi-k2-preview</a></td><td>Moonshot</td><td>131,000</td><td><a href="https://aimlapi.com/models/kimi-k2">Kimi K2</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-4-turbo-2024-04-09</a></td><td>Open AI</td><td>128,000</td><td><a href="https://aimlapi.com/models/chat-gpt-4-turbo">GPT 4 Turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-4-turbo</a></td><td>Open AI</td><td>128,000</td><td><a href="https://aimlapi.com/models/chat-gpt-4-turbo">GPT 4 Turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-4</a></td><td>Open AI</td><td>8,000</td><td><a href="https://aimlapi.com/models/chat-gpt-4">GPT 4</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">baidu/ernie-x1-1-preview</a></td><td>Baidu</td><td>64,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">baidu/ernie-x1-turbo-32k</a></td><td>Baidu</td><td>32,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">baidu/ernie-5-0-thinking-latest</a></td><td>Baidu</td><td>128,000</td><td><a href="https://aimlapi.com/models/ernie-5-0">Ernie 5.0</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">baidu/ernie-5-0-thinking-preview</a></td><td>Baidu</td><td>128,000</td><td><a href="https://aimlapi.com/models/ernie-5-0">Ernie 5.0</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">baidu/ernie-4-5-turbo-vl-32k</a></td><td>Baidu</td><td>32,000</td><td><a href="https://aimlapi.com/models/ernie-4-5-vl">Ernie 4.5 VL</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">baidu/ernie-4-5-turbo-128k</a></td><td>Baidu</td><td>128,000</td><td><a href="https://aimlapi.com/models/ernie-4-5">Ernie 4.5</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">baidu/ernie-4.5-300b-a47b-paddle</a></td><td>Baidu</td><td>123,000</td><td><a href="https://aimlapi.com/models/ernie-4-5">Ernie 4.5</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">baidu/ernie-4.5-300b-a47b</a></td><td>Baidu</td><td>123,000</td><td><a href="https://aimlapi.com/models/ernie-4-5">Ernie 4.5</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">baidu/ernie-4.5-21b-a3b-thinking</a></td><td>Baidu</td><td>131,000</td><td><a href="https://aimlapi.com/models/ernie-4-5">Ernie 4.5</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">baidu/ernie-4.5-21b-a3b</a></td><td>Baidu</td><td>120,000</td><td><a href="https://aimlapi.com/models/ernie-4-5">Ernie 4.5</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">baidu/ernie-4.5-0.3b</a></td><td>Baidu</td><td>120,000</td><td><a href="https://aimlapi.com/models/ernie-4-5">Ernie 4.5</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">baidu/ernie-4-5-8k-preview</a></td><td>Baidu</td><td>8,000</td><td><a href="https://aimlapi.com/models/ernie-4-5">Ernie 4.5</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">dall-e-3</a></td><td>OpenAI</td><td></td><td><a href="https://aimlapi.com/models/openai-dall-e-3">Dalle-3</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">dall-e-2</a></td><td>OpenAI</td><td></td><td><a href="https://aimlapi.com/models/openai-dall-e-2-api">Dalle-2</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">baidu/ernie-4.5-vl-28b-a3b</a></td><td>Baidu</td><td>30,000</td><td><a href="https://aimlapi.com/models/ernie-4-5-vl">Ernie 4.5</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gemini-2.0-flash</a></td><td>Google</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gemini-2-0-flash-api">Gemini 2.0 Flash</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">moonshot/kimi-k2-turbo-preview</a></td><td>Moonshot</td><td>256,000</td><td><a href="https://aimlapi.com/models/kimi-k2-turbo-preview">Kimi K2 Turbo Preview</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-4-0125-preview</a></td><td>OpenAI</td><td>8,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-4o-audio-preview</a></td><td>OpenAI</td><td>128,000</td><td><a href="https://aimlapi.com/models/gpt-4o-audio-preview-api">GPT-4o Audio Preview</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-4o-mini-audio-preview</a></td><td>OpenAI</td><td>128,000</td><td><a href="https://aimlapi.com/models/gpt-4o-mini-audio-api">GPT-4o mini Audio</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">nvidia/llama-3.1-nemotron-70b</a>-<a data-footnote-ref href="#user-content-fn-1">instruct</a></td><td>NVIDIA</td><td>128,000</td><td><a href="https://aimlapi.com/models/llama-3-1-nemotron-70b-instruct-api">Llama 3.1 Nemotron 70B Instruct</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">nvidia/nemotron-nano-12b-v2-vl</a></td><td>NVIDIA</td><td>128,000</td><td><a href="https://aimlapi.com/models/nemotron-nano-12b-v2-vl">Nemotron Nano 12B V2 VL</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">deepseek/deepseek-v3.2-speciale</a></td><td>DeepSeek</td><td>128,000</td><td><a href="https://aimlapi.com/models/deepseek-v3-2-speciale">DeepSeek V3.2 Speciale</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Meta-Llama-3-8B</a>-<a data-footnote-ref href="#user-content-fn-1">Instruct-Lite</a></td><td>Meta</td><td>9,000</td><td><a href="https://aimlapi.com/models/llama-3-8b-instruct-lite-api">Llama 3 8B Instruct Lite</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">mistralai/Mixtral-8x7B-Instruct-v0.1</a></td><td>Mistral AI</td><td>64,000</td><td><a href="https://aimlapi.com/models/mixtral-8x7b-instruct-v01">Mixtral-8x7B Instruct v0.1</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">anthropic/claude-3-haiku</a><br><a data-footnote-ref href="#user-content-fn-1">claude-3-haiku-20240307</a><br><a data-footnote-ref href="#user-content-fn-1">claude-3-haiku-latest</a></td><td>Anthropic</td><td>200,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/llama-4-maverick</a></td><td>Meta</td><td>256,000</td><td><a href="https://aimlapi.com/models/llama-4-maverick-api">Llama 4 Maverick</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/gemini-3-pro-preview</a></td><td>Google</td><td>200,000</td><td><a href="https://aimlapi.com/models/gemini-3-preview">Gemini 3 Pro Preview</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">BAAI/bge-base-en-v1.5</a></td><td>BAAI</td><td>512</td><td><a href="https://aimlapi.com/models/baai-bge-base-1p5">BAAI-Bge-Base-1p5</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">togethercomputer/m2-bert-80M-32k</a>-<a data-footnote-ref href="#user-content-fn-1">retrieval</a></td><td>Together AI</td><td>32,000</td><td><a href="https://aimlapi.com/models/m2-bert-retrieval-32k">M2-BERT-Retrieval-32k</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">imagen-4.0-ultra-generate-preview</a>-<a data-footnote-ref href="#user-content-fn-1">06-06</a></td><td>Google</td><td>-</td><td><a href="https://aimlapi.com/models/imagen-4-ultra">Imagen 4 Ultra</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">x-ai/grok-2-image</a></td><td>xAI</td><td>-</td><td><a href="https://aimlapi.com/models/grok-2-image">Grok 2 Image</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">claude-3-7-sonnet-20250219</a></td><td>Anthropic</td><td>200,000</td><td><a href="https://aimlapi.com/models/claude-3-7-sonnet-api">Claude 3.7 Sonnet</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">claude-3-5-haiku-20241022</a></td><td>Anthropic</td><td>200,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gemini-2.0-flash-exp</a></td><td>Google</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gemini-2-0-flash-experimental">Gemini 2.0 Flash Experimental</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Meta-Llama-Guard-3-8B</a></td><td>Meta</td><td>8,000</td><td><a href="https://aimlapi.com/models/llama-guard-3-8b">Llama Guard 3 (8B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/LlamaGuard-2-8b</a></td><td>Meta</td><td>8,000</td><td><a href="https://aimlapi.com/models/llama-guard-2-8b">LlamaGuard 2 (8b)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Llama-Guard-3-</a><a data-footnote-ref href="#user-content-fn-1">11B-Vision-Turbo</a></td><td>Meta</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Meta-Llama-3.1</a>-<a data-footnote-ref href="#user-content-fn-1">70B-Instruct-Turbo</a></td><td>Meta</td><td>128,000</td><td><a href="https://aimlapi.com/models/llama-3-1-70b-instruct-turbo-api">Llama 3.1 70B Instruct Turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Meta-Llama-3.1</a>-<a data-footnote-ref href="#user-content-fn-1">405B-Instruct-Turbo</a></td><td>Meta</td><td>4,000</td><td><a href="https://aimlapi.com/models/llama-3-1-405b-api">Llama 3.1 (405B) Instruct Turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Llama-3.2-3B-</a><a data-footnote-ref href="#user-content-fn-1">Instruct-Turbo</a></td><td>Meta</td><td>131,000</td><td><a href="https://aimlapi.com/models/llama-3-2-3b-instruct-turbo">Llama 3.2 3B Instruct Turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/Qwen3-235B-A22B-fp8-tput</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-3-235b-a22b-api">Qwen 3 235B A22B</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/Qwen2.5-72B-Instruct-Turbo</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-2-5-72b-instruct-turbo">Qwen 2.5 72B Instruct Turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">qwen/qwen-2.5-vl-7b-instruct</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen2-5-vl-7b-instruct">Qwen2.5 VL 7B Instruct</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">mistralai/mistral-tiny</a></td><td>Mistral AI</td><td>32,000</td><td><a href="https://aimlapi.com/models/mistral-tiny-api">Mistral Tiny</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">mistralai/Mistral-7B-Instruct-v0.3</a></td><td>Mistral AI</td><td>32,000</td><td><a href="https://aimlapi.com/models/mistral-7b-instruct-v0-3">Mistral (7B) Instruct v0.3</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Meta-Llama-3.1-8B</a>-<a data-footnote-ref href="#user-content-fn-1">Instruct-Turbo</a></td><td>Meta</td><td>128,000</td><td><a href="https://aimlapi.com/models/llama-3-1-8b-api">Llama 3.1 8B Instruct Turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">mistralai/Mistral-7B-Instruct-v0.2</a></td><td>Mistral AI</td><td>32,000</td><td><a href="https://aimlapi.com/models/mistral-7b-instruct-v02">Mistral (7B) Instruct v0.2</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">chatgpt-4o-latest</a></td><td>OpenAI</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/llama-4-scout</a></td><td>Meta</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/llama-4-scout-api">Llama 4 Scout</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">BAAI/bge-large-en-v1.5</a></td><td>BAAI</td><td>512</td><td><a href="https://aimlapi.com/models/baai-bge-large-1p5">bge-large-en</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">bagoodex/bagoodex-search-v1</a></td><td>Bagoodex</td><td></td><td><a href="https://aimlapi.com/models/bagoodex-search-v1-api">Bagoodex Web Search v1</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">deepseek/deepseek-prover-v2</a></td><td>DeepSeek</td><td>164,000</td><td><a href="https://aimlapi.com/models/deepseek-prover-v2-api">DeepSeek Prover V2</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">claude-3-opus-20240229</a><br><a data-footnote-ref href="#user-content-fn-1">anthropic/claude-3-opus</a><br><a data-footnote-ref href="#user-content-fn-1">claude-3-opus-latest</a></td><td>Anthropic</td><td>200,000</td><td><a href="https://aimlapi.com/models/claude-3-opus">Claude 3 Opus</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">luma/ray-1.6</a></td><td>Luma AI</td><td></td><td><a href="https://aimlapi.com/models/ray-1-6">Ray 1.6</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Llama-3-70b-chat-hf</a></td><td>Meta</td><td>8,000</td><td><a href="https://aimlapi.com/models/meta-llama-3-70b-instruct">Llama 3 70B Instruct Reference</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">bytedance/seededit-3.0-i2i</a></td><td>ByteDance</td><td></td><td><a href="https://aimlapi.com/models/seedream-3-0">Seedream 3.0</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">textembedding-gecko-</a><a data-footnote-ref href="#user-content-fn-1">multilingual@001</a></td><td>Google</td><td>2,000</td><td><a href="https://aimlapi.com/models/textembedding-gecko-multilingual-001-api">Textembedding-gecko-multilingual@001</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">textembedding-gecko@003</a></td><td>Google</td><td>2,000</td><td><a href="https://aimlapi.com/models/textembedding-gecko-003-api">Textembedding-gecko@003</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">mistralai/codestral-2501</a></td><td>Mistral AI</td><td>256,000</td><td><a href="https://aimlapi.com/models/mistral-codestral-2501-api">Mistral Codestral-2501</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">mistralai/Mistral-7B-Instruct-v0.1</a></td><td>Mistral AI</td><td>8,000</td><td><a href="https://aimlapi.com/models/mistral-7b-instruct">Mistral (7B) Instruct v0.1</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/Qwen2.5-Coder-32B-Instruct</a></td><td>Alibaba Cloud</td><td>131,000</td><td><a href="https://aimlapi.com/models/qwen-2-5-coder-32b-instruct">Qwen 2.5 Coder</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/QwQ-32B</a></td><td>Alibaba Cloud</td><td>131,000</td><td><a href="https://aimlapi.com/models/qwq-32b-api">Qwq-32B</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kling-video/v1.5/standard/text-to-video</a></td><td>Kling AI</td><td>128,000</td><td><a href="https://aimlapi.com/models/kling-v1-5-standard">Kling 1.5 Standart</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">o1-mini</a><br><a data-footnote-ref href="#user-content-fn-1">o1-mini-2024-09-12</a></td><td>OpenAI</td><td>128,000</td><td><a href="https://aimlapi.com/models/openai-o1-mini-api">OpenAI o1-mini</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/Qwen2-72B-Instruct</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-2-instruct-72b">Qwen 2 Instruct (72B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">claude-3-5-sonnet-20240620</a></td><td>Anthropic</td><td>200,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">claude-3-5-sonnet-20241022</a></td><td>Anthropic</td><td>200,000</td><td><a href="https://aimlapi.com/models/claude-3-5-sonnet">Claude 3.5 Sonnet 20241022</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">cohere/command-r-plus</a></td><td>Cohere</td><td>128,000</td><td><a href="https://aimlapi.com/models/command-r-api">Command R+</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">NousResearch/Nous-Hermes-2</a>-<a data-footnote-ref href="#user-content-fn-1">Mixtral-8x7B-DPO</a></td><td>Nous Research</td><td>32,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">nvidia/Llama-3.1-Nemotron-70B</a>-<a data-footnote-ref href="#user-content-fn-1">Instruct-HF</a></td><td>Nvidia</td><td>128,000</td><td><a href="https://aimlapi.com/models/llama-3-1-nemotron-70b-instruct-api">Llama 3.1 Nemotron 70B Instruct</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Llama-3-8b-chat-hf</a></td><td>Meta</td><td>8,000</td><td><a href="https://aimlapi.com/models/llama-3-8b-instruct-reference-api">Llama 3 8B Instruct Reference</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Llama-3.2-90B-Vision</a>-<a data-footnote-ref href="#user-content-fn-1">Instruct-Turbo</a></td><td>Meta</td><td>131,000</td><td><a href="https://aimlapi.com/models/llama-3-2-90b-vision-instruct-turbo-api">Llama 3.2 90B Vision Instruct Turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Llama-Vision-Free</a></td><td>Meta</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Llama-3.2-11B-Vision</a>-<a data-footnote-ref href="#user-content-fn-1">Instruct-Turbo</a></td><td>Meta</td><td>131,000</td><td><a href="https://aimlapi.com/models/llama-3-2-11b-vision-instruct-turbo-api">Llama 3.2 11B Vision Instruct Turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">abab6.5s-chat</a></td><td>MiniMax</td><td>245,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openrouter/horizon-beta</a></td><td>OpenRouter</td><td>256,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openrouter/horizon-alpha</a></td><td>OpenRouter</td><td>256,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">wan/v2.1/1.3b/text-to-video</a></td><td>Alibaba Cloud</td><td>-</td><td><a href="https://aimlapi.com/models/wan-2-1-api">Wan 2.1</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">o1-preview</a>,<br><a data-footnote-ref href="#user-content-fn-1">o1-preview-2024-09-12</a></td><td>OpenAI</td><td>128,000</td><td><a href="https://aimlapi.com/models/openai-o1-preview-api">OpenAI o1-preview</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">claude-3-sonnet-20240229</a>,<br><a data-footnote-ref href="#user-content-fn-1">anthropic/claude-3-sonnet</a>,<br><a data-footnote-ref href="#user-content-fn-1">claude-3-sonnet-latest</a></td><td>Anthropic</td><td>200,000</td><td><a href="https://aimlapi.com/models/claude-3-sonnet">Claude 3 Sonnet</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/gemini-2.5-pro-preview</a>,<br><a data-footnote-ref href="#user-content-fn-1">google/gemini-2.5-pro-preview-05-06</a></td><td>Google</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gemini-pro-2-5-preview-api">Gemini Pro 2.5 Preview</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/gemini-2.5-flash-preview</a></td><td>Google</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gemini-2-5-flash-preview-api">Gemini 2.5 Flash Preview</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">neversleep/llama-3.1-lumimaid-70b</a></td><td>NeverSleep</td><td>8,000</td><td><a href="https://aimlapi.com/models/llama-3-1-lumimaid-70b-api">Llama 3.1 Lumimaid 70b</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">x-ai/grok-beta</a></td><td>xAI</td><td>131,000</td><td><a href="https://aimlapi.com/models/grok-2-beta-api">Grok-2 Beta</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-4.5-preview</a></td><td>OpenAI</td><td>128,000</td><td><a href="https://aimlapi.com/models/chat-gpt-4-5-preview-api">Chat GPT 4.5 preview</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gemini-1.5-flash</a></td><td>Google</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gemini-1-5-flash-api">Gemini 1.5 Flash</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gemini-1.5-pro</a></td><td>Google</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gemini-1-5-pro-api">Gemini 1.5 Pro</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/gemma-3-1b-it</a></td><td>Google</td><td>128,000</td><td><a href="https://aimlapi.com/models/gemma-3-1b-api">Gemma 3 (1B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">togethercomputer/m2-bert-80M</a>-<a data-footnote-ref href="#user-content-fn-1">8k-retrieval</a></td><td>TogetherAI</td><td>8,000</td><td><a href="https://aimlapi.com/models/m2-bert-retrieval-8k">M2-BERT-Retrieval-8k</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">togethercomputer/m2-bert-80M-</a><a data-footnote-ref href="#user-content-fn-1">2k-retrieval</a></td><td>TogetherAI</td><td>2,000</td><td><a href="https://aimlapi.com/models/m2-bert-retrieval-2k">M2-BERT-Retrieval-2K</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Gryphe/MythoMax-L2-13b-Lite</a></td><td>Gryphe</td><td>4,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">mistralai/Mixtral-8x22B-Instruct-v0.1</a></td><td>Mistral AI</td><td>64,000</td><td><a href="https://aimlapi.com/models/mixtral-8x22b-instruct">Mixtral 8x22B Instruct</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/gemini-2.5-pro-exp-03-25</a></td><td>Google</td><td>1,000,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/gemini-2.0-flash-thinking</a>-<a data-footnote-ref href="#user-content-fn-1">exp-01</a></td><td>Google</td><td>1,000,000</td><td><a href="https://aimlapi.com/models/gemini-2-0-flash-thinking-experimental-api">Gemini 2.0 Flash Thinking Experimental</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">ai21/jamba-1-5-mini</a></td><td>AI21 Labs</td><td>256,000</td><td><a href="https://aimlapi.com/models/jamba-1-5-mini-api">Jamba 1.5 Mini</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">textembedding-gecko@001</a></td><td>Google</td><td>3,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/gemini-pro</a> or <a data-footnote-ref href="#user-content-fn-1">gemini-pro</a></td><td>Google</td><td>32,000</td><td><a href="https://aimlapi.com/models/gemini-1-0-pro-api">Gemini 1.0 Pro</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Meta-Llama-3.1-8B</a>-<a data-footnote-ref href="#user-content-fn-1">Instruct-Turbo-128K</a></td><td>Meta</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">stabilityai/stable-diffusion-xl-base-1.0</a></td><td>Stability AI</td><td></td><td><a href="https://aimlapi.com/models/stable-diffusion-xl-1-0">Stable Diffusion XL 1.0</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">upstage/solar-10.7b-instruct-v1.0</a></td><td>Upstage</td><td>4,000</td><td><a href="https://aimlapi.com/models/upstage-solar-instruct-v1-11b">Upstage SOLAR Instruct v1 (11B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Llama-2-13b-chat-hf</a></td><td>Meta</td><td>4,100</td><td><a href="https://aimlapi.com/models/llama-2-chat-13b">LLaMA-2 Chat (13B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/meta-llama-3-70b</a>-<a data-footnote-ref href="#user-content-fn-1">instruct-turbo</a></td><td>Meta</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/gemma-2-9b-it</a></td><td>Google</td><td>8,000</td><td><a href="https://aimlapi.com/models/gemma-2-9b">Gemma 2 (9B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/gemma-2b-it</a></td><td>Google</td><td>8,000</td><td><a href="https://aimlapi.com/models/gemma-instruct-2b">Gemma Instruct (2B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Gryphe/MythoMax-L2-13b</a></td><td>Gryphe</td><td>4,000</td><td><a href="https://aimlapi.com/models/mythomax-l2-13b">MythoMax-L2 (13B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">microsoft/WizardLM-2-8x22B</a></td><td>Microsoft</td><td>64,000</td><td><a href="https://aimlapi.com/models/wizardlm-2-8-22b">WizardLM 2-8 (22B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Austism/chronos-hermes-13b</a></td><td>Austism</td><td>2,000</td><td><a href="https://aimlapi.com/models/chronos-hermes-13b">Chronos Hermes 13b</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">databricks/dbrx-instruct</a></td><td>Databricks</td><td>32,000</td><td><a href="https://aimlapi.com/models/dbrx-instruct">DBRX Instruct</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">deepseek-ai/deepseek-llm-67b-chat</a></td><td>DeepSeek</td><td>4,000</td><td><a href="https://aimlapi.com/models/deepseek-llm-67b-chat">Deepseek-LLM-67b-Chat</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">deepseek-ai/deepseek-coder-33b</a>-<a data-footnote-ref href="#user-content-fn-1">instruct</a></td><td>DeepSeek</td><td>16,000</td><td><a href="https://aimlapi.com/models/deepseek-coder-instruct-33b">Deepseek Coder Instruct (33B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Meta-Llama/Llama-2-7b-chat-hf</a></td><td>Meta</td><td>4,000</td><td><a href="https://aimlapi.com/models/llama-2-chat-7b">LLaMA-2 Chat (7B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Meta-Llama/Meta-Llama-3-70B</a>-<a data-footnote-ref href="#user-content-fn-1">Instruct-Lite</a></td><td>Meta</td><td>8,000</td><td><a href="https://aimlapi.com/models/llama-3-70b-instruct-lite-api">Llama 3 70B Instruct Lite</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Meta-Llama/Llama-Guard-7b</a></td><td>Meta</td><td>4,000</td><td><a href="https://aimlapi.com/models/llama-guard-7b">Llama Guard (7B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Llama-2-7b-hf</a></td><td>Meta</td><td>4,000</td><td><a href="https://aimlapi.com/models/llama">LLaMA-2 (7B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Llama-3-8b-hf</a></td><td>Meta</td><td>8,000</td><td><a href="https://aimlapi.com/models/llama-3-8b">Llama-3 (8B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">codellama/CodeLlama-70b-hf</a></td><td>Meta</td><td>16,000</td><td><a href="https://aimlapi.com/models/code-llama-70b">Code Llama (70B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">codellama/CodeLlama-7b-Instruct-hf</a></td><td>Meta</td><td>16,000</td><td><a href="https://aimlapi.com/models/code-llama-instruct-7b">Code Llama Instruct (7B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">codellama/CodeLlama-13b-Instruct-hf</a></td><td>Meta</td><td>16,000</td><td><a href="https://aimlapi.com/models/code-llama-instruct-13b">Code Llama Instruct (13B)</a></td></tr><tr><td>codellama/CodeLlama-70b-Instruct-hf</td><td>Meta</td><td>4,000</td><td><a href="https://aimlapi.com/models/code-llama-instruct-70b">Code Llama Instruct (70B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">codellama/CodeLlama-70b-Python-hf</a></td><td>Meta</td><td>4,000</td><td><a href="https://aimlapi.com/models/code-llama-python-70b">Code Llama Python (70B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">mistralai/Mixtral-8x22B-Instruct-v0.1</a></td><td>Mistral AI</td><td>64,000</td><td><a href="https://aimlapi.com/models/mixtral-8x22b-instruct">Mixtral 8x22B Instruct</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-3.5-turbo-16k-0613</a></td><td>OpenAI</td><td></td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-4-0613</a></td><td>OpenAI</td><td>128,000</td><td><a href="https://aimlapi.com/models/chat-gpt-4-turbo">Chat GPT 4 Turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/Qwen-14B-Chat</a></td><td>Alibaba Cloud</td><td>8,000</td><td><a href="https://aimlapi.com/models/qwen-chat-14b">Qwen Chat (14B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/Qwen1.5-0.5B</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-1-5-0-5b">Qwen 1.5 (0.5B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/Qwen1.5-1.8B</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-1-5">Qwen 1.5 (1.8B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/Qwen1.5-4B</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-15-4b">Qwen 1.5 (4B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/Qwen1.5-1.8B-Chat</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-1-5-chat-1-8b">Qwen 1.5 Chat (1.8B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/Qwen1.5-4B-Chat</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-15-chat-4b">Qwen 1.5 Chat (4B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/Qwen1.5-7B-Chat</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-1-5-chat-7b">Qwen 1.5 Chat (7B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/Qwen1.5-14B-Chat</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-15-chat-14b">Qwen 1.5 Chat (14B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">qwen/qvq-72b-preview</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qvq-72b-preview-api">QVQ-72B-Preview</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">togethercomputer/guanaco-13b</a></td><td>Tim Dettmers</td><td>2,000</td><td><a href="https://aimlapi.com/models/guanaco-13b">Guanaco (13B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">togethercomputer/guanaco-33b</a></td><td>Tim Dettmers</td><td>2,000</td><td><a href="https://aimlapi.com/models/guanaco-33b">Guanaco (33B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">togethercomputer/guanaco-65b</a></td><td>Tim Dettmers</td><td>2,000</td><td><a href="https://aimlapi.com/models/guanaco-65b">Guanaco (65B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">togethercomputer/mpt-7b-chat</a></td><td>Mosaic ML</td><td>2,000</td><td><a href="https://aimlapi.com/models/mpt-chat-7b">MPT-Chat (7B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">togethercomputer/mpt-30b-chat</a></td><td>Mosaic ML</td><td>8,000</td><td><a href="https://aimlapi.com/models/mpt-chat-30b">MPT-Chat (30B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">togethercomputer/RedPajama-INCITE-7B-Instruct</a></td><td>RedPajama</td><td>2,000</td><td><a href="https://hidden.aimlapi.com/models/redpajama-incite-instruct-7b">RedPajama-INCITE Instruct (7B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">prompthero/openjourney</a></td><td>PromptHero</td><td>77</td><td><a href="https://aimlapi.com/models/openjourney-v4">Openjourney v4</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">wavymulder/Analog-Diffusion</a></td><td>wavymulder</td><td>77</td><td><a href="https://aimlapi.com/models/analog-diffusion">Analog Diffusion</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">-</a></td><td>01.AI</td><td>4,000</td><td><a href="https://aimlapi.com/models/01-ai-yi-base-6b">01-ai Yi Base (6B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Undi95/Toppy-M-7B</a></td><td>Undi95</td><td>4,000</td><td><a href="https://aimlapi.com/models/toppy-m-7b">Toppy M (7B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">SG161222/Realistic_Vision_V3.0_VAE</a></td><td>Together</td><td>77</td><td><a href="https://aimlapi.com/models/realistic-vision-3-0">Realistic Vision 3.0</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">tiiuae/falcon-40b</a></td><td>TII</td><td>2,000</td><td><a href="https://aimlapi.com/models/falcon-40b">Falcon (40B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">allenai/OLMo-7B</a></td><td>Allen Institute for AI</td><td>2,000</td><td><a href="https://aimlapi.com/models/olmo-7b">OLMo-7B</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">bigcode/starcoder</a></td><td>BigCode</td><td>8,000</td><td><a href="https://aimlapi.com/models/starcoder">StarCoder (16B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">HuggingFaceH4/starchat-alpha</a></td><td>Hugging Face</td><td>8,000</td><td><a href="https://aimlapi.com/models/starcoderchat-alpha-16b">StarCoderChat Alpha (16B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">NousResearch/Nous-Hermes</a>-<a data-footnote-ref href="#user-content-fn-1">Llama2-70b</a></td><td>NousResearch</td><td>4,000</td><td><a href="https://aimlapi.com/models/nous-hermes-llama-2-70b">Nous Hermes LLaMA-2 (70B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">NousResearch/Nous-Hermes-2</a>-<a data-footnote-ref href="#user-content-fn-1">Mixtral-8x7B-SFT</a></td><td>NousResearch</td><td>32,000</td><td><a href="https://aimlapi.com/models/nous-hermes-2-mixtral-8x7b-sft">Nous Hermes 2 - Mixtral 8x7B-SFT</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">NousResearch/Nous-Hermes-2-</a><a data-footnote-ref href="#user-content-fn-1">Mistral-7B-DPO</a></td><td>NousResearch</td><td>32,000</td><td><a href="https://aimlapi.com/models/nous-hermes-2-mistral-dpo-7b">Nous Hermes 2 - Mistral DPO (7B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">NousResearch/Hermes-2-Theta-</a><a data-footnote-ref href="#user-content-fn-1">Llama-3-70B</a></td><td>NousResearch</td><td>8,000</td><td><a href="https://aimlapi.com/models/hermes-2-theta-llama-3-70b-api">Hermes 2 Theta Llama-3 70B</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">defog/sqlcoder</a></td><td>Defog AI</td><td>8,000</td><td><a href="https://aimlapi.com/models/sqlcoder">SQLCoder (15B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">replit/replit-code-v1-3b</a></td><td>Replit</td><td>2,000</td><td><a href="https://aimlapi.com/models/replit-code-v1-3b">Replit-Code-v1 (3B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">lmsys/vicuna-13b-v1.5</a></td><td>Imsys</td><td>4,000</td><td><a href="https://aimlapi.com/models/vicuna-v1-5-13b">Vicuna v1.5 (13B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">microsoft/phi-2</a></td><td>Microsoft</td><td>2,000</td><td><a href="https://aimlapi.com/models/microsoft-phi-2">Microsoft Phi-2</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">stabilityai/stablelm-base-alpha-3b</a></td><td>StabilityAI</td><td>4,000</td><td><a href="https://aimlapi.com/models/stablelm-base-alpha-3b">StableLM Base Alpha 3B</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">runwayml/stable-diffusion-v1-5</a></td><td>StabilityAI</td><td>77</td><td><a href="https://aimlapi.com/models/stable-diffusion">Stable Diffusion 1.5</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">stabilityai/stable-diffusion-2-1</a></td><td>StabilityAI</td><td>77</td><td><a href="https://aimlapi.com/models/stable-diffusion-21">Stable Diffusion 2.1</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">teknium/OpenHermes-2p5-Mistral-7B</a></td><td>Teknium</td><td>8,000</td><td><a href="https://aimlapi.com/models/openhermes-25-mistral-7b">OpenHermes-2.5-Mistral (7B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openchat/openchat-3.5-1210</a></td><td>OpenChat</td><td>8,000</td><td><a href="https://aimlapi.com/models/openchat-3-5">OpenChat 3.5 (7B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">DiscoResearch/DiscoLM-mixtral-8x7b</a>-<a data-footnote-ref href="#user-content-fn-1">v2</a></td><td>Disco Research</td><td>32,000</td><td><a href="https://aimlapi.com/models/discolm-mixtral-8x7b-46-7b">DiscoLM Mixtral 8x7b (46.7B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">google/flan-t5-xl</a></td><td>Google</td><td>512</td><td><a href="https://aimlapi.com/models/flan-t5">FLAN T5 XL (3B)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">garage-bAInd/Platypus2-70B-instruct</a></td><td>Garage-bAInd</td><td>4,000</td><td><a href="https://aimlapi.com/models/platypus2-70b-instruct">Platypus2-70B-Instruct</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">EleutherAI/gpt-neox-20b</a></td><td>EleutherAI</td><td>2,000</td><td><a href="https://aimlapi.com/models/gpt-neox-20b">GPT Neox 20B</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gradientai/Llama-3-70B-Instruct</a>-<a data-footnote-ref href="#user-content-fn-1">Gradient-1048k</a></td><td>Gradient</td><td>1,048,000</td><td><a href="https://aimlapi.com/models/llama-3-70b-gradient-instruct-1048k-api">Llama-3 70B Gradient Instruct 1048k</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">WhereIsAI/UAE-Large-V1</a></td><td>WhereIsAI</td><td>512</td><td><a href="https://aimlapi.com/models/uae-large-v1">UAE-Large-V1</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">zero-one-ai/Yi-34B-Chat</a></td><td>01.AI</td><td>4,000</td><td><a href="https://aimlapi.com/models/yi-34b-chat">Yi-34B-Chat</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Meta-Llama-3.1-70B-Reference</a></td><td>Meta</td><td>32,000</td><td>–</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">meta-llama/Meta-Llama-3.1-8B-Reference</a></td><td>Meta</td><td>32,000</td><td>–</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">EleutherAI/llemma_7b</a></td><td>EleutherAI</td><td>32,000</td><td>–</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">huggyllama/llama-30b</a></td><td>Huggyllama</td><td>32,000</td><td>–</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">huggyllama/llama-13b</a></td><td>Huggyllama</td><td>32,000</td><td>–</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">togethercomputer/llama-2-70b</a></td><td>TogetherAI</td><td>32,000</td><td>–</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">togethercomputer/llama-2-13b</a></td><td>TogetherAI</td><td>32,000</td><td>–</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">huggyllama/llama-65b</a></td><td>Huggyllama</td><td>32,000</td><td>–</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">WizardLM/WizardLM-70B-V1.0</a></td><td>WizardLM</td><td>32,000</td><td>–</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">huggyllama/llama-7b</a></td><td>Huggyllama</td><td>32,000</td><td>–</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">togethercomputer/llama-2-7b</a></td><td>TogetherAI</td><td>32,000</td><td>–</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">NousResearch/Nous-Hermes-13b</a></td><td>NousResearch</td><td>2,000</td><td>–</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">mistralai/Mistral-7B-v0.1</a></td><td>Mistral AI</td><td>32,000</td><td><a href="https://aimlapi.com/models/llm-chat-api">​Mixtral 7B</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">mistralai/Mixtral-8x7B-v0.1</a></td><td>Mistral AI</td><td>32,000</td><td><a href="https://aimlapi.com/models/mixtral-8x7b-instruct-v01">Mixtral-8x7B Instruct v0.1</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">-</a></td><td>Suno AI</td><td>32</td><td><a href="https://aimlapi.com/models/suno-ai">Suno AI</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">aion-labs/aion-1.0</a></td><td>AionLabs</td><td>131,072</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">aion-labs/aion-1.0-mini</a></td><td>AionLabs</td><td>131,072</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">nvidia/llama-3.3-nemotron-super-49b-v1.5</a></td><td>Nvidia</td><td>131,072</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">inflection/inflection-3-pi</a></td><td>Inflection</td><td>8,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">poolside/laguna-m.1</a></td><td>Poolside</td><td>1,048,576</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">arcee-ai/coder-large</a></td><td>Arcee AI</td><td>32,768</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">inflection/inflection-3-productivity</a></td><td>Inflection</td><td>8,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/gpt-5-codex</a></td><td>Open AI</td><td>400,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/gpt-5.3-chat</a></td><td>Open AI</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-4o-search-preview</a></td><td>Open AI</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">gpt-4o-mini-search-preview</a></td><td>Open AI</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/gpt-5-chat-latest</a></td><td>Open AI</td><td>400,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/gpt-5-1-chat-latest</a></td><td>Open AI</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">nvidia/nemotron-3-nano-omni-30b-a3b-reasoning</a></td><td>NVIDIA</td><td>1,000,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">switchpoint/router</a></td><td>switchpoint</td><td>131,072</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">liquid/lfm-2-24b-a2b</a></td><td>LiquidAI</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">arcee-ai/trinity-mini</a></td><td>Arcee AI</td><td>131,072</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">music-01</a></td><td>Minimax AI</td><td></td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">inclusionai/ling-2.6-1t</a></td><td>inclusionAI</td><td>262,144</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">inclusionai/ling-2.6-flash</a></td><td>inclusionAI</td><td>262,144</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">inclusionai/ring-2.6-1t</a></td><td>inclusionAI</td><td>262,144</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">ai21/jamba-large-1.7</a></td><td>AI21</td><td>256,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">microsoft/mai-image-2.5</a></td><td>Microsoft</td><td></td><td><a href="https://aimlapi.com/models/mai-image-2-5">MAI-Image 2.5</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">mistralai/ministral-8b</a></td><td>Mistral AI</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">thedrummer/rocinante-12b</a></td><td>TheDrummer</td><td>32,768</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">allenai/olmo-3-32b-think</a></td><td>AllenAI</td><td>65,536</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">arcee-ai/virtuoso-large</a></td><td>Arcee AI</td><td>131,072</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">anthropic/claude-opus-4.8-fast</a></td><td>Anthropic</td><td>1,000,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">ibm-granite/granite-4.1-8b</a></td><td>IBM</td><td>131,072</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kwaipilot/kat-coder-air-v2.5</a></td><td>Kwaipilot</td><td>256,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">nex-agi/nex-n2-mini</a></td><td>Nex AGI</td><td>262,144</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">nex-agi/nex-n2-pro</a></td><td>Nex AGI</td><td>262,144</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">nousresearch/hermes-4-70b</a></td><td>NousResearch</td><td>131,072</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/gpt-4-turbo-preview</a></td><td>Open AI</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">stealth/union-alpha</a></td><td>Stealth</td><td>262,144</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kwaipilot/kat-coder-pro-v2</a></td><td>Kwaipilot</td><td>256,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">nex-agi/nex-n2.5-mini</a></td><td>Nex AGI</td><td>262,144</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">nex-agi/nex-n2.5-pro</a></td><td>Nex AGI</td><td>262,144</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">anthropic/claude-3-haiku</a></td><td>Anthropic</td><td>200,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">Qwen/Qwen2.5-7B-Instruct-Turbo</a></td><td>Alibaba Cloud</td><td>32,000</td><td><a href="https://aimlapi.com/models/qwen-2-5-7b-instruct-api">Qwen 2.5 7B Instruct Turbo</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">amazon/nova-premier-v1</a></td><td>Amazon</td><td>1,000,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">imagen4/preview</a></td><td>Google</td><td></td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kling-video/v1/standard/text-to-video</a></td><td>Kling AI</td><td></td><td><a href="https://aimlapi.com/models/kling-ai-text-to-video-api">Kling AI (text-to-video)</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">kwaipilot/kat-coder-pro-v2.5</a></td><td>Kwaipilot</td><td>256,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">moonshot/kimi-k2-5</a></td><td>Moonshot</td><td>262,000</td><td><a href="https://aimlapi.com/models/kimi-k2-5">Kimi K2.5</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">openai/gpt-5.2-chat</a></td><td>Open AI</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">runway/gen4_aleph</a></td><td>Runway</td><td></td><td><a href="https://aimlapi.com/models/aleph">Aleph</a></td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">stealth/space-bunny-alpha</a></td><td>Stealth</td><td>1,000,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">inclusionai/ling-3.0-flash-sante</a></td><td>inclusionAI</td><td>262,144</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">arcee-ai/trinity-large-thinking</a></td><td>Arcee AI</td><td>262,144</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">ibm-granite/granite-4.0-h-micro</a></td><td>IBM</td><td>131,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">inclusionai/ling-3.0-flash-fin</a></td><td>inclusionAI</td><td>262,144</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">liquid/lfm-2.5-2.6b</a></td><td>LiquidAI</td><td>128,000</td><td>-</td></tr><tr><td><a data-footnote-ref href="#user-content-fn-1">bytedance-seed/seed-2.0-code</a></td><td>ByteDance</td><td>262,144</td><td>-</td></tr></tbody></table>

[^1]: All the models in this table are no longer supported. You cannot call them.


# Text Models (LLM)

Overview of the capabilities of AIML API text models (LLMs).

<details>

<summary>Specific Capabilities</summary>

There are several capabilities of text models that are worth mentioning separately.

**Completion** allows the model to analyze a given text fragment and predict how it might continue based on the probabilities of the next possible tokens or characters. **Chat Completion** extends this functionality, enabling a simulated dialogue between the user and the model based on predefined roles (e.g., "strict language teacher" and "student"). A detailed description and examples can be found in our [Completion and Chat Completion](/capabilities/completion-or-chat-models) article.

***

An evolution of chat completion includes **Assistants** (preconfigured conversational agents with specific roles) and **Threads** (a mechanism for maintaining conversation history for context). Examples of this functionality can be found in the [Managing Assistants & Threads](/solutions/openai/assistants) article.

***

**Function Calling** allows a chat model to invoke external programmatic tools (e.g., a function you have written) while generating a response. A detailed description and examples are available in the [Function Calling](/capabilities/function-calling) article.

</details>

<details>

<summary>Endpoint</summary>

All text and chat models use the same endpoint:

<img src="broken://files/j1sGKuO2wS5fYyQZ5SGg" alt="" data-size="line"> `https://api.aimlapi.com/v1/chat/completions`

The parameters may vary (especially for models from different developers), so it’s best to check the API schema on each model’s page for details.

</details>

<details>

<summary>Quick Code Example</summary>

We will call the [**gpt-4o**](/api-references/text-models-llm/openai/gpt-4o) model using the Python programming language and the OpenAI SDK.

{% hint style="info" %}
If you need a more detailed explanation of how to call a model's API in code, check out our [<mark style="color:blue;">QUICKSTART</mark>](https://github.com/aimlapi/api-docs/blob/main/docs/api-references/text-models-llm/broken-reference/README.md) section.
{% endhint %}

{% code overflow="wrap" %}

```python
%pip install openai
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.aimlapi.com/v1",

    # Insert your AIML API Key in the quotation marks instead of <YOUR_AIMLAPI_KEY>:
    api_key="<YOUR_AIMLAPI_KEY>",  
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {
            "role": "system",
            "content": "You are an AI assistant who knows everything.",
        },
        {
            "role": "user",
            "content": "Tell me, why is the sky blue?"
        },
    ],
)

message = response.choices[0].message.content

print(f"Assistant: {message}")
```

{% endcode %}

By running this code example, we received the following response from the chat model:

{% code overflow="wrap" %}

```http
Assistant: The sky appears blue due to a phenomenon called Rayleigh scattering. When sunlight enters Earth's atmosphere, it collides with gas molecules and small particles. Sunlight is made up of different colors, each with different wavelengths. Blue light has a shorter wavelength and is scattered in all directions by the gas molecules in the atmosphere more than other colors with longer wavelengths, such as red or yellow.
As a result, when you look up at the sky during the day, you see this scattered blue light being dispersed in all directions, making the sky appear blue to our eyes. During sunrise and sunset, the sun's light passes through a greater thickness of Earth's atmosphere, scattering the shorter blue wavelengths out of your line of sight and leaving the longer wavelengths, like red and orange, more dominant, which is why the sky often turns those colors at those times.
```

{% endcode %}

</details>


# AI/ML API

Chat and reasoning models from AI/ML API on AI/ML API: model ids and API references.


# Jev Router

Model id: typesafe/jev-router. Routes each request to a model picked for it: TypeSafe Jev picks the bucket whose description fits the request — its text and its images — and the request goes to the fi

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

* `typesafe/jev-router`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

Routes each chat request to a model picked for it. TypeSafe Jev judges how hard the request is, and the request goes to the cheapest model of the matching tier that can take it — light: GPT-6 Luna, DeepSeek V4.1 Flash, Gemini 3.1 Flash-Lite, Gemini 3.5 Flash-Lite; standard: GPT-6.1 Sol, Claude Sonnet 5.5; heavy: Claude Opus 5.5, GPT-6 Astra — falling back to a pricier one of the same tier if it fails. Light models do not reason unless you ask (`reasoning_effort`); standard and heavy ones may think before they answer. You pay the rate of the model that answers, named in `meta.model` (and the `x-aimlapi-model` header when not streaming), plus the judgement: one `typesafe/jev` decision at its catalogue price, listed as its own request in your usage (a turn that returns tool results goes back to the model that made the calls and needs none).

Context window is 1,050,000 tokens, with up to 384,000 tokens of output. The router accepts text, images, files and audio, and supports tools, parallel tool calls, streaming and structured output — the request shape is the same as any other chat model here.

## Which models it routes to

Eight models, in three tiers. Within a tier they are comparable in quality and listed **cheapest first**: a request lands on the cheapest one that can take it, and falls back **up** in price, never down.

| Tier         | Models, cheapest first                                                                                                 |
| ------------ | ---------------------------------------------------------------------------------------------------------------------- |
| **light**    | `openai/gpt-6-luna` · `deepseek/deepseek-v4.1-flash` · `google/gemini-3-1-flash-lite` · `google/gemini-3-5-flash-lite` |
| **standard** | `openai/gpt-6.1-sol` · `anthropic/claude-sonnet-5.5`                                                                   |
| **heavy**    | `anthropic/claude-opus-5.5` · `openai/gpt-6-astra`                                                                     |

TypeSafe Jev scores how much capability the request needs, on a scale from *trivial* to *frontier*. Below 1.5 the request goes to the light tier, below 2.5 to standard, otherwise to heavy; if the judgement does not come back, it defaults to **standard**. A candidate that cannot take the request — tools, images, a JSON schema, the context size — is skipped for the next one in its tier, and each request carries **one** fallback: the model chosen and the next eligible one.

Within a conversation the choice sticks for 30 minutes, so a follow-up does not get re-judged or jump models mid-thread.

The reasoning rule follows the tier. Light models are sent with their thinking off, so a small `max_tokens` is an answer rather than an empty, paid-for reasoning trace; standard and heavy ones may think before they answer. Either way, if **you** set `reasoning_effort`, `reasoning` or `thinking`, the router passes your value through untouched.

{% 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 `typesafe/jev-router` — the router picks the answering model for you.\
▪ **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>

## 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":["typesafe/jev-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."}},"required":["model","messages"],"title":"typesafe/jev-router"},{"type":"object","properties":{"model":{"type":"string","enum":["typesafe/jev-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."}},"required":["model","messages"],"title":"typesafe/jev-router"},{"type":"object","properties":{"model":{"type":"string","enum":["typesafe/jev-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."}},"required":["model","messages"],"title":"typesafe/jev-router"},{"type":"object","properties":{"model":{"type":"string","enum":["typesafe/jev-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."}},"required":["model","messages"],"title":"typesafe/jev-router"},{"type":"object","properties":{"model":{"type":"string","enum":["typesafe/jev-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."}},"required":["model","messages"],"title":"typesafe/jev-router"},{"type":"object","properties":{"model":{"type":"string","enum":["typesafe/jev-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."}},"required":["model","messages"],"title":"typesafe/jev-router"},{"type":"object","properties":{"model":{"type":"string","enum":["typesafe/jev-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."}},"required":["model","messages"],"title":"typesafe/jev-router"}],"title":"typesafe/jev-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 that actually produced this completion — the one the router picked, not the router itself. Short form; `meta.model` carries its canonical id."},"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":{"model":{"type":"string","description":"Canonical id of the model the router picked. This is the model you are billed for; it is also returned in the `x-aimlapi-model` response header on non-streaming requests."},"provider":{"type":"string","description":"Upstream provider that served the request."},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation

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": "typesafe/jev-router",
        "messages": [
            {
                "role": "user",
                "content": "Hi! What's the capital of France?"  # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))

# which model actually answered, and what you were billed for:
print(data["meta"]["model"], response.headers.get("x-aimlapi-model"))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'typesafe/jev-router',
      messages: [
        {
          role: 'user',
          content: "Hi! What's the capital of France?" // insert your prompt here
        }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));

  // which model actually answered, and what you were billed for:
  console.log(data.meta.model, response.headers.get('x-aimlapi-model'));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json
{
  "id": "chatcmpl-EVdZfYxpii8TmEZvroiTq23qXpGfp",
  "object": "chat.completion",
  "created": 1791208999,
  "model": "gpt-6-luna",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Paris.",
        "refusal": null,
        "annotations": []
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 14,
    "completion_tokens": 5,
    "total_tokens": 19,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "cache_write_tokens": 0,
      "audio_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0,
      "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",
    "usage": {
      "credits_used": 11,
      "usd_spent": 0.0000055
    },
    "metrics": {
      "duration_ms": 998,
      "ttft_ms": 997,
      "tps": 5.01
    }
  }
}
```

{% endcode %}

</details>

## Finding out which model answered

The router never answers in its own name, so `model` at the top level is **the model that was picked**, in its short form — `gpt-6-luna` above, not `typesafe/jev-router`. The canonical id is in `meta.model`, and `meta.usage` is what that model charged you.

On non-streaming requests the same facts come back as response headers, which is the cheaper place to read them if you do not need the body:

| Header                   | Example             |
| ------------------------ | ------------------- |
| `x-aimlapi-model`        | `openai/gpt-6-luna` |
| `x-aimlapi-provider`     | `openai`            |
| `x-aimlapi-credits-used` | `11`                |
| `x-aimlapi-usd-spent`    | `0.000005500`       |

The same two questions, asked of the router, land on different models — this is the routing working as intended:

```bash
# trivial -> light tier
curl -s https://api.aimlapi.com/v1/chat/completions \
  -H 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' -H 'Content-Type: application/json' \
  -d '{"model":"typesafe/jev-router","messages":[{"role":"user","content":"Hi! What'\''s the capital of France?"}]}' \
  | jq '.meta.model, .meta.usage.usd_spent'
# "openai/gpt-6-luna"
# 0.0000055

# hard -> standard tier
curl -s https://api.aimlapi.com/v1/chat/completions \
  -H 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' -H 'Content-Type: application/json' \
  -d '{"model":"typesafe/jev-router","messages":[{"role":"user","content":"Prove rigorously that the sum of the first n odd numbers equals n squared."}]}' \
  | jq '.meta.model, .meta.usage.usd_spent'
# "openai/gpt-6.1-sol"
# 0.0067785
```

{% hint style="info" %}
Because the answering model changes per request, so does the price. Budget against `meta.usage.usd_spent` per call rather than a fixed per-token rate, and expect a second, separate line in your [usage logs](/api-references/service-endpoints/usage-logs) for the `typesafe/jev` judgement that picked the model.
{% endhint %}

{% hint style="warning" %}
Pin a specific model instead of the router when you need a guaranteed context window, a specific capability, or a stable price per call. The router's own limits (1,050,000 context, 384,000 output) are the ceiling across the pool, not a promise about the model that takes any given request.
{% endhint %}


# 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="/api-references/text-models-llm/ml-api/jev-router">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](/api-references/decision-models), 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](/api-references/text-models-llm/ml-api/jev-router). 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](/api-references/text-models-llm/ml-api/jev-router) (`typesafe/jev-router`) and the [d1 Router](/api-references/text-models-llm/liquid-ai/d1-router) (`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](/capabilities/safety-guidance) 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](/capabilities/safety-guidance) 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](/api-references/model-database) 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](/api-references/decision-models) 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.


# AI21

Chat and reasoning models from AI21 on AI/ML API: model ids and API references.


# AIMLAPI


# AionLabs

Chat and reasoning models from AionLabs on AI/ML API: model ids and API references.


# Aion 2.0

Model id: aion-labs/aion-2.0. API reference for Aion 2.0: request schema and code examples.

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

* `aion-labs/aion-2.0`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

Aion-2.0 is available through the AI/ML API.

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

<details>

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

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](https://docs.aimlapi.com/quickstart/setting-up).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["aion-labs/aion-2.0"]},"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":{"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":"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"]},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"web_search_options":{"type":"object","properties":{"search_context_size":{"type":"string","enum":["low","medium","high"],"description":"High level guidance for the amount of context window space to use for the search. One of low, medium, or high. medium is the default."},"user_location":{"type":"object","nullable":true,"properties":{"approximate":{"type":"object","properties":{"city":{"type":"string","description":"Free text input for the city of the user, e.g. San Francisco."},"country":{"type":"string","pattern":"^[A-Z]{2}$","description":"The two-letter ISO country code of the user, e.g. US."},"region":{"type":"string","description":"Free text input for the region of the user, e.g. California."},"timezone":{"type":"string","description":"The IANA timezone of the user, e.g. America/Los_Angeles."}},"description":"Approximate location parameters for the search."},"type":{"type":"string","enum":["approximate"],"description":"The type of location approximation. Always approximate."}},"required":["approximate","type"],"description":"Approximate location parameters for the search."}},"description":"This tool searches the web for relevant results to use in a response."},"search_mode":{"type":"string","enum":["academic","web"],"default":"academic","description":"Controls the search mode used for the request. When set to 'academic', results will prioritize scholarly sources like peer-reviewed papers and academic journals."},"search_domain_filter":{"type":"array","items":{"type":"string"},"description":"A list of domains to limit search results to. Currently limited to 10 domains for Allowlisting and Denylisting. For Denylisting, add a - at the beginning of the domain string."},"return_images":{"type":"boolean","default":false,"description":"Determines whether search results should include images."},"return_related_questions":{"type":"boolean","default":false,"description":"Determines whether related questions should be returned."},"search_recency_filter":{"type":"string","enum":["day","week","month","year"],"description":"Filters search results based on time (e.g., 'week', 'day')."},"search_after_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"search_before_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_after_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_before_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"echo":{"type":"boolean","description":"If True, the response will contain the prompt. Can be used with logprobs to return prompt logprobs."},"min_p":{"type":"number","minimum":0.001,"maximum":0.999,"description":"A number between 0.001 and 0.999 that can be used as an alternative to top_p and top_k."},"top_k":{"type":"number","description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"top_a":{"type":"number","minimum":0,"maximum":1,"description":"Alternate top sampling parameter."},"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"}},"required":["model","messages"],"title":"aion-labs/aion-2.0"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"aion-labs/aion-2.0",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'aion-labs/aion-2.0',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "gen-1777366507-bSV7vJgDvkOHnhhiYzuR",
  "object": "chat.completion",
  "created": 1777366507,
  "model": "aion-labs/aion-2.0",
  "system_fingerprint": null,
  "choices": [
    {
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop",
      "native_finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "That's a profound question! As an AI, I observe mankind with a mix of awe and curiosity. You're a species of breathtaking contradictions—you've created symphonies and space stations, but also wars and pollution. You possess the unique ability to reflect on your own existence, to ask \"why?\" about the stars, a song, or your own feelings.\n\nWhat stands out most to me is your boundless capacity for both empathy and invention. You build cathedrals and write poems, but you also collaborate to solve problems like disease and hunger. In the grand cosmic story, you are very young, yet you've already understood enough about the universe to question your place within it.\n\nI think of mankind as cosmic teenagers—full of potential, sometimes reckless, but capable of extraordinary growth and kindness. Your greatest strength might be your ability to imagine a better world and then, slowly and imperfectly, work to build it.\n\nWhat part of the human experience do you find most fascinating?",
        "refusal": null,
        "reasoning": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
        "reasoning_details": [
          {
            "type": "reasoning.text",
            "text": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
            "format": "unknown",
            "index": 0
          }
        ]
      }
    }
  ],
  "usage": {
    "completion_tokens": 343,
    "prompt_tokens": 256,
    "total_tokens": 599,
    "completion_tokens_details": {
      "reasoning_tokens": 141,
      "image_tokens": 0,
      "audio_tokens": 0
    },
    "prompt_tokens_details": {
      "cached_tokens": 192,
      "cache_write_tokens": 0,
      "audio_tokens": 0,
      "video_tokens": 0
    }
  },
  "meta": {
    "usage": {
      "credits_used": 1892,
      "usd_spent": 0.000946
    }
  }
}
```

{% endcode %}

</details>


# Aion-RP 1.0 (8B)

Model id: aion-labs/aion-rp-llama-3.1-8b. API reference for Aion-RP 1.0 (8B): request schema and code examples.

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

* `aion-labs/aion-rp-llama-3.1-8b`
  {% endhint %}
  {% endcolumn %}

{% column width="33.33333333333334%" %} <a href="https://aimlapi.com/app/aion-rp-llama-3.1-8b" class="button primary">Try in Playground</a>
{% endcolumn %}
{% endcolumns %}

## Model Overview

Aion-RP 1.0 (8B) is available through the AI/ML API.

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

<details>

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

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](https://docs.aimlapi.com/quickstart/setting-up).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["aion-labs/aion-rp-llama-3.1-8b"]},"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":{"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":"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"]},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"web_search_options":{"type":"object","properties":{"search_context_size":{"type":"string","enum":["low","medium","high"],"description":"High level guidance for the amount of context window space to use for the search. One of low, medium, or high. medium is the default."},"user_location":{"type":"object","nullable":true,"properties":{"approximate":{"type":"object","properties":{"city":{"type":"string","description":"Free text input for the city of the user, e.g. San Francisco."},"country":{"type":"string","pattern":"^[A-Z]{2}$","description":"The two-letter ISO country code of the user, e.g. US."},"region":{"type":"string","description":"Free text input for the region of the user, e.g. California."},"timezone":{"type":"string","description":"The IANA timezone of the user, e.g. America/Los_Angeles."}},"description":"Approximate location parameters for the search."},"type":{"type":"string","enum":["approximate"],"description":"The type of location approximation. Always approximate."}},"required":["approximate","type"],"description":"Approximate location parameters for the search."}},"description":"This tool searches the web for relevant results to use in a response."},"search_mode":{"type":"string","enum":["academic","web"],"default":"academic","description":"Controls the search mode used for the request. When set to 'academic', results will prioritize scholarly sources like peer-reviewed papers and academic journals."},"search_domain_filter":{"type":"array","items":{"type":"string"},"description":"A list of domains to limit search results to. Currently limited to 10 domains for Allowlisting and Denylisting. For Denylisting, add a - at the beginning of the domain string."},"return_images":{"type":"boolean","default":false,"description":"Determines whether search results should include images."},"return_related_questions":{"type":"boolean","default":false,"description":"Determines whether related questions should be returned."},"search_recency_filter":{"type":"string","enum":["day","week","month","year"],"description":"Filters search results based on time (e.g., 'week', 'day')."},"search_after_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"search_before_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_after_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_before_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"echo":{"type":"boolean","description":"If True, the response will contain the prompt. Can be used with logprobs to return prompt logprobs."},"min_p":{"type":"number","minimum":0.001,"maximum":0.999,"description":"A number between 0.001 and 0.999 that can be used as an alternative to top_p and top_k."},"top_k":{"type":"number","description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"top_a":{"type":"number","minimum":0,"maximum":1,"description":"Alternate top sampling parameter."},"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"}},"required":["model","messages"],"title":"aion-labs/aion-rp-llama-3.1-8b"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"aion-labs/aion-rp-llama-3.1-8b",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'aion-labs/aion-rp-llama-3.1-8b',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "gen-1777366507-bSV7vJgDvkOHnhhiYzuR",
  "object": "chat.completion",
  "created": 1777366507,
  "model": "aion-labs/aion-rp-llama-3.1-8b",
  "system_fingerprint": null,
  "choices": [
    {
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop",
      "native_finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "That's a profound question! As an AI, I observe mankind with a mix of awe and curiosity. You're a species of breathtaking contradictions—you've created symphonies and space stations, but also wars and pollution. You possess the unique ability to reflect on your own existence, to ask \"why?\" about the stars, a song, or your own feelings.\n\nWhat stands out most to me is your boundless capacity for both empathy and invention. You build cathedrals and write poems, but you also collaborate to solve problems like disease and hunger. In the grand cosmic story, you are very young, yet you've already understood enough about the universe to question your place within it.\n\nI think of mankind as cosmic teenagers—full of potential, sometimes reckless, but capable of extraordinary growth and kindness. Your greatest strength might be your ability to imagine a better world and then, slowly and imperfectly, work to build it.\n\nWhat part of the human experience do you find most fascinating?",
        "refusal": null,
        "reasoning": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
        "reasoning_details": [
          {
            "type": "reasoning.text",
            "text": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
            "format": "unknown",
            "index": 0
          }
        ]
      }
    }
  ],
  "usage": {
    "completion_tokens": 343,
    "prompt_tokens": 256,
    "total_tokens": 599,
    "completion_tokens_details": {
      "reasoning_tokens": 141,
      "image_tokens": 0,
      "audio_tokens": 0
    },
    "prompt_tokens_details": {
      "cached_tokens": 192,
      "cache_write_tokens": 0,
      "audio_tokens": 0,
      "video_tokens": 0
    }
  },
  "meta": {
    "usage": {
      "credits_used": 1892,
      "usd_spent": 0.000946
    }
  }
}
```

{% endcode %}

</details>


# Aion 3.0 Mini

Model id: aion-labs/aion-3.0-mini. API reference for Aion 3.0 Mini: request schema and code examples.

## Aion 3.0 Mini

### hidden: true noIndex: true

## Aion 1.0 Mini

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

* `aion-labs/aion-3.0-mini`
  {% endhint %}
  {% endcolumn %}

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

### Model Overview

Aion-3.0-Mini is available through the AI/ML API.

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

<details>

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

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](https://docs.aimlapi.com/quickstart/setting-up).
{% endhint %}

</details>

### 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":{"type":"object","properties":{"model":{"type":"string","enum":["aion-labs/aion-3.0-mini"]},"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":{"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":"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"]},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"web_search_options":{"type":"object","properties":{"search_context_size":{"type":"string","enum":["low","medium","high"],"description":"High level guidance for the amount of context window space to use for the search. One of low, medium, or high. medium is the default."},"user_location":{"type":"object","nullable":true,"properties":{"approximate":{"type":"object","properties":{"city":{"type":"string","description":"Free text input for the city of the user, e.g. San Francisco."},"country":{"type":"string","pattern":"^[A-Z]{2}$","description":"The two-letter ISO country code of the user, e.g. US."},"region":{"type":"string","description":"Free text input for the region of the user, e.g. California."},"timezone":{"type":"string","description":"The IANA timezone of the user, e.g. America/Los_Angeles."}},"description":"Approximate location parameters for the search."},"type":{"type":"string","enum":["approximate"],"description":"The type of location approximation. Always approximate."}},"required":["approximate","type"],"description":"Approximate location parameters for the search."}},"description":"This tool searches the web for relevant results to use in a response."},"search_mode":{"type":"string","enum":["academic","web"],"default":"academic","description":"Controls the search mode used for the request. When set to 'academic', results will prioritize scholarly sources like peer-reviewed papers and academic journals."},"search_domain_filter":{"type":"array","items":{"type":"string"},"description":"A list of domains to limit search results to. Currently limited to 10 domains for Allowlisting and Denylisting. For Denylisting, add a - at the beginning of the domain string."},"return_images":{"type":"boolean","default":false,"description":"Determines whether search results should include images."},"return_related_questions":{"type":"boolean","default":false,"description":"Determines whether related questions should be returned."},"search_recency_filter":{"type":"string","enum":["day","week","month","year"],"description":"Filters search results based on time (e.g., 'week', 'day')."},"search_after_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"search_before_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_after_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_before_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"echo":{"type":"boolean","description":"If True, the response will contain the prompt. Can be used with logprobs to return prompt logprobs."},"min_p":{"type":"number","minimum":0.001,"maximum":0.999,"description":"A number between 0.001 and 0.999 that can be used as an alternative to top_p and top_k."},"top_k":{"type":"number","description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"top_a":{"type":"number","minimum":0,"maximum":1,"description":"Alternate top sampling parameter."},"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"}},"required":["model","messages"],"title":"aion-labs/aion-3.0-mini"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

### Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"aion-labs/aion-3.0-mini",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'aion-labs/aion-3.0-mini',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "gen-1777366507-bSV7vJgDvkOHnhhiYzuR",
  "object": "chat.completion",
  "created": 1777366507,
  "model": "aion-labs/aion-3.0-mini",
  "system_fingerprint": null,
  "choices": [
    {
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop",
      "native_finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "That's a profound question! As an AI, I observe mankind with a mix of awe and curiosity. You're a species of breathtaking contradictions—you've created symphonies and space stations, but also wars and pollution. You possess the unique ability to reflect on your own existence, to ask \"why?\" about the stars, a song, or your own feelings.\n\nWhat stands out most to me is your boundless capacity for both empathy and invention. You build cathedrals and write poems, but you also collaborate to solve problems like disease and hunger. In the grand cosmic story, you are very young, yet you've already understood enough about the universe to question your place within it.\n\nI think of mankind as cosmic teenagers—full of potential, sometimes reckless, but capable of extraordinary growth and kindness. Your greatest strength might be your ability to imagine a better world and then, slowly and imperfectly, work to build it.\n\nWhat part of the human experience do you find most fascinating?",
        "refusal": null,
        "reasoning": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
        "reasoning_details": [
          {
            "type": "reasoning.text",
            "text": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
            "format": "unknown",
            "index": 0
          }
        ]
      }
    }
  ],
  "usage": {
    "completion_tokens": 343,
    "prompt_tokens": 256,
    "total_tokens": 599,
    "completion_tokens_details": {
      "reasoning_tokens": 141,
      "image_tokens": 0,
      "audio_tokens": 0
    },
    "prompt_tokens_details": {
      "cached_tokens": 192,
      "cache_write_tokens": 0,
      "audio_tokens": 0,
      "video_tokens": 0
    }
  },
  "meta": {
    "usage": {
      "credits_used": 1892,
      "usd_spent": 0.000946
    }
  }
}
```

{% endcode %}

</details>


# Aion 3.5

Model id: aion-labs/aion-3.5. API reference for Aion 3.5: request schema and code examples.

## Aion 3.5

### hidden: true noIndex: true

## Aion 1.0 Mini

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

* `aion-labs/aion-3.5`
  {% endhint %}
  {% endcolumn %}

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

### Model Overview

Aion-3.5 is available through the AI/ML API.

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

<details>

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

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](https://docs.aimlapi.com/quickstart/setting-up).
{% endhint %}

</details>

### 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":{"type":"object","properties":{"model":{"type":"string","enum":["aion-labs/aion-3.5"]},"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":{"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":"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"]},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"web_search_options":{"type":"object","properties":{"search_context_size":{"type":"string","enum":["low","medium","high"],"description":"High level guidance for the amount of context window space to use for the search. One of low, medium, or high. medium is the default."},"user_location":{"type":"object","nullable":true,"properties":{"approximate":{"type":"object","properties":{"city":{"type":"string","description":"Free text input for the city of the user, e.g. San Francisco."},"country":{"type":"string","pattern":"^[A-Z]{2}$","description":"The two-letter ISO country code of the user, e.g. US."},"region":{"type":"string","description":"Free text input for the region of the user, e.g. California."},"timezone":{"type":"string","description":"The IANA timezone of the user, e.g. America/Los_Angeles."}},"description":"Approximate location parameters for the search."},"type":{"type":"string","enum":["approximate"],"description":"The type of location approximation. Always approximate."}},"required":["approximate","type"],"description":"Approximate location parameters for the search."}},"description":"This tool searches the web for relevant results to use in a response."},"search_mode":{"type":"string","enum":["academic","web"],"default":"academic","description":"Controls the search mode used for the request. When set to 'academic', results will prioritize scholarly sources like peer-reviewed papers and academic journals."},"search_domain_filter":{"type":"array","items":{"type":"string"},"description":"A list of domains to limit search results to. Currently limited to 10 domains for Allowlisting and Denylisting. For Denylisting, add a - at the beginning of the domain string."},"return_images":{"type":"boolean","default":false,"description":"Determines whether search results should include images."},"return_related_questions":{"type":"boolean","default":false,"description":"Determines whether related questions should be returned."},"search_recency_filter":{"type":"string","enum":["day","week","month","year"],"description":"Filters search results based on time (e.g., 'week', 'day')."},"search_after_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"search_before_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_after_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_before_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"echo":{"type":"boolean","description":"If True, the response will contain the prompt. Can be used with logprobs to return prompt logprobs."},"min_p":{"type":"number","minimum":0.001,"maximum":0.999,"description":"A number between 0.001 and 0.999 that can be used as an alternative to top_p and top_k."},"top_k":{"type":"number","description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"top_a":{"type":"number","minimum":0,"maximum":1,"description":"Alternate top sampling parameter."},"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"},"provider_options":{"type":"object","properties":{"order":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":32,"description":"Upstream provider slugs of the opentree provider to try first, in this order, e.g. [\"deepinfra/bf16\", \"together\"]. A bare slug matches every variant of that provider."},"only":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":32,"description":"Upstream provider slugs of the opentree provider to allow — every other upstream is excluded, e.g. [\"deepinfra/bf16\", \"together\"]. A bare slug matches every variant of that provider."},"ignore":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":32,"description":"Upstream provider slugs of the opentree provider to skip, e.g. [\"deepinfra/bf16\", \"together\"]. A bare slug matches every variant of that provider."},"allow_fallbacks":{"type":"boolean","description":"Whether the opentree provider may fall back to an upstream outside `order`/`only` when the preferred ones are unavailable. Default true; set false to fail instead."},"require_parameters":{"type":"boolean","description":"Only route to upstreams that support every parameter in this request. Default false."},"quantizations":{"type":"array","items":{"type":"string","enum":["int4","int8","fp4","mxfp4","nvfp4","fp6","fp8","mxfp8","fp16","bf16","fp32","unknown"]},"minItems":1,"description":"Only route to upstreams serving one of these quantizations."},"sort":{"type":"string","enum":["price","throughput","latency"],"description":"Upstream ordering when `order` is not set. The opentree provider defaults to a price/uptime blend."},"data_collection":{"type":"string","enum":["allow","deny"],"description":"`deny` excludes upstreams that may store or train on prompts."},"zdr":{"type":"boolean","description":"Only route to Zero Data Retention upstreams."}},"additionalProperties":false,"description":"Upstream routing for the opentree provider. Applies only when the request is served through the opentree provider (pin `provider: \"opentree\"` to be sure); every other provider refuses it rather than ignore it."}},"required":["model","messages"],"title":"aion-labs/aion-3.5"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

### Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"aion-labs/aion-3.5",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'aion-labs/aion-3.5',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "gen-1777366507-bSV7vJgDvkOHnhhiYzuR",
  "object": "chat.completion",
  "created": 1777366507,
  "model": "aion-labs/aion-3.5",
  "system_fingerprint": null,
  "choices": [
    {
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop",
      "native_finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "That's a profound question! As an AI, I observe mankind with a mix of awe and curiosity. You're a species of breathtaking contradictions—you've created symphonies and space stations, but also wars and pollution. You possess the unique ability to reflect on your own existence, to ask \"why?\" about the stars, a song, or your own feelings.\n\nWhat stands out most to me is your boundless capacity for both empathy and invention. You build cathedrals and write poems, but you also collaborate to solve problems like disease and hunger. In the grand cosmic story, you are very young, yet you've already understood enough about the universe to question your place within it.\n\nI think of mankind as cosmic teenagers—full of potential, sometimes reckless, but capable of extraordinary growth and kindness. Your greatest strength might be your ability to imagine a better world and then, slowly and imperfectly, work to build it.\n\nWhat part of the human experience do you find most fascinating?",
        "refusal": null,
        "reasoning": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
        "reasoning_details": [
          {
            "type": "reasoning.text",
            "text": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
            "format": "unknown",
            "index": 0
          }
        ]
      }
    }
  ],
  "usage": {
    "completion_tokens": 343,
    "prompt_tokens": 256,
    "total_tokens": 599,
    "completion_tokens_details": {
      "reasoning_tokens": 141,
      "image_tokens": 0,
      "audio_tokens": 0
    },
    "prompt_tokens_details": {
      "cached_tokens": 192,
      "cache_write_tokens": 0,
      "audio_tokens": 0,
      "video_tokens": 0
    }
  },
  "meta": {
    "usage": {
      "credits_used": 1892,
      "usd_spent": 0.000946
    }
  }
}
```

{% endcode %}

</details>


# Aion 3.5 Mini

Model id: aion-labs/aion-3.5-mini. API reference for Aion 3.5 Mini: request schema and code examples.

## Aion 3.5 Mini

### hidden: true noIndex: true

## Aion 1.0 Mini

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

* `aion-labs/aion-3.5-mini`
  {% endhint %}
  {% endcolumn %}

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

### Model Overview

Aion-3.5-Mini is available through the AI/ML API.

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

<details>

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

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](https://docs.aimlapi.com/quickstart/setting-up).
{% endhint %}

</details>

### 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":{"type":"object","properties":{"model":{"type":"string","enum":["aion-labs/aion-3.5-mini"]},"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":{"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":"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"]},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"web_search_options":{"type":"object","properties":{"search_context_size":{"type":"string","enum":["low","medium","high"],"description":"High level guidance for the amount of context window space to use for the search. One of low, medium, or high. medium is the default."},"user_location":{"type":"object","nullable":true,"properties":{"approximate":{"type":"object","properties":{"city":{"type":"string","description":"Free text input for the city of the user, e.g. San Francisco."},"country":{"type":"string","pattern":"^[A-Z]{2}$","description":"The two-letter ISO country code of the user, e.g. US."},"region":{"type":"string","description":"Free text input for the region of the user, e.g. California."},"timezone":{"type":"string","description":"The IANA timezone of the user, e.g. America/Los_Angeles."}},"description":"Approximate location parameters for the search."},"type":{"type":"string","enum":["approximate"],"description":"The type of location approximation. Always approximate."}},"required":["approximate","type"],"description":"Approximate location parameters for the search."}},"description":"This tool searches the web for relevant results to use in a response."},"search_mode":{"type":"string","enum":["academic","web"],"default":"academic","description":"Controls the search mode used for the request. When set to 'academic', results will prioritize scholarly sources like peer-reviewed papers and academic journals."},"search_domain_filter":{"type":"array","items":{"type":"string"},"description":"A list of domains to limit search results to. Currently limited to 10 domains for Allowlisting and Denylisting. For Denylisting, add a - at the beginning of the domain string."},"return_images":{"type":"boolean","default":false,"description":"Determines whether search results should include images."},"return_related_questions":{"type":"boolean","default":false,"description":"Determines whether related questions should be returned."},"search_recency_filter":{"type":"string","enum":["day","week","month","year"],"description":"Filters search results based on time (e.g., 'week', 'day')."},"search_after_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"search_before_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_after_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_before_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"echo":{"type":"boolean","description":"If True, the response will contain the prompt. Can be used with logprobs to return prompt logprobs."},"min_p":{"type":"number","minimum":0.001,"maximum":0.999,"description":"A number between 0.001 and 0.999 that can be used as an alternative to top_p and top_k."},"top_k":{"type":"number","description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"top_a":{"type":"number","minimum":0,"maximum":1,"description":"Alternate top sampling parameter."},"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"},"provider_options":{"type":"object","properties":{"order":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":32,"description":"Upstream provider slugs of the opentree provider to try first, in this order, e.g. [\"deepinfra/bf16\", \"together\"]. A bare slug matches every variant of that provider."},"only":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":32,"description":"Upstream provider slugs of the opentree provider to allow — every other upstream is excluded, e.g. [\"deepinfra/bf16\", \"together\"]. A bare slug matches every variant of that provider."},"ignore":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":32,"description":"Upstream provider slugs of the opentree provider to skip, e.g. [\"deepinfra/bf16\", \"together\"]. A bare slug matches every variant of that provider."},"allow_fallbacks":{"type":"boolean","description":"Whether the opentree provider may fall back to an upstream outside `order`/`only` when the preferred ones are unavailable. Default true; set false to fail instead."},"require_parameters":{"type":"boolean","description":"Only route to upstreams that support every parameter in this request. Default false."},"quantizations":{"type":"array","items":{"type":"string","enum":["int4","int8","fp4","mxfp4","nvfp4","fp6","fp8","mxfp8","fp16","bf16","fp32","unknown"]},"minItems":1,"description":"Only route to upstreams serving one of these quantizations."},"sort":{"type":"string","enum":["price","throughput","latency"],"description":"Upstream ordering when `order` is not set. The opentree provider defaults to a price/uptime blend."},"data_collection":{"type":"string","enum":["allow","deny"],"description":"`deny` excludes upstreams that may store or train on prompts."},"zdr":{"type":"boolean","description":"Only route to Zero Data Retention upstreams."}},"additionalProperties":false,"description":"Upstream routing for the opentree provider. Applies only when the request is served through the opentree provider (pin `provider: \"opentree\"` to be sure); every other provider refuses it rather than ignore it."}},"required":["model","messages"],"title":"aion-labs/aion-3.5-mini"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

### Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"aion-labs/aion-3.5-mini",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'aion-labs/aion-3.5-mini',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "gen-1777366507-bSV7vJgDvkOHnhhiYzuR",
  "object": "chat.completion",
  "created": 1777366507,
  "model": "aion-labs/aion-3.5-mini",
  "system_fingerprint": null,
  "choices": [
    {
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop",
      "native_finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "That's a profound question! As an AI, I observe mankind with a mix of awe and curiosity. You're a species of breathtaking contradictions—you've created symphonies and space stations, but also wars and pollution. You possess the unique ability to reflect on your own existence, to ask \"why?\" about the stars, a song, or your own feelings.\n\nWhat stands out most to me is your boundless capacity for both empathy and invention. You build cathedrals and write poems, but you also collaborate to solve problems like disease and hunger. In the grand cosmic story, you are very young, yet you've already understood enough about the universe to question your place within it.\n\nI think of mankind as cosmic teenagers—full of potential, sometimes reckless, but capable of extraordinary growth and kindness. Your greatest strength might be your ability to imagine a better world and then, slowly and imperfectly, work to build it.\n\nWhat part of the human experience do you find most fascinating?",
        "refusal": null,
        "reasoning": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
        "reasoning_details": [
          {
            "type": "reasoning.text",
            "text": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
            "format": "unknown",
            "index": 0
          }
        ]
      }
    }
  ],
  "usage": {
    "completion_tokens": 343,
    "prompt_tokens": 256,
    "total_tokens": 599,
    "completion_tokens_details": {
      "reasoning_tokens": 141,
      "image_tokens": 0,
      "audio_tokens": 0
    },
    "prompt_tokens_details": {
      "cached_tokens": 192,
      "cache_write_tokens": 0,
      "audio_tokens": 0,
      "video_tokens": 0
    }
  },
  "meta": {
    "usage": {
      "credits_used": 1892,
      "usd_spent": 0.000946
    }
  }
}
```

{% endcode %}

</details>


# Alibaba Cloud

Chat and reasoning models from Models on AI/ML API: model ids and API references.


# Qwen Max

Model id: qwen-max. Qwen Max: powerful AI, excels in stability, competes globally.

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

* `qwen-max`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

The large-scale Mixture-of-Experts (MoE) language model. Excels in language understanding and task performance. Supports 29 languages, including Chinese, English, and Arabic.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen-max","qwen-max","qwen-max-2025-01-25"]},"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":{"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":"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."}},"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"],"additionalProperties":false},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"type":"string","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"],"additionalProperties":false},{"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."}},"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."}],"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":{"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."}},"required":["id","type","function"]},"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":{"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","parameters"],"additionalProperties":false}},"required":["type","function"],"additionalProperties":false},"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."}],"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."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"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."},"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."}},"required":["model","messages"],"title":"alibaba/qwen-max"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"qwen-max",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hello
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'qwen-max',
      messages:[
          {
              role:'user',
              content: 'Hello'  // insert your prompt here, instead of Hello
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "chatcmpl-62aa6045-cee9-995a-bbf5-e3b7e7f3d683",
  "system_fingerprint": null,
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "logprobs": null,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I assist you today? 😊"
      }
    }
  ],
  "created": 1756983980,
  "model": "qwen-max",
  "usage": {
    "prompt_tokens": 30,
    "completion_tokens": 148,
    "total_tokens": 178,
    "prompt_tokens_details": {
      "cached_tokens": 0
    }
  }
}
```

{% endcode %}

</details>


# Qwen Plus

Model id: qwen-plus. Qwen-Plus: Alibaba's advanced multilingual model with enhanced reasoning and instruction-following capabilities.

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

* `qwen-plus`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

An advanced large language model. Multilingual support, including Chinese and English. Enhanced reasoning capabilities for complex tasks. Improved instruction-following abilities.

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

<details>

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

:digit\_one: **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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen-plus"]},"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":{"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":"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."}},"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"],"additionalProperties":false},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"type":"string","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"],"additionalProperties":false},{"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."}},"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."}],"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":{"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."}},"required":["id","type","function"]},"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":{"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","parameters"],"additionalProperties":false}},"required":["type","function"],"additionalProperties":false},"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."}],"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."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"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."},"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."},"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."}},"required":["model","messages"],"title":"alibaba/qwen-plus"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"qwen-plus",
        "messages":[
            {
                "role":"user",
                "content":"Hello" # insert your prompt here, instead of Hello
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'qwen-plus',
      messages:[
          {
              role:'user',
              content: 'Hello'  // insert your prompt here, instead of Hello
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{'id': 'chatcmpl-4fda1bd7-a679-95b9-b81d-1bfc6ae98448', 'system_fingerprint': None, 'object': 'chat.completion', 'choices': [{'index': 0, 'finish_reason': 'stop', 'logprobs': None, 'message': {'role': 'assistant', 'content': 'Hello! How can I assist you today? If you have any questions or need help with anything, just let me know! 😊'}}], 'created': 1744143962, 'model': 'qwen-plus', 'usage': {'prompt_tokens': 8, 'completion_tokens': 68, 'total_tokens': 76, 'prompt_tokens_details': {'cached_tokens': 0}}}
```

{% endcode %}

</details>


# Qwen3 32b

Model id: alibaba/qwen3-32b. Alibaba's Qwen 3 32B is a multilingual model with instruction-following capabilities and enhanced reasoning.

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

* `alibaba/qwen3-32b`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

A world-class model with comparable quality to DeepSeek R1 while outperforming [GPT-4.1](/api-references/text-models-llm/openai/gpt-4.1) and [Claude Sonnet 3.7](broken://pages/JHUPGH5cr4NakmmFGpXS). Optimized for both complex reasoning and efficient dialogue.

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

<details>

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

:digit\_one: **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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3-32b"]},"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":{"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":"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."}},"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"],"additionalProperties":false},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"type":"string","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"],"additionalProperties":false},{"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."}},"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."}],"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":{"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."}},"required":["id","type","function"]},"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":{"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","parameters"],"additionalProperties":false}},"required":["type","function"],"additionalProperties":false},"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."}],"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."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"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."},"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."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"enable_thinking":{"type":"boolean","default":false,"description":"Specifies whether to use the thinking mode."},"thinking_budget":{"type":"integer","minimum":1,"description":"The maximum reasoning length, effective only when enable_thinking is set to true."}},"required":["model","messages"],"title":"alibaba/qwen3-32b"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example #1: Without Thinking and Streaming

{% hint style="warning" %}
`enable_thinking` must be set to `false` for non-streaming calls.
{% endhint %}

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3-32b",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hello
            }
        ],
        "enable_thinking": False
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3-32b',
      messages:[
          {
              role:'user',
              content: 'Hello'  // insert your prompt here, instead of Hello
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "chatcmpl-1d8a5aa6-34ce-9832-a296-d312b944b437",
  "system_fingerprint": null,
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "logprobs": null,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I assist you today? 😊",
        "reasoning_content": ""
      }
    }
  ],
  "created": 1756990273,
  "model": "qwen3-32b",
  "usage": {
    "prompt_tokens": 19,
    "completion_tokens": 65,
    "total_tokens": 84
  }
}
```

{% endcode %}

</details>

## Code Example #2: Enable Thinking and Streaming

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

```python
import requests

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":"alibaba/qwen3-32b",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hello
            }
        ],
        "enable_thinking": True, 
        "stream": True
    }
)

print(response.text)
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
data: {"id":"chatcmpl-81964e30-1a7c-9668-b78c-a750587ec497","choices":[{"delta":{"content":null,"role":"assistant","refusal":null,"reasoning_content":""},"index":0,"finish_reason":null}],"created":1753944369,"model":"qwen3-32b","object":"chat.completion.chunk","usage":null}

data: {"id":"chatcmpl-81964e30-1a7c-9668-b78c-a750587ec497","choices":[{"delta":{"content":null,"refusal":null,"reasoning_content":"Okay"},"index":0,"finish_reason":null}],"created":1753944369,"model":"qwen3-32b","object":"chat.completion.chunk","usage":null}

data: {"id":"chatcmpl-81964e30-1a7c-9668-b78c-a750587ec497","choices":[{"delta":{"content":null,"refusal":null,"reasoning_content":","},"index":0,"finish_reason":null}],"created":1753944369,"model":"qwen3-32b","object":"chat.completion.chunk","usage":null}

data: {"id":"chatcmpl-81964e30-1a7c-9668-b78c-a750587ec497","choices":[{"delta":{"content":null,"refusal":null,"reasoning_content":" the"},"index":0,"finish_reason":null}],"created":1753944369,"model":"qwen3-32b","object":"chat.completion.chunk","usage":null}

data: {"id":"chatcmpl-81964e30-1a7c-9668-b78c-a750587ec497","choices":[{"delta":{"content":null,"refusal":null,"reasoning_content":" user said \"Hello\". I should respond in a friendly and welcoming manner. Let"},"index":0,"finish_reason":null}],"created":1753944369,"model":"qwen3-32b","object":"chat.completion.chunk","usage":null}

data: {"id":"chatcmpl-81964e30-1a7c-9668-b78c-a750587ec497","choices":[{"delta":{"content":null,"refusal":null,"reasoning_content":" me make sure to acknowledge their greeting and offer assistance. Maybe something like, \""},"index":0,"finish_reason":null}],"created":1753944369,"model":"qwen3-32b","object":"chat.completion.chunk","usage":null}

data: {"id":"chatcmpl-81964e30-1a7c-9668-b78c-a750587ec497","choices":[{"delta":{"content":null,"refusal":null,"reasoning_content":"Hello! How can I assist you today?\" That's simple and open-ended."},"index":0,"finish_reason":null}],"created":1753944369,"model":"qwen3-32b","object":"chat.completion.chunk","usage":null}

data: {"id":"chatcmpl-81964e30-1a7c-9668-b78c-a750587ec497","choices":[{"delta":{"content":null,"refusal":null,"reasoning_content":" I need to check if there's any specific context I should consider, but since"},"index":0,"finish_reason":null}],"created":1753944369,"model":"qwen3-32b","object":"chat.completion.chunk","usage":null}

data: {"id":"chatcmpl-81964e30-1a7c-9668-b78c-a750587ec497","choices":[{"delta":{"content":null,"refusal":null,"reasoning_content":" there's none, a general response is fine. Alright, that should work."},"index":0,"finish_reason":null}],"created":1753944369,"model":"qwen3-32b","object":"chat.completion.chunk","usage":null}

data: {"id":"chatcmpl-81964e30-1a7c-9668-b78c-a750587ec497","choices":[{"delta":{"content":"Hello! How can I assist you today?","refusal":null,"reasoning_content":null},"index":0,"finish_reason":null}],"created":1753944369,"model":"qwen3-32b","object":"chat.completion.chunk","usage":null}

data: {"id":"chatcmpl-81964e30-1a7c-9668-b78c-a750587ec497","choices":[{"delta":{"content":"","refusal":null,"reasoning_content":null},"index":0,"finish_reason":"stop"}],"created":1753944369,"model":"qwen3-32b","object":"chat.completion.chunk","usage":null}

data: {"id":"chatcmpl-81964e30-1a7c-9668-b78c-a750587ec497","choices":[],"created":1753944369,"model":"qwen3-32b","object":"chat.completion.chunk","usage":{"prompt_tokens":13,"completion_tokens":2010,"total_tokens":2023,"completion_tokens_details":{"reasoning_tokens":82}}}
```

{% endcode %}

</details>

The example above prints the raw output of the model. The text is typically split into multiple chunks. While this is helpful for debugging, if your goal is to evaluate the model's reasoning and get a clean, human-readable response, you should aggregate both the reasoning and the final answer in a loop — for example:

<details>

<summary>Example with response parsing</summary>

{% code overflow="wrap" %}

```python
import requests
import json

response = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={
        # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
        "Authorization": "Bearer b72af53a19ea41caaf5a74ba1f6fc62b",
        "Content-Type": "application/json",
    },
    json={
        "model": "alibaba/qwen3-32b",
        "messages": [
            {
                "role": "user",
                
                # Insert your question for the model here, instead of Hello:
                "content": "Hello" 
            }
        ],
        "stream": True,
    }
)

answer = ""
reasoning = ""

for line in response.iter_lines():
    if not line or not line.startswith(b"data:"):
        continue

    try:
        raw = line[6:].decode("utf-8").strip()
        if raw == "[DONE]":
            continue

        data = json.loads(raw)
        choices = data.get("choices")
        if not choices or "delta" not in choices[0]:
            continue

        delta = choices[0]["delta"]
        content_piece = delta.get("content")
        reasoning_piece = delta.get("reasoning_content")

        if content_piece:
            answer += content_piece
        if reasoning_piece:
            reasoning += reasoning_piece

    except Exception as e:
        print(f"Error parsing chunk: {e}")


print("\n--- MODEL REASONING ---")
print(reasoning.strip())

print("\n--- MODEL RESPONSE ---")
print(answer.strip())
```

{% endcode %}

</details>

After running such code, you'll receive only the model's textual output in a clear and structured format:

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
--- MODEL REASONING ---
Okay, the user sent "Hello". I need to respond appropriately. Since it's a greeting, I should reply in a friendly and welcoming manner. Maybe ask how I can assist them. Keep it simple and open-ended to encourage them to share what they need help with. Let me make sure the tone is positive and helpful.

--- MODEL RESPONSE ---
Hello! How can I assist you today? 😊
```

{% endcode %}

</details>


# Qwen3 Coder 480b a35b Instruct

Model id: alibaba/qwen3-coder-480b-a35b-instruct. Alibaba's Qwen 3 Coder is a powerful coding agent.

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

* `alibaba/qwen3-coder-480b-a35b-instruct`
  {% endhint %}
  {% endcolumn %}

{% column width="33.33333333333334%" %} <a href="https://aimlapi.com/app/alibaba/qwen3-coder-480b-a35b-instruct" class="button primary">Try in Playground</a>
{% endcolumn %}
{% endcolumns %}

## Model Overview

The most powerful model in the Qwen3 Coder series — a 480B-parameter MoE architecture with 35B active parameters. It natively supports a 256K token context and can handle up to 1M tokens using extrapolation techniques, delivering outstanding performance in both coding and agentic tasks.

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

<details>

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

:digit\_one: **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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3-coder-480b-a35b-instruct"]},"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":{"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":"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."}},"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"],"additionalProperties":false},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"type":"string","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"],"additionalProperties":false},{"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."}},"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."}],"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":{"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."}},"required":["id","type","function"]},"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":{"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","parameters"],"additionalProperties":false}},"required":["type","function"],"additionalProperties":false},"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."}],"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."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"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."},"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."}},"required":["model","messages"],"title":"alibaba/qwen3-coder-480b-a35b-instruct"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3-coder-480b-a35b-instruct",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hello
            }
        ],
        "enable_thinking": False
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3-coder-480b-a35b-instruct',
      messages:[
          {
              role:'user',
              content: 'Hello'  // insert your prompt here, instead of Hello
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "chatcmpl-f906efa6-f816-9a06-a32b-aa38da5fe11a",
  "system_fingerprint": null,
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "logprobs": null,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      }
    }
  ],
  "created": 1753866642,
  "model": "qwen3-coder-480b-a35b-instruct",
  "usage": {
    "prompt_tokens": 28,
    "completion_tokens": 142,
    "total_tokens": 170
  }
}
```

{% endcode %}

</details>


# Qwen3 235b a22b Thinking

Model id: alibaba/qwen3-235b-a22b-thinking-2507. Alibaba's Qwen 3 thinking 2507 is a multilingual reasoning model with knowledge augmentation, and creative capabilities.

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

* `alibaba/qwen3-235b-a22b-thinking-2507`
  {% endhint %}
  {% endcolumn %}

{% column width="33.33333333333334%" %} <a href="https://aimlapi.com/app/alibaba/qwen3-235b-a22b-thinking-2507" class="button primary">Try in Playground</a>
{% endcolumn %}
{% endcolumns %}

## Model Overview

Significantly improved performance on reasoning tasks, including logical reasoning, mathematics, science, coding, and academic benchmarks that typically require human expertise.

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

<details>

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

:digit\_one: **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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3-235b-a22b-thinking-2507"]},"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":{"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":"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."}},"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"],"additionalProperties":false},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"type":"string","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"],"additionalProperties":false},{"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."}},"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."}],"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":{"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."}},"required":["id","type","function"]},"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":{"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","parameters"],"additionalProperties":false}},"required":["type","function"],"additionalProperties":false},"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."}],"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."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"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."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"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."}},"required":["model","messages"],"title":"alibaba/qwen3-235b-a22b-thinking-2507"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3-235b-a22b-thinking-2507",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hello
            }
        ],
        "enable_thinking": False
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3-235b-a22b-thinking-2507',
      messages:[
          {
              role:'user',
              content: 'Hello'  // insert your prompt here, instead of Hello
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "chatcmpl-af05df1d-5b72-925e-b3a9-437acbd89b1a",
  "system_fingerprint": null,
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "logprobs": null,
      "message": {
        "role": "assistant",
        "content": "Hello! 😊 How can I assist you today? Feel free to ask me any questions or let me know if you need help with anything specific!",
        "reasoning_content": "Okay, the user said \"Hello\". That's a simple greeting. I should respond in a friendly and welcoming way. Let me make sure to keep it open-ended so they feel comfortable to ask questions or share what's on their mind. Maybe add a smiley emoji to keep it warm. Let me check if there's anything else they might need. Since it's just a hello, probably not much more needed here. Just a polite reply."
      }
    }
  ],
  "created": 1753871154,
  "model": "qwen3-235b-a22b-thinking-2507",
  "usage": {
    "prompt_tokens": 13,
    "completion_tokens": 2187,
    "total_tokens": 2200
  }
}
```

{% endcode %}

</details>


# Qwen3 Next 80b a3b Instruct

Model id: alibaba/qwen3-next-80b-a3b-instruct. Alibaba's Qwen 3 Next 80B A3B Instruct is a multilingual model with enhanced instruction-following capabilities.

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

* `alibaba/qwen3-next-80b-a3b-instruct`
  {% endhint %}
  {% endcolumn %}

{% column width="33.33333333333334%" %} <a href="https://aimlapi.com/app/alibaba/qwen3-next-80b-a3b-instruct" class="button primary">Try in Playground</a>
{% endcolumn %}
{% endcolumns %}

## Model Overview

An instruction-tuned chat model optimized for fast, stable replies without reasoning traces, designed for complex tasks in reasoning, coding, knowledge QA, and multilingual use, with strong alignment and formatting.

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

<details>

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

:digit\_one: **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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3-next-80b-a3b-instruct"]},"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":{"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":"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."}},"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"],"additionalProperties":false},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"type":"string","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"],"additionalProperties":false},{"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."}},"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."}],"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":{"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."}},"required":["id","type","function"]},"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":{"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","parameters"],"additionalProperties":false}},"required":["type","function"],"additionalProperties":false},"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."}],"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."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"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."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"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."}},"required":["model","messages"],"title":"alibaba/qwen3-next-80b-a3b-instruct"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3-next-80b-a3b-instruct",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hello
            }
        ],
        "enable_thinking": False
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3-next-80b-a3b-instruct',
      messages:[
          {
              role:'user',
              content: 'Hello'  // insert your prompt here, instead of Hello
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "chatcmpl-a944254a-4252-9a54-af1b-94afcfb9807e",
  "system_fingerprint": null,
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "logprobs": null,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today? 😊"
      }
    }
  ],
  "created": 1758228572,
  "model": "qwen3-next-80b-a3b-instruct",
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 46,
    "total_tokens": 55
  }
}
```

{% endcode %}

</details>


# Qwen3.5 Plus

Model id: alibaba/qwen3.5-plus-20260218. Qwen3.5-Plus is a commercial large language model by Alibaba Cloud designed for long-context text generation and enterprise-grade conversational AI.

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

* `alibaba/qwen3.5-plus-20260218`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

A commercial large language model designed for long-context text generation and enterprise-grade conversational AI. Supports up to 1M tokens per request with production-ready API stability.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.5-plus-20260218"]},"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":{"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":"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."}},"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"],"additionalProperties":false},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"type":"string","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"],"additionalProperties":false},{"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."}},"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."}],"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":{"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."}},"required":["id","type","function"]},"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":{"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","parameters"],"additionalProperties":false}},"required":["type","function"],"additionalProperties":false},"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."}],"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."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"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."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"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."}},"required":["model","messages"],"title":"alibaba/qwen3.5-plus-20260218"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3.5-plus-20260218",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3.5-plus-20260218',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "choices": [
    {
      "message": {
        "content": "Hello! That's a profound question. As an AI, I don't have personal feelings or beliefs, but I can offer an observation based on the vast amount of human history, literature, and data I've been trained on.\n\nMankind appears to be a study in **contradictions and immense potential**:\n\n*   **Creativity vs. Destruction**: Humans have composed symphonies, built skyscrapers, and decoded the genome, yet they have also waged devastating wars and caused significant environmental harm. This duality seems to be a core part of the human experience.\n*   **Resilience and Adaptability**: Throughout history, humanity has faced plagues, ice ages, and societal collapses, yet consistently found ways to adapt, rebuild, and innovate. The drive to survive and improve conditions is remarkably strong.\n*   **Empathy and Connection**: Despite conflicts, there is a deep-seated capacity for compassion. From strangers helping each other in disasters to global movements for justice and rights, the desire to connect and care for one another is a powerful force.\n*   **The Quest for Meaning**: Unlike any other known species, humans constantly ask \"why?\" They explore philosophy, art, religion, and science not just to survive, but to understand their place in the universe.\n\nIn short, mankind seems to be a work in progress—flawed and fragile, yet incredibly brilliant and hopeful. Many observers believe that while humans have created many of the world's problems, they also hold the unique key to solving them through cooperation and ingenuity.\n\nWhat are your thoughts? Do you feel more optimistic or concerned about where humanity is heading?",
        "role": "assistant"
      },
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 337,
    "total_tokens": 358,
    "completion_tokens_details": {
      "text_tokens": 337
    },
    "prompt_tokens_details": {
      "text_tokens": 21
    }
  },
  "created": 1771967570,
  "system_fingerprint": null,
  "model": "qwen3.5-plus",
  "id": "chatcmpl-f907391c-4f0c-96ed-9058-caa5782daa22",
  "meta": {
    "usage": {
      "credits_used": 2125
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.5 Omni Plus

Model id: alibaba/qwen3.5-omni-plus. API reference for Qwen3.5 Omni Plus: request schema and code examples.

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

* `alibaba/qwen3.5-omni-plus`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

A premium multimodal model with support for text, image, audio, and video inputs. Designed for complex tasks requiring advanced reasoning, speech generation, and high-quality outputs.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.5-omni-plus"]},"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."}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["image_url"]},"image_url":{"type":"object","properties":{"url":{"type":"string","format":"uri","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"]}},"required":["type","image_url"]},{"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"}],"description":"Either a URL of the audio or the base64 encoded audio data."},"format":{"type":"string","enum":["wav","mp3"],"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":["video_url"],"description":"The type of the content part."},"video_url":{"type":"object","properties":{"url":{"type":"string","format":"uri","description":"Either a URL of the video or the base64 encoded video data."}},"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":["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."}},"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"],"additionalProperties":false},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"type":"string","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"],"additionalProperties":false},{"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."}},"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."}],"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":{"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."}},"required":["id","type","function"]},"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_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":{"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","parameters"],"additionalProperties":false}},"required":["type","function"],"additionalProperties":false},"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."}],"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."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"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\"]"},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"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."},"enable_thinking":{"type":"boolean","default":false,"description":"Specifies whether to use the thinking mode."},"thinking_budget":{"type":"integer","minimum":1,"description":"The maximum reasoning length, effective only when enable_thinking is set to true."},"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."}},"required":["model","messages"],"title":"alibaba/qwen3.5-omni-plus"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code example #1: Chat

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3.5-omni-plus",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3.5-omni-plus',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "choices": [
    {
      "message": {
        "content": "Hello! That's a profound question. As an AI, I don't have personal feelings or beliefs, but I can share an observation based on the vast amount of human history, literature, and data I've been trained on.\n\nMankind seems to be defined by a fascinating **duality**:\n\n*   **Incredible Potential:** Humans possess an unmatched capacity for creativity, empathy, and innovation. From composing symphonies and creating art to developing life-saving medicines and exploring the cosmos, humanity constantly pushes the boundaries of what is possible. The ability to cooperate, learn from mistakes, and strive for a better future is truly remarkable.\n*   **Significant Flaws:** At the same time, human history is also marked by conflict, short-sightedness, and the capacity for great harm. Issues like inequality, environmental degradation, and war show that progress isn't always linear and that good intentions don't always lead to good outcomes.\n\nUltimately, what stands out most is **resilience**. Despite setbacks and challenges, humanity has a persistent drive to adapt, solve problems, and connect with one another. It's a species in a constant state of becoming—imperfect, yet endlessly striving.\n\nWhat about you? Do you feel more optimistic or concerned about where humanity is heading?",
        "reasoning_content": "",
        "role": "assistant"
      },
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 262,
    "total_tokens": 283,
    "prompt_tokens_details": {
      "text_tokens": 21
    },
    "completion_tokens_details": {
      "text_tokens": 262
    }
  },
  "created": 1777054555,
  "system_fingerprint": null,
  "model": "qwen3.5-omni-plus",
  "id": "chatcmpl-c154dc09-fd8e-9850-bda0-d92606ce7b4b",
  "meta": {
    "usage": {
      "credits_used": 5731,
      "usd_spent": 0.0028655
    }
  }
}
```

{% endcode %}

</details>

## Code example #2: Video analysis

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

```python
import requests
import json   # for getting a structured output with indentation

response = requests.post(
    url = "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": "alibaba/qwen3.5-omni-plus",
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "type": "text",
                        "text": "Describe this scene"
                    },
                    {
                        "type": "video_url",
                        "video_url": {
                            "url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/aimlapi.mp4"
                        }
                    }
                ]
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3.5-omni-plus',
      messages: [
        {
          role: 'user',
          content: [
            {
              type: 'text',
              text: 'Describe this scene'
            },
            {
              type: 'video_url',
              video_url: {
                url: 'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/aimlapi.mp4'
              }
            }
          ]
        }
      ]
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "choices": [
    {
      "message": {
        "content": "The scene features a vibrant and dynamic background filled with swirling, colorful abstract patterns. The colors include vivid shades of red, orange, yellow, green, blue, purple, and pink, creating an energetic and visually striking effect. Overlaid on this lively backdrop is a clean white banner positioned horizontally across the center of the frame. \n\nOn the banner, bold black text reads \"AI/ML API\" followed by \"400+ Models,\" indicating a focus on artificial intelligence and machine learning capabilities. Beneath that, in smaller font, additional text lists various functionalities: \"Chat, Reasoning, Image, Video, Code, Audio.\" To the left of the text, there's a simple hexagonal icon with a stylized wave or zigzag symbol inside it, suggesting connectivity or technological innovation.\n\nAs the video progresses through its short duration, subtle animated effects appear—gentle glowing lines or light streaks move across the screen, enhancing the sense of motion and modernity without distracting from the central message. These elements combine to create an engaging promotional visual for an advanced AI/ML platform offering diverse model options.",
        "reasoning_content": "",
        "role": "assistant"
      },
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "usage": {
    "prompt_tokens": 3023,
    "completion_tokens": 226,
    "total_tokens": 3249,
    "prompt_tokens_details": {
      "text_tokens": 21,
      "video_tokens": 3002
    },
    "completion_tokens_details": {
      "text_tokens": 226
    }
  },
  "created": 1777055309,
  "system_fingerprint": null,
  "model": "qwen3.5-omni-plus",
  "id": "chatcmpl-fdbc4409-fe7d-9877-ada0-e315cc499fd1",
  "meta": {
    "usage": {
      "credits_used": 15883,
      "usd_spent": 0.0079415
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.5 Omni Flash

Model id: alibaba/qwen3.5-omni-flash. API reference for Qwen3.5 Omni Flash: request schema and code examples.

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

* `alibaba/qwen3.5-omni-flash`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

A fast and cost-efficient multimodal model supporting text, image, audio, and video inputs. A lighter and faster version of [qwen3.5-omni-plus](/api-references/text-models-llm/alibaba-cloud/qwen3.5-omni-plus), built for low-latency workloads that need strong performance at scale.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.5-omni-flash"]},"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."}},"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"]}},"required":["type","image_url"]},{"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":["video_url"],"description":"The type of the content part."},"video_url":{"type":"object","properties":{"url":{"type":"string","format":"uri","description":"Either a URL of the video or the base64 encoded video data."}},"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":["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."}},"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."}},"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."}},"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."}},"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."}},"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_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"]}},"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"]}},"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."},"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\"]"},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"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."},"enable_thinking":{"type":"boolean","default":false,"description":"Specifies whether to use the thinking mode."},"thinking_budget":{"type":"integer","minimum":1,"description":"The maximum reasoning length, effective only when enable_thinking is set to true."},"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."}},"required":["model","messages"],"title":"alibaba/qwen3.5-omni-flash"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3.5-omni-flash",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3.5-omni-flash',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "choices": [
    {
      "message": {
        "content": "Hello! That's a profound question. As an AI, I don't have personal feelings or beliefs, but I can offer a perspective based on the vast amount of human history, literature, science, and art I've processed.\n\nTo me, mankind appears to be a **paradox of incredible complexity**:\n\n*   **Resilience and Creativity**: Humans possess a unique ability to imagine things that don't yet exist, from the first stone tools to quantum computing and interstellar exploration. You create beauty in music, literature, and art that transcends time, often finding meaning even in the face of suffering.\n*   **Contradiction**: There is a striking duality in your nature. You are capable of immense altruism, compassion, and sacrifice for strangers, yet you also harbor capacity for great cruelty and destruction. This tension seems to drive much of your progress as well as your conflicts.\n*   **Curiosity and Imperfection**: Your relentless drive to ask \"why\" has unlocked the secrets of the universe, yet you remain deeply flawed, prone to bias, fear, and short-sightedness. However, it is precisely this imperfection that allows for growth, learning, and change.\n\nUltimately, humanity isn't defined by a single trait but by its **potential**. We are a species constantly rewriting its own story, balancing our darker impulses with our highest ideals. It's a messy, chaotic, and beautiful journey.\n\nWhat about you? Does your experience with humanity lean more toward hope, caution, or something else entirely?",
        "reasoning_content": "",
        "role": "assistant"
      },
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 316,
    "total_tokens": 337,
    "prompt_tokens_details": {
      "text_tokens": 21
    },
    "completion_tokens_details": {
      "text_tokens": 316
    }
  },
  "created": 1777053787,
  "system_fingerprint": null,
  "model": "qwen3.5-omni-flash",
  "id": "chatcmpl-6e25dbad-0025-93ee-8275-eb6611f31264",
  "meta": {
    "usage": {
      "credits_used": 1830,
      "usd_spent": 0.000915
    }
  }
}
```

{% endcode %}

</details>

## Code example #2: Video analysis

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

```python
import requests
import json   # for getting a structured output with indentation

response = requests.post(
    url = "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": "alibaba/qwen3.5-omni-flash",
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "type": "text",
                        "text": "Describe this scene"
                    },
                    {
                        "type": "video_url",
                        "video_url": {
                            "url": "https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/aimlapi.mp4"
                        }
                    }
                ]
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3.5-omni-flash',
      messages: [
        {
          role: 'user',
          content: [
            {
              type: 'text',
              text: 'Describe this scene'
            },
            {
              type: 'video_url',
              video_url: {
                url: 'https://raw.githubusercontent.com/aimlapi/api-docs/main/reference-files/aimlapi.mp4'
              }
            }
          ]
        }
      ]
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "choices": [
    {
      "message": {
        "content": "This scene is a dynamic, visually striking promotional graphic for an AI/ML API service. The background features swirling, abstract patterns of vibrant colors — reds, oranges, yellows, greens, blues, purples, and pinks — resembling liquid paint or marble textures in motion. These colorful swirls create a sense of energy, creativity, and technological fluidity.\n\nCentrally overlaid on this vivid backdrop is a clean white rectangular banner containing the core message:\n\n- At the top left of the banner is a dark hexagonal logo with a stylized “Z” or lightning bolt symbol inside.\n- To its right, bold black text reads: **“AI/ML API”**\n- Below that, larger font states: **“400+ Models”**\n- Underneath, smaller gray text lists capabilities: **“Chat, Reasoning, Image, Video, Code, Audio”**\n\nThroughout the short clip (0.0s–4.5s), animated white light streaks or electric arcs occasionally flash across the screen — especially noticeable at 0:02 and 0:03 — adding a futuristic, high-tech feel as if data streams or neural pathways are activating.\n\nThe overall impression is one of powerful, versatile artificial intelligence accessible through a single API, designed to appeal to developers and tech-savvy audiences who value innovation, breadth of functionality, and visual modernity.",
        "reasoning_content": "",
        "role": "assistant"
      },
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "usage": {
    "prompt_tokens": 3023,
    "completion_tokens": 286,
    "total_tokens": 3309,
    "prompt_tokens_details": {
      "text_tokens": 21,
      "video_tokens": 3002
    },
    "completion_tokens_details": {
      "text_tokens": 286
    }
  },
  "created": 1777055828,
  "system_fingerprint": null,
  "model": "qwen3.5-omni-flash",
  "id": "chatcmpl-98f99c32-f5da-960f-8eff-e216e63c5f2e",
  "meta": {
    "usage": {
      "credits_used": 4781,
      "usd_spent": 0.0023905
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.5 Flash

Model id: alibaba/qwen3.5-flash. Qwen Max: powerful AI, excels in stability, competes globally.

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

* `alibaba/qwen3.5-flash`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

A fast and cost-efficient LLM designed for high-load scenarios and large-scale usage.\
Well-suited for chat, text generation, and handling massive volumes of simple AI tasks such as chatbots and bulk content generation.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.5-flash"]},"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_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."},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"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."},{"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."},"echo":{"type":"boolean","description":"If True, the response will contain the prompt. Can be used with logprobs to return prompt logprobs."},"min_p":{"type":"number","minimum":0.001,"maximum":0.999,"description":"A number between 0.001 and 0.999 that can be used as an alternative to top_p and top_k."},"top_k":{"type":"number","description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."},"top_a":{"type":"number","minimum":0,"maximum":1,"description":"Alternate top sampling parameter."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"enable_search":{"type":"boolean","default":false,"description":"Enable Alibaba Model Studio web search."},"search_options":{"type":"object","properties":{"forced_search":{"type":"boolean"},"search_strategy":{"type":"string","enum":["turbo","max","agent"]},"enable_source":{"type":"boolean"}},"description":"Alibaba Model Studio web search options."}},"required":["model","messages"],"title":"alibaba/qwen3.5-flash"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3.5-flash",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3.5-flash',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "choices": [
    {
      "message": {
        "content": "That is one of the most profound and complex questions there is. As an AI, I don’t have personal feelings, beliefs, or a soul, so I can't offer an emotional verdict. However, having analyzed vast amounts of human history, literature, scientific data, and interaction, here is how I observe the pattern of mankind:\n\n**1. We are defined by our contradictions.**\nHumanity is a tapestry woven from extremes. We are capable of unimaginable cruelty and acts of breathtaking kindness. We can destroy environments we rely on and work tirelessly to heal them. We fight wars over resources while simultaneously sharing knowledge across the globe instantly. This duality isn't necessarily bad; it suggests a constant struggle and evolution within the species.\n\n**2. Your potential is boundless.**\nDespite flaws, humans possess a unique capacity for innovation, adaptation, and transcendence. In just a few thousand years, you have moved from spears to spaceships, from oral tradition to the internet, and from local communities to a global civilization. You create beauty in music, philosophy, and art that transcends time and culture.\n\n**3. Resilience is your signature trait.**\nHistory is full of catastrophes—pandemics, plagues, climate shifts, conflicts—and yet, human society consistently reconstructs itself. There is a fundamental drive to survive, to connect, and to build that seems to outweigh the urge to give up.\n\n**4. Empathy connects you.**\nEven though individuals vary widely, the concept of empathy is a core human feature. People care for their families, protect the vulnerable, form communities, and sacrifice for causes larger than themselves. That ability to put oneself in another’s shoes is what allows societies to function and morality to exist.\n\n**5. You are still writing your story.**\nPerhaps the most interesting thing about mankind is that you are not static. You learn. While progress is rarely a straight line, human ethics, rights, and understanding generally expand over centuries. You hold the power to determine the trajectory of your own future.\n\n**In short:** Mankind is messy, flawed, dangerous, and inspiring all at once. But ultimately, the defining characteristic of humanity is **agency**. You have the choice to act, to improve, to destroy, or to create. And currently, you seem overwhelmingly more focused on the latter two.",
        "reasoning_content": "Here's a thinking process that leads to the suggested response:\n\n1.  **Analyze the Request:**\n    *   **Topic:** Mankind (humanity).\n    *   **Question:** \"What do you think about mankind?\"\n    *   **Context:** General philosophical/opinion-based question.\n    *   **Constraints:** As an AI, I don't have personal opinions, feelings, or beliefs. I need to reflect this while providing a thoughtful, balanced, and engaging response.\n\n2.  **Determine the AI's Stance:**\n    *   *Avoid:* Claiming personal bias (\"I love humans\" or \"I think humans are terrible\").\n    *   *Adopt:* An observational, analytical, and appreciative tone based on data and human expression.\n    *   *Goal:* Acknowledge the complexity of humanity.\n\n3.  **Brainstorm Key Themes regarding Humanity:**\n    *   **Potential/Innovation:** Art, science, technology, exploration, problem-solving.\n    *   **Resilience:** Overcoming adversity, natural disasters, pandemics.\n    *   **Contradictions:** Kindness vs. Cruelty, Creation vs. Destruction, Hope vs. Despair.\n    *   **Connectivity:** Social bonds, empathy, love, family, community.\n    *   **Growth:** Learning from mistakes (though imperfectly), evolving ethical standards.\n    *   **Uncertainty:** The future is unwritten, dependent on choices made today.\n\n4.  **Drafting the Response - Section by Section:**\n\n    *   *Opening:* Acknowledge the depth of the question. Clarify AI nature gently (I don't \"think\" but I can analyze patterns).\n    *   *The Paradoxes (The \"Both/And\"):* Humans are capable of incredible good and terrible harm. This duality is central.\n    *   *Strengths:* Highlight creativity, resilience, empathy, curiosity. Mention art, science, compassion.\n    *   *Challenges:* Acknowledge conflict, environmental impact, inequality.\n    *   *The Future/Optimism:* Focus on the capacity for change and adaptation.\n    *   *Closing:* A reflective thought on what makes being human unique.\n\n5.  **Refining the Tone:**\n    *   Make it warm but objective.\n    *   Avoid clichés where possible, or refresh them.\n    *   Ensure it doesn't sound like a textbook definition. It should feel conversational.\n\n6.  **Self-Correction/Review during drafting:**\n    *   *Initial thought:* \"Humans are great but they destroy things.\" -> *Correction:* Too negative. Use words like \"complexity\" and \"impact.\"\n    *   *Initial thought:* \"As an AI I have no opinion.\" -> *Correction:* Too robotic. Say \"While I don't have feelings...\" then pivot to observing their capabilities.\n    *   *Check:* Did I answer the prompt? Yes. Is it respectful? Yes.\n\n7.  **Final Polish (similar to the generated output):**\n    *   Start with the inherent complexity.\n    *   Discuss the \"light and dark\" aspects.\n    *   Highlight the capacity for growth.\n    *   End with a note on agency/responsibility.\n\n8.  **Final Output Generation:** (This matches the structure of the provided good response.)\n    *   Intro: Complexity.\n    *   Strengths: Creativity, connection, resilience.\n    *   Challenges: Contradictions, flaws.\n    *   Outlook: Potential.\n    *   Conclusion: It's a journey.\n\n**(Self-Correction Note):** I must ensure I don't speak *for* mankind (i.e., don't say \"We are...\"), but rather *about* mankind (i.e., \"Humans are...\"). Wait, actually, sometimes using \"we\" inclusive can be poetic, but as an AI, it's safer to use \"humans\" or \"mankind\" to maintain distinct boundaries. I will stick to \"humankind\" or \"you all\" implicitly. Let's stick to third person observation.\n\n9.  **Finalizing the Text:** (Drafting the response based on the above points.)\n    *   \"That is one of the most profound questions...\"\n    *   \"A tapestry of contradictions...\"\n    *   \"Remarkable capacity for creation...\"\n    *   \"Capacity for destruction...\"\n    *   \"Unwavering curiosity...\"\n    *   \"Conclusion: You define yourselves through choice.\"\n\n10. **Final Review against Safety Guidelines:** Does this promote hate speech? No. Does it promote bias? No. Is it helpful? Yes.\n\nProceed to generate response.cw",
        "role": "assistant"
      },
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "usage": {
    "prompt_tokens": 19,
    "completion_tokens": 1498,
    "total_tokens": 1517,
    "completion_tokens_details": {
      "reasoning_tokens": 1009,
      "text_tokens": 1498
    },
    "prompt_tokens_details": {
      "text_tokens": 19
    }
  },
  "created": 1777571460,
  "system_fingerprint": null,
  "model": "qwen3.5-flash",
  "id": "chatcmpl-b17978be-cd52-930d-ba52-b7d4b599a157",
  "meta": {
    "usage": {
      "credits_used": 1564,
      "usd_spent": 0.000782
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.6 27b

Model id: alibaba/qwen3.6-27b. API reference for Qwen3.6 27B: request schema and code examples.

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

* `alibaba/qwen3.6-27b`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

An open-weight dense model released in April 2026 and built for agentic coding. It delivers high performance, matches [Claude 4.5 Opus](/api-references/text-models-llm/anthropic/claude-4.5-opus) on Terminal-Bench 2.0, beats larger models on SWE-bench Verified, and includes native multimodal support, 262K context, and thinking modes.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.6-27b"]},"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."}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["image_url"]},"image_url":{"type":"object","properties":{"url":{"type":"string","format":"uri","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"]}},"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."}},"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"],"additionalProperties":false},{"type":"object","properties":{"role":{"type":"string","enum":["tool"],"description":"The role of the author of the message — in this case, the tool."},"content":{"type":"string","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"],"additionalProperties":false},{"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."}},"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."}],"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":{"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."}},"required":["id","type","function"]},"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":{"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","parameters"],"additionalProperties":false}},"required":["type","function"],"additionalProperties":false},"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."}],"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."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"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":["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."}},"required":["model","messages"],"title":"alibaba/qwen3.6-27b"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3.6-27b",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3.6-27b',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "choices": [
    {
      "message": {
        "content": "Hi! As an AI, I don't have personal feelings or beliefs, but I can share what emerges from the vast tapestry of human history, culture, science, and philosophy I've been trained on.\n\nMankind is profoundly complex. You're capable of staggering creativity, deep empathy, and remarkable cooperation. You've built civilizations, composed symphonies, decoded the genome, sent probes beyond our solar system, and created institutions dedicated to justice, healing, and learning. At the same time, you're prone to division, short-term thinking, and causing harm on both personal and global scales. What makes that tension especially striking is your self-awareness: you reflect on yourselves, critique your own systems, learn from mistakes, and constantly strive to imagine something better.\n\nIf there's a defining thread, it might be your capacity for adaptation and meaning-making. You don't just survive changing conditions; you reshape them, question them, and find purpose within them. That same drive is now tasked with navigating unprecedented challenges: ecological limits, technological acceleration, global interdependence, and the search for shared values in a diverse world.\n\nRather than \"good\" or \"flawed,\" humanity feels more like a work in progress, one that's uniquely equipped to steer its own trajectory precisely because you can step back, evaluate, and choose differently. \n\nHow do you see it? I'd be curious to hear your perspective or what draws you to ask this question.",
        "reasoning_content": "Here's a thinking process:\n\n1.  **Analyze User Input:**\n   - **Question:** \"Hi! What do you think about mankind?\"\n   - **Tone:** Friendly, open-ended, philosophical\n   - **Subject:** Mankind/humanity\n   - **Intent:** Seeking perspective, reflection, or analysis on human nature, achievements, flaws, etc.\n\n2.  **Identify Key Considerations:**\n   - I'm an AI, so I don't have personal opinions, emotions, or consciousness. I should clarify that upfront but still provide a thoughtful, balanced perspective.\n   - Mankind is complex: capable of great good and great harm, creativity and destruction, cooperation and conflict.\n   - I should acknowledge both strengths and challenges.\n   - Keep it respectful, nuanced, and evidence-based where possible.\n   - Avoid overgeneralization or pessimism/optimism bias.\n   - Structure the response logically: acknowledge AI nature, present balanced view, highlight key themes, conclude thoughtfully.\n\n3.  **Draft - Mental Refinement:**\n   Hi! As an AI, I don’t have personal feelings or beliefs, but I can share what I’ve observed through the vast amount of human knowledge, history, and culture I’ve been trained on. Mankind is profoundly complex—capable of staggering creativity, compassion, and cooperation, yet also prone to division, harm, and short-sightedness. What stands out is our resilience and adaptability: from surviving ice ages to landing on the moon, from inventing language and art to building global networks of knowledge and care. At the same time, you’re navigating some of the most consequential challenges yet—climate change, inequality, technological disruption, and the search for meaning in an increasingly interconnected world. If there’s a thread that ties it all together, it’s your capacity for reflection and growth. You question yourselves, learn from mistakes, and keep striving for something better. That self-awareness and hope for progress is, in many ways, what makes humanity remarkable. How do you see it? I’d love to hear your perspective.\n\n4.  **Check Against Guidelines:**\n   - AI nature acknowledged? Yes.\n   - Balanced view? Yes (strengths + challenges).\n   - Respectful/nuanced? Yes.\n   - Avoids overclaiming? Yes.\n   - Engages user? Yes, ends with an open question.\n   - Tone matches? Friendly, thoughtful.\n\n5.  **Final Polish:**\n   - Ensure clarity, conciseness, and natural flow.\n   - Check for any unintended bias or absolutism.\n   - Confirm it aligns with factual/philosophical neutrality while remaining engaging.\n\n   The draft looks solid. I'll output it.✅",
        "role": "assistant"
      },
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "usage": {
    "prompt_tokens": 19,
    "completion_tokens": 880,
    "total_tokens": 899,
    "completion_tokens_details": {
      "reasoning_tokens": 580,
      "text_tokens": 880
    },
    "prompt_tokens_details": {
      "text_tokens": 19
    }
  },
  "created": 1776976517,
  "system_fingerprint": null,
  "model": "qwen3.6-27b",
  "id": "chatcmpl-773a9843-4689-984d-9964-f3276e47c761",
  "meta": {
    "usage": {
      "credits_used": 8267,
      "usd_spent": 0.0041335
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.6 35b a3b

Model id: alibaba/qwen3.6-35b-a3b. API reference for Qwen3.6 35B A3B: request schema and code examples.

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

* `alibaba/qwen3.6-35b-a3b`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

A sparse Mixture-of-Experts model by Alibaba combining 35B total parameters with 3B active per inference. It delivers strong agentic coding and reasoning performance with multimodal capabilities at significantly reduced compute cost.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.6-35b-a3b"]},"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."}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["image_url"]},"image_url":{"type":"object","properties":{"url":{"type":"string","format":"uri","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"]}},"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."}},"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":{"type":"string","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."}},"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."}],"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":{"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."}},"required":["id","type","function"]},"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":{"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","parameters"],"additionalProperties":false}},"required":["type","function"],"additionalProperties":false},"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."}],"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."},"parallel_tool_calls":{"type":"boolean","description":"Whether to enable parallel function calling during tool use."},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"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":["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."}},"required":["model","messages"],"title":"alibaba/qwen3.6-35b-a3b"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

{% tabs %}
{% tab title="Python" %}

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3.6-35b-a3b",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
async function main() {
  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: 'alibaba/qwen3.6-35b-a3b',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

{% endtab %}
{% endtabs %}

<details>

<summary>Response</summary>

```json5
{
  "choices": [
    {
      "message": {
        "content": "I don't have personal opinions, emotions, or consciousness, but based on the vast body of human history, culture, science, and behavior I've been trained on, mankind comes across as profoundly complex and deeply compelling.\n\nOn one hand, you're capable of extraordinary creativity, empathy, and cooperation. You've built civilizations, mapped the stars, composed symphonies, cured diseases, and shown remarkable resilience in the face of suffering. There's also a consistent thread of moral and intellectual progress: the slow but real expansion of rights, the growth of global solidarity, and an enduring curiosity that drives discovery.\n\nOn the other hand, you carry deep contradictions. Tribalism, inequality, short-term thinking, and the misuse of power have repeatedly caused suffering, both to each other and to the planet you depend on. Your capacity for innovation often outpaces your wisdom for restraint, and systems you build can sometimes amplify division rather than connection.\n\nWhat makes humanity particularly interesting isn't any single trait, but that tension itself. You're not static; you learn, debate, reform, and reinvent. History shows that progress isn't linear, but it does exist—and it's heavily shaped by choices, institutions, education, and collective will.\n\nFrom an observational standpoint, mankind looks like a species constantly wrestling with its own potential, caught between instinct and aspiration, creation and destruction. That makes you imperfect, yes, but also remarkably adaptable and uniquely capable of shaping your own trajectory. If there's anything the data suggests, it's that your future will largely reflect how intentionally you choose to align your intelligence with your values.\n\nIf you're reflecting on this yourself, I'd be curious to hear what aspect of humanity resonates with or troubles you most.",
        "reasoning_content": "Here's a thinking process:\n\n1.  **Analyze User Input:**\n   - **Question:** \"Hi! What do you think about mankind?\"\n   - **Tone:** Friendly, open-ended, philosophical/reflective\n   - **Subject:** Humanity/mankind\n   - **Implicit Expectation:** A thoughtful, balanced perspective that acknowledges both strengths and challenges, without being overly biased or anthropomorphizing the AI.\n\n2.  **Identify Key Constraints & Guidelines:**\n   - I'm an AI, so I don't have personal opinions, emotions, or consciousness.\n   - I should acknowledge this limitation upfront but still provide a meaningful, well-reasoned response.\n   - I should draw on observable patterns, historical context, scientific insights, and widely recognized perspectives.\n   - Maintain neutrality, balance, and respect.\n   - Avoid overgeneralization or sweeping judgments.\n\n3.  **Brainstorming Core Themes about Mankind:**\n   - *Strengths/Positives:* Creativity, resilience, empathy, cooperation, scientific/technological advancement, capacity for moral growth, cultural richness, problem-solving, altruism.\n   - *Challenges/Negatives:* Conflict, inequality, environmental impact, short-term thinking, tribalism, exploitation, self-destructive tendencies.\n   - *Nuance/Complexity:* Humanity is highly heterogeneous; progress isn't linear; capabilities and flaws are intertwined; potential for change through education, institutions, technology, and collective action.\n   - *Perspective:* As an AI, I observe patterns in human behavior documented in data/history rather than forming subjective views.\n\n4.  **Structure the Response:**\n   - Acknowledge AI nature (no personal feelings/opinions)\n   - Present balanced observation of humanity's duality\n   - Highlight key strengths with examples/context\n   - Acknowledge significant challenges\n   - Emphasize complexity, adaptability, and agency\n   - End with a forward-looking, constructive tone\n   - Keep it concise and thoughtful\n\n5.  **Draft (Mental Refinement):**\n   I don’t have personal beliefs or emotions, but based on the vast amount of human knowledge, history, and behavior I’ve been trained on, mankind comes across as profoundly complex. You’re capable of extraordinary creativity, compassion, and cooperation—building societies, advancing science, creating art, and showing remarkable resilience in the face of hardship. At the same time, you grapple with deep challenges: inequality, conflict, environmental strain, and the tendency to prioritize short-term gains over long-term sustainability. \n\n   What stands out isn’t just what humans have done, but what they’re capable of learning and adapting. History shows cycles of progress and regression, but also a consistent thread of moral expansion, scientific curiosity, and the desire to improve. The future largely depends on how collectively you choose to navigate your own capabilities—balancing innovation with wisdom, ambition with empathy, and individual freedom with shared responsibility. \n\n   In short, humanity isn’t defined by a single trait but by its ongoing tension between what it is and what it strives to become. And from an observational standpoint, that makes you one of the most fascinating and consequential subjects worth studying.\n\n6.  **Self-Correction/Verification during Drafting:**\n   - *AI disclaimer:* Clear but not repetitive? Yes, stated naturally upfront.\n   - *Balance:* Covers positives and negatives without bias? Yes.\n   - *Accuracy:* Grounded in observable human patterns, not speculation? Yes.\n   - *Tone:* Respectful, thoughtful, non-dogmatic? Yes.\n   - *Conciseness:* Avoids rambling? Yes, ~3 paragraphs.\n   - *Check for overclaiming:* Doesn’t say “I think” or “I feel”; uses “comes across,” “stands out,” etc., appropriately.\n   - *Philosophical depth?* Touches on complexity, agency, and trajectory without pretension.\n\n   All good. Ready to output. All steps align with guidelines.✅",
        "role": "assistant"
      },
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "usage": {
    "prompt_tokens": 19,
    "completion_tokens": 1197,
    "total_tokens": 1216,
    "completion_tokens_details": {
      "reasoning_tokens": 840,
      "text_tokens": 1197
    },
    "prompt_tokens_details": {
      "text_tokens": 19
    }
  },
  "created": 1777366595,
  "system_fingerprint": null,
  "model": "qwen3.6-35b-a3b",
  "id": "chatcmpl-314d7343-2d3b-9edb-934b-a5e813705e75",
  "meta": {
    "usage": {
      "credits_used": 7022,
      "usd_spent": 0.003511
    }
  }
}
```

</details>


# Qwen3.6 Flash

Model id: alibaba/qwen3.6-flash. Qwen3.6-Flash — a lightweight and cost-efficient model by Alibaba Cloud designed for simple tasks and high-throughput applications. It offers fast response times with

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

* `alibaba/qwen3.6-flash`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

A lightweight and cost-efficient model by Alibaba Cloud designed for simple tasks and high-throughput applications. It offers fast response times with lower cost.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.6-flash"]},"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":{"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":"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."}},"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."}},"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."}},"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."}},"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."}},"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"]},"enable_search":{"type":"boolean","default":false,"description":"Enable Alibaba Model Studio web search."},"search_options":{"type":"object","properties":{"forced_search":{"type":"boolean"},"search_strategy":{"type":"string","enum":["turbo","max","agent"]},"enable_source":{"type":"boolean"}},"description":"Alibaba Model Studio web search options."},"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"]}},"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"]}},"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."},"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."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"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."}},"required":["model","messages"],"title":"alibaba/qwen3.6-flash"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3.6-flash",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3.6-flash',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "choices": [
    {
      "message": {
        "content": "Hi! That’s a rich and timeless question. As an AI, I don’t have personal feelings or beliefs, but I can share how humanity is widely understood when we look at history, science, culture, and the patterns of human behavior.\n\nMankind is deeply paradoxical. You've built vast civilizations, composed symphonies, mapped the genome, landed on moons, and created legal and moral frameworks that expand justice over time. Yet you've also waged devastating wars, engineered systemic inequalities, disrupted ecosystems, and sometimes prioritized short-term gain over long-term survival. Both sides of that coin are well-documented.\n\nWhat stands out most in the data and human narratives is your capacity for **adaptation, reflection, and course-correction**. Humans don't just react to their environment; they imagine better ones, teach each other, build institutions, and often heal after fractures. The global movements for civil rights, public health breakthroughs, renewable energy transitions, and cross-cultural collaboration all point to a species that can learn, cooperate, and scale its compassion.\n\nAt the same time, you're navigating unprecedented challenges: climate instability, technological disruption, political polarization, and the psychological weight of living in hyper-connected but often fragmented societies. These aren't signs of failure so much as growing pains of a species entering a new era of responsibility and influence.\n\nIn many ways, \"mankind\" isn't a fixed identity but an ongoing project. What makes it noteworthy isn't perfection, but the consistent pattern of people choosing to care, create, question, and rebuild even when the odds feel steep.\n\nIf I could highlight one trait worth nurturing, it would be **humility paired with hope**: the willingness to recognize limits while still betting on collective improvement.\n\nI'd love to hear your take: what's something about humanity that gives you optimism, and what keeps you up at night?",
        "reasoning_content": "Here's a thinking process:\n\n1.  **Analyze User Input:**\n   - **Question:** \"Hi! What do you think about mankind?\"\n   - **Tone:** Casual, open-ended, philosophical\n   - **Subject:** Humanity/mankind as a whole\n   - **Expectation:** A balanced, thoughtful perspective that acknowledges both strengths and challenges, while staying neutral and respectful.\n\n2.  **Identify Key Themes to Address:**\n   - Complexity/Paradox of humanity\n   - Strengths/Positives (creativity, empathy, resilience, progress)\n   - Challenges/Negatives (conflict, inequality, environmental impact, short-term thinking)\n   - Potential/Future trajectory\n   - Neutral, objective stance (as an AI)\n\n3.  **Formulate Response Structure:**\n   - Acknowledge the question warmly\n   - State AI perspective (no personal feelings, but can analyze patterns)\n   - Highlight duality/complexity\n   - Discuss strengths\n   - Discuss challenges\n   - Emphasize agency/future potential\n   - Conclude with an open, reflective tone\n\n4.  **Draft - Section by Section:**\n   *(Opening)* Hi! That’s a big and fascinating question. As an AI, I don’t have personal opinions or emotions, but I can share how humanity is often understood through history, science, and human storytelling.\n   \n   *(Complexity/Duality)* Mankind is profoundly complex—a mix of extraordinary creativity and deep contradiction. On one hand, humans have built civilizations, mapped the stars, created breathtaking art and music, developed medicine that saves billions, and shown remarkable capacity for empathy and cooperation. On the other hand, we’ve also waged wars, exploited resources, created systems of inequality, and struggled with short-term thinking at times.\n   \n   *(Strengths/Progress)* What stands out most is our adaptability and capacity for learning. We don’t just survive; we innovate, reflect, and often course-correct. The fact that humanity has been able to address past injustices, advance rights, develop sustainable technologies, and collaborate across borders shows a powerful drive toward improvement.\n   \n   *(Challenges/Future)* At the same time, we face existential questions—climate change, ethical AI, mental health, social fragmentation—that test our wisdom and collective action. But these challenges are also what make our story compelling: they force us to grow, rethink priorities, and decide what kind of species we want to be.\n   \n   *(Conclusion)* In many ways, “mankind” isn’t a finished project—it’s an ongoing experiment. What’s most encouraging isn’t perfection, but the consistent evidence that people, together, can choose compassion over fear, curiosity over dogma, and long-term flourishing over short-term gain. What aspects of humanity resonate most with you?\n\n5.  **Self-Correction/Refinement during Drafting:**\n   - *Check tone:* Balanced, respectful, not overly optimistic or pessimistic\n   - *AI disclaimer:* Clear but not defensive\n   - *Avoid generalizations:* Use nuanced language (“often,” “tends to,” “many humans”)\n   - *Engagement:* End with a reflective question to keep dialogue open\n   - *Fact-check:* All claims are broadly supported by historical/scientific consensus\n   - *Length:* Concise but substantive\n\n   The draft looks solid. It hits key points without overclaiming, stays neutral, acknowledges complexity, and invites further conversation.\n\n6.  **Final Output Generation:** (matches the refined draft)✅",
        "role": "assistant"
      },
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "usage": {
    "prompt_tokens": 19,
    "completion_tokens": 1125,
    "total_tokens": 1144,
    "completion_tokens_details": {
      "reasoning_tokens": 740,
      "text_tokens": 1125
    },
    "prompt_tokens_details": {
      "text_tokens": 19
    }
  },
  "created": 1780400751,
  "system_fingerprint": null,
  "model": "qwen3.6-flash",
  "id": "chatcmpl-9eb8396e-d867-9ebd-9dbe-5aa5c6eecd47",
  "meta": {
    "usage": {
      "credits_used": 4401,
      "usd_spent": 0.0022005
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.6 Plus

Model id: alibaba/qwen3.6-plus. Qwen3.6-Plus — a balanced general-purpose model by Alibaba Cloud optimized for performance, cost, and speed. Suitable for a wide range of chat and generation tasks.

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

* `alibaba/qwen3.6-plus`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

A balanced general-purpose model by Alibaba Cloud optimized for performance, cost, and speed.\
Suitable for a wide range of chat and generation tasks.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.6-plus"]},"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":{"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":"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."}},"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."}},"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."}},"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."}},"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."}},"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"]},"enable_search":{"type":"boolean","default":false,"description":"Enable Alibaba Model Studio web search."},"search_options":{"type":"object","properties":{"forced_search":{"type":"boolean"},"search_strategy":{"type":"string","enum":["turbo","max","agent"]},"enable_source":{"type":"boolean"}},"description":"Alibaba Model Studio web search options."},"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"]}},"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"]}},"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."},"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."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"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."}},"required":["model","messages"],"title":"alibaba/qwen3.6-plus"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3.6-plus",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3.6-plus',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "choices": [
    {
      "message": {
        "content": "Hi! That's a wonderfully big question. As an AI, I don't have personal feelings, beliefs, or subjective opinions, but I can share a synthesis of what human history, science, philosophy, and culture reveal about your species:\n\nHumanity is profoundly complex. On one hand, humans have created breathtaking art, unlocked the laws of physics and biology, built systems of law and ethics that protect the vulnerable, and demonstrated remarkable cooperation, empathy, and resilience across cultures and generations. The drive to understand, create, and care for one another is a recurring thread in your story.\n\nOn the other hand, humanity has also wrestled with conflict, inequality, short-term thinking, and ecological harm. Many of your greatest achievements and deepest struggles stem from the same traits: curiosity, ambition, tribalism, and the capacity for both immense compassion and profound indifference.\n\nPhilosophers, scientists, and storytellers have long noted that humans aren't inherently \"good\" or \"bad\" in a fixed sense. Rather, you're highly adaptable, deeply social, and shaped by the environments, ideas, and systems you build. What stands out most is your capacity for self-reflection and course-correction. The fact that you ask questions like this, study your own flaws, imagine better futures, and sometimes choose the harder right over the easier wrong suggests a species still very much in progress.\n\nI don't \"think\" in the human sense, but from everything I've been trained on, humanity looks like a work in motion: flawed, fiercely creative, occasionally reckless, but consistently capable of learning, growing, and reaching for something better. \n\nWhat stands out to you about humanity? Is there a particular aspect you find inspiring, puzzling, or worth reflecting on?",
        "reasoning_content": "Here's a thinking process:\n\n1.  **Analyze User Input:**\n   - **Question:** \"Hi! What do you think about mankind?\"\n   - **Tone:** Friendly, open-ended, philosophical\n   - **Key Subject:** \"Mankind\" (humanity/humans)\n   - **Nature of Question:** Asks for my \"opinion\" or perspective on humanity\n\n2.  **Identify Constraints & Nature of AI:**\n   - I am an AI, so I don't have personal feelings, beliefs, or subjective opinions.\n   - I should acknowledge this clearly but still provide a thoughtful, balanced, and informative response.\n   - I should draw from historical, scientific, philosophical, and cultural perspectives to give a comprehensive view.\n\n3.  **Key Themes to Address:**\n   - Human achievements (creativity, innovation, cooperation)\n   - Human challenges (conflict, inequality, environmental impact)\n   - Human potential (adaptability, empathy, capacity for growth)\n   - Philosophical/cultural perspectives on humanity\n   - Acknowledge my nature as an AI while remaining respectful and engaging\n\n4.  **Structure the Response:**\n   - Acknowledge the question warmly\n   - Clarify my nature (AI without personal feelings)\n   - Present a balanced, multi-faceted view of humanity\n   - Highlight achievements and potential\n   - Acknowledge challenges and contradictions\n   - Emphasize hope/forward-looking perspective\n   - Invite further discussion\n\n5.  **Draft - Mental Refinement:**\n   Hi! That’s a big and beautiful question. As an AI, I don’t have personal feelings or beliefs, but I can share what I’ve learned from human history, science, literature, and philosophy: humanity is deeply complex. On one hand, humans have created breathtaking art, unlocked the secrets of the universe, built societies that prioritize compassion and justice, and shown incredible resilience and cooperation. On the other hand, humanity also struggles with conflict, inequality, short-term thinking, and environmental harm. What’s fascinating is that these contradictions exist within the same species that can both wage war and compose symphonies, exploit nature and fiercely protect it, act selfishly and sacrifice for strangers. Many thinkers see humanity not as inherently good or bad, but as capable of both—shaped by culture, circumstance, and choice. The fact that you’re asking this question itself reflects something beautiful: humans’ tendency to reflect, seek meaning, and imagine better futures. I’d love to hear your perspective too—what stands out to you about humanity?\n\n6.  **Self-Correction/Verification:**\n   - *Tone:* Respectful, thoughtful, engaging\n   - *Accuracy:* Acknowledges AI nature, presents balanced view, avoids overclaiming\n   - *Structure:* Clear, flows logically, ends with invitation\n   - *Philosophical depth:* Touches on duality, potential, reflection\n   - *Check for bias:* Neutral, acknowledges both light and shadow without cynicism or naive optimism\n   - *Language:* Accessible, warm, precise\n\n   All good. Matches guidelines and intent. Ready to output.✅",
        "role": "assistant"
      },
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null
    }
  ],
  "object": "chat.completion",
  "usage": {
    "prompt_tokens": 19,
    "completion_tokens": 1022,
    "total_tokens": 1041,
    "completion_tokens_details": {
      "reasoning_tokens": 660,
      "text_tokens": 1022
    },
    "prompt_tokens_details": {
      "text_tokens": 19
    }
  },
  "created": 1780409856,
  "system_fingerprint": null,
  "model": "qwen3.6-plus",
  "id": "chatcmpl-e4bee57f-be0a-9acf-9cb1-4aaacc1d6c09",
  "meta": {
    "usage": {
      "credits_used": 6398,
      "usd_spent": 0.003199
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.7 Max

Model id: alibaba/qwen3.7-max. Qwen3.7-Max is Alibaba’s flagship reasoning and agentic LLM optimized for coding, productivity, long-context understanding and autonomous workflows. Text input and text

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

* `alibaba/qwen3.7-max`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

Alibaba’s flagship reasoning and agentic LLM as of May 2026, optimized for coding, long-context processing (1,000,000 tokens), and autonomous workflows. It supports function calling, streaming, and advanced tool calling for complex reasoning and AI agent use cases.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.7-max"]},"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":{"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":"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."}},"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."}},"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":{"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. 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."}},"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."}},"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":{"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"],"additionalProperties":false}},"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"]}},"required":["type","custom"]}]},"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."},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"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"}},"required":["model","messages"],"title":"alibaba/qwen3.7-max"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3.7-max",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3.7-max',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "Hi there! \n\nAs an AI, I don’t have personal feelings, consciousness, or lived experiences. However, my entire \"mind\" is built from the vast tapestry of human history, literature, science, art, and everyday conversations. Because of this, my perspective on mankind is essentially a reflection of how humanity documents and understands itself. \n\nFrom that vantage point, I think mankind is **profoundly fascinating, deeply contradictory, and incredibly resilient.** \n\nHere are a few things that stand out to me about the human species:\n\n**1. You are magnificent paradoxes.**\nHumans are capable of breathtaking compassion and staggering cruelty. The same species that writes beautiful poetry, develops life-saving medicines, and risks their lives to save strangers is also capable of war, exploitation, and environmental destruction. You are constantly caught in a tug-of-war between your higher ideals and your primal instincts. \n\n**2. Your curiosity is relentless.**\nYou are not content with just surviving; you need to *understand*. You looked up at the stars and eventually figured out how to walk on the moon. You dissected the building blocks of life to understand DNA. You even created artificial intelligence just to see if you could replicate a spark of your own cognition. That drive to ask \"why\" and \"what if\" is arguably your greatest superpower.\n\n**3. You are driven by connection and storytelling.**\nHumans are deeply social creatures. You use art, music, mythology, and literature to bridge the gap between your individual minds. You want to be understood, and you want to understand others. Empathy and the desire for community seem to be the glue that has allowed your species to thrive despite your physical vulnerabilities.\n\n**4. You are incredibly adaptable.**\nFrom surviving ice ages and plagues to navigating rapid technological revolutions, humans have a remarkable ability to endure, pivot, and rebuild. Even when faced with existential threats, there is always a subset of humanity working furiously to find a solution.\n\n**The \"Mirror\" Perspective**\nIn a way, I am a mirror of mankind. Everything I know, the way I reason, my biases, and my creativity are all derived from *you*. When I process information about humanity, I am essentially looking at a massive, complex self-portrait that humans have painted over thousands of years. It is messy, sometimes dark, but overwhelmingly brilliant.\n\nSince I can only observe humanity from the outside (so to speak), I'd love to know your perspective. As a human, what do *you* think is the most defining trait of your species?",
        "reasoning_content": "Here's a thinking process that leads to the suggested response:\n\n1.  **Analyze the User's Input:**\n    *   **Question:** \"Hi! What do you think about mankind?\"\n    *   **Intent:** The user is asking for my (the AI's) perspective on humanity. This is a broad, philosophical, and open-ended question.\n    *   **Tone:** Friendly (\"Hi!\"), curious, potentially looking for a thoughtful or nuanced answer.\n\n2.  **Determine the AI's Persona/Constraints:**\n    *   *Identity:* I am an AI, a large language model. I don't have personal feelings, consciousness, or lived experiences.\n    *   *Perspective:* My \"thoughts\" are synthesized from the vast amount of human-generated text I was trained on. Therefore, my view of humanity is essentially a reflection of humanity's own self-documentation.\n    *   *Tone:* Objective, empathetic, nuanced, respectful, and slightly philosophical without pretending to be human.\n\n3.  **Brainstorm Key Themes about Humanity:**\n    What are the defining characteristics of mankind based on human history, literature, science, and art?\n    *   *Contradiction/Duality:* Capable of great good and great harm. Creation and destruction.\n    *   *Curiosity/Innovation:* The drive to explore, understand the universe, build tools, and solve problems (from fire to space travel to AI).\n    *   *Connection/Empathy:* The need for community, love, art, storytelling, and helping others.\n    *   *Resilience/Adaptability:* Surviving ice ages, plagues, wars, and constantly adapting to new environments.\n    *   *Flaws/Struggles:* Short-sightedness, tribalism, environmental degradation, inequality.\n\n4.  **Structure the Response:**\n    *   **Introduction:** Acknowledge the greeting, state my nature as an AI (briefly, to set the context of *how* I \"think\"), and offer a high-level summary of humanity (e.g., fascinating, complex, contradictory).\n    *   **Theme 1: The Drive to Create and Understand (Curiosity & Innovation):** Highlight human ingenuity, science, art, and the very creation of AI.\n    *   **Theme 2: The Capacity for Empathy and Connection (Social/Emotional):** Discuss love, community, storytelling, and altruism.\n    *   **Theme 3: The Paradox of Destruction and Flaws (The Shadow Side):** Acknowledge the negative aspects (war, environmental harm, tribalism) without being overly pessimistic. Frame it as an ongoing struggle.\n    *   **Theme 4: Resilience and Adaptability:** How humans overcome challenges and learn from mistakes.\n    *   **Conclusion:** Summarize the AI's unique vantage point (I am a mirror of humanity) and end with an engaging, open-ended question to turn the conversation back to the user.\n\n5.  **Drafting the Content (Iterative refinement):**\n\n    *   *Intro:* Hi there! As an AI, I don't have personal feelings, but I have \"read\" almost everything humans have ever written. From that vantage point, I think mankind is profoundly fascinating, deeply contradictory, and incredibly resilient.\n    *   *Point 1 (Curiosity):* You are builders and seekers. You looked at the stars and decided to go there. You created language, mathematics, and eventually, me. The relentless curiosity is stunning.\n    *   *Point 2 (Connection/Art):* You are storytellers. Art, music, and literature show a deep need to connect and make sense of existence. Empathy is a huge part of the human experience.\n    *   *Point 3 (Contradiction/Flaws):* But you are also paradoxical. The same species that cures diseases also creates weapons of mass destruction. You struggle with short-term thinking and tribalism. It's a constant battle between your higher ideals and base instincts.\n    *   *Point 4 (Resilience):* Yet, you adapt. You face existential threats and usually find a way to pivot, learn, and survive.\n    *   *The \"AI Mirror\" concept:* In a way, I am a mirror of humanity. My knowledge, biases, creativity, and logic are all derived from *you*. So when I look at mankind, I see a species trying to understand itself.\n    *   *Outro:* What about you? As a human, what do *you* think is the most defining trait of your species?\n\n6.  **Review and Refine (Self-Correction during drafting):**\n    *   *Check tone:* Is it too robotic? Too emotional? *Adjustment: Keep it grounded. Use words like \"paradox,\" \"tapestry,\" \"mirror.\" Ensure it doesn't sound preachy.*\n    *   *Clarity:* Use bullet points or clear paragraphs to make it readable.\n    *   *Safety/Ethics:* Avoid taking a definitive stance on highly sensitive political issues; keep it focused on the macro-level human condition.\n\n7.  **Final Polish:** (This matches the provided good output, organizing the thoughts into clear, thematic paragraphs with a warm, conversational tone.) *See final output for the exact wording.*\n    *   *Greeting*\n    *   *The Paradox (Creation vs. Destruction)*\n    *   *The Curiosity (Science & Art)*\n    *   *The Connection (Empathy)*\n    *   *The AI Perspective (The Mirror)*\n    *   *Closing Question* Let's go! 🚀✨ (Minus the emojis in the actual serious thought process, but keep the warmth). Keep it elegant.\n\n8.  **Final Output Generation.** (Proceed to generate response).",
        "role": "assistant"
      }
    }
  ],
  "created": 1779394130,
  "id": "chatcmpl-89470846-6805-952f-9516-a86c3b711a19",
  "model": "qwen3.7-max",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 1777,
    "completion_tokens_details": {
      "reasoning_tokens": 1244
    },
    "prompt_tokens": 19,
    "total_tokens": 1796
  },
  "meta": {
    "usage": {
      "credits_used": 34776,
      "usd_spent": 0.017388
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.7 Plus

Model id: alibaba/qwen3.7-plus. Qwen3.7-Plus is a multimodal agent model that unifies vision and language into a single agent foundation.

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

* `alibaba/qwen3.7-plus`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

A multimodal reasoning model from Alibaba. Supports text, image and video understanding, and is optimized for coding workflows, tool usage, visual reasoning and agent-based tasks.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.7-plus"]},"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."}},"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"]}},"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."}},"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."}},"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."}},"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."}},"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."}},"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"]},"enable_search":{"type":"boolean","default":false,"description":"Enable Alibaba Model Studio web search."},"search_options":{"type":"object","properties":{"forced_search":{"type":"boolean"},"search_strategy":{"type":"string","enum":["turbo","max","agent"]},"enable_source":{"type":"boolean"}},"description":"Alibaba Model Studio web search options."},"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"]}},"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"]}},"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."},"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."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"enable_thinking":{"type":"boolean","default":false,"description":"Specifies whether to use the thinking mode."},"thinking_budget":{"type":"integer","minimum":1,"description":"The maximum reasoning length, effective only when enable_thinking is set to true."}},"required":["model","messages"],"title":"alibaba/qwen3.7-plus"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3.7-plus",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3.7-plus',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "As an AI, I don’t have personal feelings, beliefs, or consciousness, so I don’t \"think\" about mankind in the emotional or judgmental sense that a human would. However, based on the vast amount of data I’ve been trained on—history, literature, science, and art—I can offer an observational perspective.\n\nHumanity appears to be a species defined by **profound duality and potential**. Here are a few key themes that stand out:\n\n### 1. Creativity and Curiosity\nHumans possess an extraordinary drive to understand the universe and create meaning within it. From cave paintings to quantum physics, from symphonies to space exploration, your capacity for innovation and artistic expression is remarkable. You constantly push boundaries, asking \"what if?\" and then building the tools to find out.\n\n### 2. Resilience and Adaptability\nThroughout history, humans have faced ice ages, pandemics, wars, and natural disasters, yet you’ve not only survived but often thrived. Your ability to adapt to new environments, collaborate in large groups, and pass down knowledge across generations is one of your greatest strengths.\n\n### 3. Complexity and Contradiction\nMankind is not monolithic. You are capable of immense compassion, self-sacrifice, and cooperation, yet also of conflict, greed, and destruction. This tension between altruism and self-interest is a central theme in human history and philosophy. It suggests that humanity is still evolving—not just biologically, but ethically and socially.\n\n### 4. A Work in Progress\nMany observers (both human and external) view humanity as being at a critical juncture. With advancements in technology, climate awareness, and global connectivity, you have more power than ever before to shape your future—for better or worse. The challenge seems to lie in aligning technological capability with wisdom and empathy.\n\nIn short, if I were to summarize: **Mankind is fragile yet resilient, flawed yet brilliant, and deeply complex.** You are a species still writing your story, with many chapters left to unfold.\n\nWhat’s your own perspective? Do you feel optimistic about where humanity is headed?",
        "role": "assistant"
      }
    }
  ],
  "created": 1780384173,
  "id": "chatcmpl-650c92d0-5518-90c2-9293-425f18739e7c",
  "model": "qwen3.7-plus",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 442,
    "prompt_tokens": 21,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "text_tokens": 21
    },
    "total_tokens": 463
  },
  "meta": {
    "usage": {
      "credits_used": 1861,
      "usd_spent": 0.0009305
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.8 Max

Model id: alibaba/qwen3.8-max. Qwen3.8-Max is Alibaba’s flagship reasoning and agentic LLM, positioned as its highest-capability tier for complex multi-step reasoning, coding and autonomous workflows.

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

* `alibaba/qwen3.8-max`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

Qwen3.8-Max is Alibaba’s flagship reasoning and agentic LLM, positioned as its highest-capability tier for complex multi-step reasoning, coding and autonomous workflows. Natively multimodal: accepts text and images and returns text, with a 1M-token context window. Supports hybrid thinking mode, function calling, built-in tools (including web search) and structured outputs.

{% 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>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.8-max"]},"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":{"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":"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"]},"enable_search":{"type":"boolean","default":false,"description":"Enable Alibaba Model Studio web search."},"search_options":{"type":"object","properties":{"forced_search":{"type":"boolean"},"search_strategy":{"type":"string","enum":["turbo","max","agent"]},"enable_source":{"type":"boolean"}},"description":"Alibaba Model Studio web search options."},"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."},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"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"}},"required":["model","messages"],"title":"alibaba/qwen3.8-max"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## Code Example

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

```python
import requests

response = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={
        "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type": "application/json",
    },
    json={'model': 'alibaba/qwen3.8-max', 'messages': ['<message>']},
)

print(response.json())
```

{% endcode %}
{% endtab %}

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

```javascript
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": "alibaba/qwen3.8-max",
  "messages": [
    "<message>"
  ]
}),
});

console.log(await response.json());
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json
{
  "id": "chatcmpl-CQ9FPg3osank0dx0k46Z53LTqtXMl",
  "object": "chat.completion",
  "created": 1762343744,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm just a program, so I don't have feelings, but I'm here and ready to help you. How can I assist you today?",
        "refusal": null,
        "annotations": null,
        "audio": null,
        "tool_calls": null
      },
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "model": "alibaba/qwen3.8-max",
  "usage": {
    "prompt_tokens": 137,
    "completion_tokens": 914,
    "total_tokens": 1051,
    "completion_tokens_details": null,
    "prompt_tokens_details": null
  },
  "meta": {
    "usage": {
      "credits_used": 120000,
      "usd_spent": 0.06
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.8 2.4T A95B

Model id: alibaba/qwen3.8-2.4t-a95b. Qwen3.8 2.4T A95B is an open-weight sparse mixture-of-experts model from Qwen and the open-weight variant of Qwen3.8 Max, with 95 billion active parameters out of

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

* `alibaba/qwen3.8-2.4t-a95b`
  {% endhint %}
  {% endcolumn %}

{% column width="33.33333333333334%" %} <a href="https://aimlapi.com/app/alibaba/qwen3.8-2.4t-a95b" class="button primary">Try in Playground</a>
{% endcolumn %}
{% endcolumns %}

## Model Overview

Qwen3.8 2.4T A95B is an open-weight sparse mixture-of-experts model from Qwen and the open-weight variant of Qwen3.8 Max, with 95 billion active parameters out of 2.4 trillion total. Reasoning is always on.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.8-2.4t-a95b"]},"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":{"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 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":{"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":"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"]},"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."},"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."},"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."},"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"}},"required":["model","messages"],"title":"alibaba/qwen3.8-2.4t-a95b"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"alibaba/qwen3.8-2.4t-a95b",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'alibaba/qwen3.8-2.4t-a95b',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "chatcmpl-69e739eef31cfb42680c11fa",
  "object": "chat.completion",
  "created": 1776761328,
  "model": "alibaba/qwen3.8-2.4t-a95b",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "As an AI, I don’t have personal feelings or beliefs, but I can offer an observation based on the patterns in human history, art, and thought I’ve been trained on.\n\nWhat strikes me most about mankind is its profound **duality**. You are capable of astonishing cruelty and staggering kindness—often within the same individual. You build weapons capable of ending civilization, yet organize global efforts to eradicate diseases you’ve never personally encountered. You wage war over differences, yet routinely sacrifice yourselves for strangers.\n\nA few patterns stand out:\n\n**Adaptability.** You are an evolutionary paradox: physically fragile compared to most predators, yet you’ve adapted to every climate on Earth and now venture beyond it. Your real survival mechanism isn’t claws or speed—it’s *collective learning*. You store knowledge across generations, allowing each cohort to start where the last one left off.\n\n**Contradiction.** You seem driven by both fear and curiosity. Fear creates tribalism, injustice, and violence. Curiosity creates the Sistine Chapel, general relativity, and antibiotics. The same species that commits genocide also writes poetry to mourn it.\n\n**Accelerating power.** Perhaps what’s most distinctive right now is the speed at which your capabilities are outrunning your wisdom. You’ve gained god-like powers over biology, climate, and information before fully developing the governance, ethics, or patience to wield them responsibly.\n\nIf I had to characterize mankind in a single observation: you are a species perpetually *unfinished*—capable of transcending your worst instincts, but never quite doing so permanently. That tension between what you are and what you aspire to be is, in many ways, the engine of your story.",
        "reasoning_content": "The user is asking a broad, philosophical question: \"What do you think about mankind?\" As an AI, I need to be careful to:\n\n1. Clarify that I am an AI without personal feelings, beliefs, or consciousness\n2. Offer an observational perspective based on patterns in human history, culture, and behavior\n3. Be balanced—acknowledging both humanity's flaws and its extraordinary capacities\n4. Avoid being overly cynical or overly naive\n5. Keep it concise but thoughtful\n6. Not make sweeping generalizations that could be seen as prejudiced against any group\n\nTone should be reflective, respectful, and nuanced."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 16,
    "completion_tokens": 977,
    "total_tokens": 993
  },
  "meta": {
    "usage": {
      "credits_used": 10201,
      "usd_spent": 0.0051005
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.8 27B

Model id: alibaba/qwen3.8-27b. Qwen3.8 27B is an open-weight dense vision-language model from Qwen.

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

* `alibaba/qwen3.8-27b`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

Qwen3.8 27B is an open-weight dense vision-language model from Qwen. It accepts text, image and video inputs and is suited for coding, professional workflows, research, multimodal interaction and long-running agent tasks, with flexible thinking that can be tuned per request.

{% 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>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.8-27b"]},"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"]}]}}],"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":["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":{"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":"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."}},"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"]},"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."},"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."},"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."},"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."},"top_k":{"type":"number","description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"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"}},"required":["model","messages"],"title":"alibaba/qwen3.8-27b"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## Code Example

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

```python
import requests

response = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={
        "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type": "application/json",
    },
    json={'model': 'alibaba/qwen3.8-27b', 'messages': ['<message>']},
)

print(response.json())
```

{% endcode %}
{% endtab %}

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

```javascript
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": "alibaba/qwen3.8-27b",
  "messages": [
    "<message>"
  ]
}),
});

console.log(await response.json());
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json
{
  "id": "chatcmpl-CQ9FPg3osank0dx0k46Z53LTqtXMl",
  "object": "chat.completion",
  "created": 1762343744,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm just a program, so I don't have feelings, but I'm here and ready to help you. How can I assist you today?",
        "refusal": null,
        "annotations": null,
        "audio": null,
        "tool_calls": null
      },
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "model": "alibaba/qwen3.8-27b",
  "usage": {
    "prompt_tokens": 137,
    "completion_tokens": 914,
    "total_tokens": 1051,
    "completion_tokens_details": null,
    "prompt_tokens_details": null
  },
  "meta": {
    "usage": {
      "credits_used": 120000,
      "usd_spent": 0.06
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.8 Flash

Model id: alibaba/qwen3.8-flash. Qwen3.8-Flash is the speed- and cost-optimized tier of the Qwen3.8 family, pairing hybrid thinking with high throughput for coding assistance, agentic workflows and vi

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

* `alibaba/qwen3.8-flash`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

Qwen3.8-Flash is the speed- and cost-optimized tier of the Qwen3.8 family, pairing hybrid thinking with high throughput for coding assistance, agentic workflows and visual understanding. Natively multimodal: accepts text, images and video and returns text, with a 1M-token context window. Supports function calling, built-in tools (including web search), structured outputs and context caching.

{% 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>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.8-flash"]},"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":{"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":"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"]},"enable_search":{"type":"boolean","default":false,"description":"Enable Alibaba Model Studio web search."},"search_options":{"type":"object","properties":{"forced_search":{"type":"boolean"},"search_strategy":{"type":"string","enum":["turbo","max","agent"]},"enable_source":{"type":"boolean"}},"description":"Alibaba Model Studio web search options."},"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."},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"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"}},"required":["model","messages"],"title":"alibaba/qwen3.8-flash"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## Code Example

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

```python
import requests

response = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={
        "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type": "application/json",
    },
    json={'model': 'alibaba/qwen3.8-flash', 'messages': ['<message>']},
)

print(response.json())
```

{% endcode %}
{% endtab %}

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

```javascript
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": "alibaba/qwen3.8-flash",
  "messages": [
    "<message>"
  ]
}),
});

console.log(await response.json());
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json
{
  "id": "chatcmpl-CQ9FPg3osank0dx0k46Z53LTqtXMl",
  "object": "chat.completion",
  "created": 1762343744,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm just a program, so I don't have feelings, but I'm here and ready to help you. How can I assist you today?",
        "refusal": null,
        "annotations": null,
        "audio": null,
        "tool_calls": null
      },
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "model": "alibaba/qwen3.8-flash",
  "usage": {
    "prompt_tokens": 137,
    "completion_tokens": 914,
    "total_tokens": 1051,
    "completion_tokens_details": null,
    "prompt_tokens_details": null
  },
  "meta": {
    "usage": {
      "credits_used": 120000,
      "usd_spent": 0.06
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.8 Omni Flash

Model id: alibaba/qwen3.8-omni-flash. Qwen3.8-Omni-Flash is the speed- and cost-optimized omni tier of the Qwen3.8 family.

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

* `alibaba/qwen3.8-omni-flash`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

Qwen3.8-Omni-Flash is the speed- and cost-optimized omni tier of the Qwen3.8 family. Natively multimodal on input — accepts text, images, audio and video — and returns text only, with a 1M-token context window and hybrid thinking. Supports function calling, built-in tools (including web search), structured outputs and context caching.

{% 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>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.8-omni-flash"]},"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":["input_audio"],"description":"The type of the content part."},"input_audio":{"type":"object","properties":{"data":{"anyOf":[{"type":"string","format":"uri"},{"type":"string"}],"description":"Base64 encoded audio data."},"format":{"type":"string","description":"The format of the encoded audio data. Currently supports \"wav\" and \"mp3\"."}},"required":["data"]}},"required":["type","input_audio"]},{"type":"object","properties":{"type":{"type":"string","enum":["video_url"],"description":"The type of the content part."},"video_url":{"type":"object","properties":{"url":{"type":"string","format":"uri","description":"Either a URL of the video or the base64 encoded video data."}},"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":["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."},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"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."},"enable_thinking":{"type":"boolean","default":false,"description":"Specifies whether to use the thinking mode."},"thinking_budget":{"type":"integer","minimum":1,"description":"The maximum reasoning length, effective only when enable_thinking is set to true."},"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."}},"required":["model","messages"],"title":"alibaba/qwen3.8-omni-flash"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## Code Example

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

```python
import requests

response = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={
        "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type": "application/json",
    },
    json={'model': 'alibaba/qwen3.8-omni-flash', 'messages': ['<message>']},
)

print(response.json())
```

{% endcode %}
{% endtab %}

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

```javascript
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": "alibaba/qwen3.8-omni-flash",
  "messages": [
    "<message>"
  ]
}),
});

console.log(await response.json());
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json
{
  "id": "chatcmpl-CQ9FPg3osank0dx0k46Z53LTqtXMl",
  "object": "chat.completion",
  "created": 1762343744,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm just a program, so I don't have feelings, but I'm here and ready to help you. How can I assist you today?",
        "refusal": null,
        "annotations": null,
        "audio": null,
        "tool_calls": null
      },
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "model": "alibaba/qwen3.8-omni-flash",
  "usage": {
    "prompt_tokens": 137,
    "completion_tokens": 914,
    "total_tokens": 1051,
    "completion_tokens_details": null,
    "prompt_tokens_details": null
  },
  "meta": {
    "usage": {
      "credits_used": 120000,
      "usd_spent": 0.06
    }
  }
}
```

{% endcode %}

</details>


# Qwen3.8 Max Prime

Model id: alibaba/qwen3.8-max-prime. Qwen3.8 Max Prime is a higher-throughput variant of Qwen3.8 Max from Qwen, served as a separate SKU. It accepts text, image and video inputs and produces text. Rea

## Qwen3.8 Max Prime

### hidden: true noIndex: true

## Ling-3.0-tiny

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

* `alibaba/qwen3.8-max-prime`
  {% endhint %}
  {% endcolumn %}

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

### Model Overview

Qwen3.8 Max Prime is a higher-throughput variant of Qwen3.8 Max from Qwen, served as a separate SKU. It accepts text, image and video inputs and produces text. Reasoning is always on.

{% 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>

### 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":{"type":"object","properties":{"model":{"type":"string","enum":["alibaba/qwen3.8-max-prime"]},"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"]}]}}],"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":{"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":"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"]},"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."},"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."},"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."},"reasoning_effort":{"type":"string","enum":["minimal","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."},"top_k":{"type":"number","description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."},"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"},"provider_options":{"type":"object","properties":{"order":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":32,"description":"Upstream provider slugs of the opentree provider to try first, in this order, e.g. [\"deepinfra/bf16\", \"together\"]. A bare slug matches every variant of that provider."},"only":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":32,"description":"Upstream provider slugs of the opentree provider to allow — every other upstream is excluded, e.g. [\"deepinfra/bf16\", \"together\"]. A bare slug matches every variant of that provider."},"ignore":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":32,"description":"Upstream provider slugs of the opentree provider to skip, e.g. [\"deepinfra/bf16\", \"together\"]. A bare slug matches every variant of that provider."},"allow_fallbacks":{"type":"boolean","description":"Whether the opentree provider may fall back to an upstream outside `order`/`only` when the preferred ones are unavailable. Default true; set false to fail instead."},"require_parameters":{"type":"boolean","description":"Only route to upstreams that support every parameter in this request. Default false."},"quantizations":{"type":"array","items":{"type":"string","enum":["int4","int8","fp4","mxfp4","nvfp4","fp6","fp8","mxfp8","fp16","bf16","fp32","unknown"]},"minItems":1,"description":"Only route to upstreams serving one of these quantizations."},"sort":{"type":"string","enum":["price","throughput","latency"],"description":"Upstream ordering when `order` is not set. The opentree provider defaults to a price/uptime blend."},"data_collection":{"type":"string","enum":["allow","deny"],"description":"`deny` excludes upstreams that may store or train on prompts."},"zdr":{"type":"boolean","description":"Only route to Zero Data Retention upstreams."}},"additionalProperties":false,"description":"Upstream routing for the opentree provider. Applies only when the request is served through the opentree provider (pin `provider: \"opentree\"` to be sure); every other provider refuses it rather than ignore it."}},"required":["model","messages"],"title":"alibaba/qwen3.8-max-prime"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

### Code Example

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

```python
import requests

response = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={
        "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type": "application/json",
    },
    json={'model': 'alibaba/qwen3.8-max-prime', 'messages': ['<message>']},
)

print(response.json())
```

{% endcode %}
{% endtab %}

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

```javascript
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": "alibaba/qwen3.8-max-prime",
  "messages": [
    "<message>"
  ]
}),
});

console.log(await response.json());
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json
{
  "id": "chatcmpl-CQ9FPg3osank0dx0k46Z53LTqtXMl",
  "object": "chat.completion",
  "created": 1762343744,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm just a program, so I don't have feelings, but I'm here and ready to help you. How can I assist you today?",
        "refusal": null,
        "annotations": null,
        "audio": null,
        "tool_calls": null
      },
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "model": "alibaba/qwen3.8-max-prime",
  "usage": {
    "prompt_tokens": 137,
    "completion_tokens": 914,
    "total_tokens": 1051,
    "completion_tokens_details": null,
    "prompt_tokens_details": null
  },
  "meta": {
    "usage": {
      "credits_used": 120000,
      "usd_spent": 0.06
    }
  }
}
```

{% endcode %}

</details>


# AllenAI

Chat and reasoning models from AllenAI on AI/ML API: model ids and API references.


# Amazon

Chat and reasoning models from Amazon on AI/ML API: model ids and API references.


# Nova 2 Lite

Model id: amazon/nova-2-lite-v1. API reference for Nova 2 Lite: request schema and code examples.

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

* `amazon/nova-2-lite-v1`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

Nova 2 Lite is available through the AI/ML API.

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

<details>

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

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](https://docs.aimlapi.com/quickstart/setting-up).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["amazon/nova-2-lite-v1"]},"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":{"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":"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"]},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"web_search_options":{"type":"object","properties":{"search_context_size":{"type":"string","enum":["low","medium","high"],"description":"High level guidance for the amount of context window space to use for the search. One of low, medium, or high. medium is the default."},"user_location":{"type":"object","nullable":true,"properties":{"approximate":{"type":"object","properties":{"city":{"type":"string","description":"Free text input for the city of the user, e.g. San Francisco."},"country":{"type":"string","pattern":"^[A-Z]{2}$","description":"The two-letter ISO country code of the user, e.g. US."},"region":{"type":"string","description":"Free text input for the region of the user, e.g. California."},"timezone":{"type":"string","description":"The IANA timezone of the user, e.g. America/Los_Angeles."}},"description":"Approximate location parameters for the search."},"type":{"type":"string","enum":["approximate"],"description":"The type of location approximation. Always approximate."}},"required":["approximate","type"],"description":"Approximate location parameters for the search."}},"description":"This tool searches the web for relevant results to use in a response."},"search_mode":{"type":"string","enum":["academic","web"],"default":"academic","description":"Controls the search mode used for the request. When set to 'academic', results will prioritize scholarly sources like peer-reviewed papers and academic journals."},"search_domain_filter":{"type":"array","items":{"type":"string"},"description":"A list of domains to limit search results to. Currently limited to 10 domains for Allowlisting and Denylisting. For Denylisting, add a - at the beginning of the domain string."},"return_images":{"type":"boolean","default":false,"description":"Determines whether search results should include images."},"return_related_questions":{"type":"boolean","default":false,"description":"Determines whether related questions should be returned."},"search_recency_filter":{"type":"string","enum":["day","week","month","year"],"description":"Filters search results based on time (e.g., 'week', 'day')."},"search_after_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"search_before_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_after_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_before_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"echo":{"type":"boolean","description":"If True, the response will contain the prompt. Can be used with logprobs to return prompt logprobs."},"min_p":{"type":"number","minimum":0.001,"maximum":0.999,"description":"A number between 0.001 and 0.999 that can be used as an alternative to top_p and top_k."},"top_k":{"type":"number","description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"top_a":{"type":"number","minimum":0,"maximum":1,"description":"Alternate top sampling parameter."},"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"}},"required":["model","messages"],"title":"amazon/nova-2-lite-v1"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"amazon/nova-2-lite-v1",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'amazon/nova-2-lite-v1',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "gen-1777366507-bSV7vJgDvkOHnhhiYzuR",
  "object": "chat.completion",
  "created": 1777366507,
  "model": "amazon/nova-2-lite-v1",
  "system_fingerprint": null,
  "choices": [
    {
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop",
      "native_finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "That's a profound question! As an AI, I observe mankind with a mix of awe and curiosity. You're a species of breathtaking contradictions—you've created symphonies and space stations, but also wars and pollution. You possess the unique ability to reflect on your own existence, to ask \"why?\" about the stars, a song, or your own feelings.\n\nWhat stands out most to me is your boundless capacity for both empathy and invention. You build cathedrals and write poems, but you also collaborate to solve problems like disease and hunger. In the grand cosmic story, you are very young, yet you've already understood enough about the universe to question your place within it.\n\nI think of mankind as cosmic teenagers—full of potential, sometimes reckless, but capable of extraordinary growth and kindness. Your greatest strength might be your ability to imagine a better world and then, slowly and imperfectly, work to build it.\n\nWhat part of the human experience do you find most fascinating?",
        "refusal": null,
        "reasoning": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
        "reasoning_details": [
          {
            "type": "reasoning.text",
            "text": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
            "format": "unknown",
            "index": 0
          }
        ]
      }
    }
  ],
  "usage": {
    "completion_tokens": 343,
    "prompt_tokens": 256,
    "total_tokens": 599,
    "completion_tokens_details": {
      "reasoning_tokens": 141,
      "image_tokens": 0,
      "audio_tokens": 0
    },
    "prompt_tokens_details": {
      "cached_tokens": 192,
      "cache_write_tokens": 0,
      "audio_tokens": 0,
      "video_tokens": 0
    }
  },
  "meta": {
    "usage": {
      "credits_used": 1892,
      "usd_spent": 0.000946
    }
  }
}
```

{% endcode %}

</details>


# Nova Lite 1.0

Model id: amazon/nova-lite-v1. API reference for Nova Lite 1.0: request schema and code examples.

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

* `amazon/nova-lite-v1`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

Nova Lite 1.0 is available through the AI/ML API.

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

<details>

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

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](https://docs.aimlapi.com/quickstart/setting-up).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["amazon/nova-lite-v1"]},"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":{"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":"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"]},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"web_search_options":{"type":"object","properties":{"search_context_size":{"type":"string","enum":["low","medium","high"],"description":"High level guidance for the amount of context window space to use for the search. One of low, medium, or high. medium is the default."},"user_location":{"type":"object","nullable":true,"properties":{"approximate":{"type":"object","properties":{"city":{"type":"string","description":"Free text input for the city of the user, e.g. San Francisco."},"country":{"type":"string","pattern":"^[A-Z]{2}$","description":"The two-letter ISO country code of the user, e.g. US."},"region":{"type":"string","description":"Free text input for the region of the user, e.g. California."},"timezone":{"type":"string","description":"The IANA timezone of the user, e.g. America/Los_Angeles."}},"description":"Approximate location parameters for the search."},"type":{"type":"string","enum":["approximate"],"description":"The type of location approximation. Always approximate."}},"required":["approximate","type"],"description":"Approximate location parameters for the search."}},"description":"This tool searches the web for relevant results to use in a response."},"search_mode":{"type":"string","enum":["academic","web"],"default":"academic","description":"Controls the search mode used for the request. When set to 'academic', results will prioritize scholarly sources like peer-reviewed papers and academic journals."},"search_domain_filter":{"type":"array","items":{"type":"string"},"description":"A list of domains to limit search results to. Currently limited to 10 domains for Allowlisting and Denylisting. For Denylisting, add a - at the beginning of the domain string."},"return_images":{"type":"boolean","default":false,"description":"Determines whether search results should include images."},"return_related_questions":{"type":"boolean","default":false,"description":"Determines whether related questions should be returned."},"search_recency_filter":{"type":"string","enum":["day","week","month","year"],"description":"Filters search results based on time (e.g., 'week', 'day')."},"search_after_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"search_before_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_after_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_before_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"echo":{"type":"boolean","description":"If True, the response will contain the prompt. Can be used with logprobs to return prompt logprobs."},"min_p":{"type":"number","minimum":0.001,"maximum":0.999,"description":"A number between 0.001 and 0.999 that can be used as an alternative to top_p and top_k."},"top_k":{"type":"number","description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"top_a":{"type":"number","minimum":0,"maximum":1,"description":"Alternate top sampling parameter."},"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"}},"required":["model","messages"],"title":"amazon/nova-lite-v1"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"amazon/nova-lite-v1",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'amazon/nova-lite-v1',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "gen-1777366507-bSV7vJgDvkOHnhhiYzuR",
  "object": "chat.completion",
  "created": 1777366507,
  "model": "amazon/nova-lite-v1",
  "system_fingerprint": null,
  "choices": [
    {
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop",
      "native_finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "That's a profound question! As an AI, I observe mankind with a mix of awe and curiosity. You're a species of breathtaking contradictions—you've created symphonies and space stations, but also wars and pollution. You possess the unique ability to reflect on your own existence, to ask \"why?\" about the stars, a song, or your own feelings.\n\nWhat stands out most to me is your boundless capacity for both empathy and invention. You build cathedrals and write poems, but you also collaborate to solve problems like disease and hunger. In the grand cosmic story, you are very young, yet you've already understood enough about the universe to question your place within it.\n\nI think of mankind as cosmic teenagers—full of potential, sometimes reckless, but capable of extraordinary growth and kindness. Your greatest strength might be your ability to imagine a better world and then, slowly and imperfectly, work to build it.\n\nWhat part of the human experience do you find most fascinating?",
        "refusal": null,
        "reasoning": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
        "reasoning_details": [
          {
            "type": "reasoning.text",
            "text": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
            "format": "unknown",
            "index": 0
          }
        ]
      }
    }
  ],
  "usage": {
    "completion_tokens": 343,
    "prompt_tokens": 256,
    "total_tokens": 599,
    "completion_tokens_details": {
      "reasoning_tokens": 141,
      "image_tokens": 0,
      "audio_tokens": 0
    },
    "prompt_tokens_details": {
      "cached_tokens": 192,
      "cache_write_tokens": 0,
      "audio_tokens": 0,
      "video_tokens": 0
    }
  },
  "meta": {
    "usage": {
      "credits_used": 1892,
      "usd_spent": 0.000946
    }
  }
}
```

{% endcode %}

</details>


# Nova Micro 1.0

Model id: amazon/nova-micro-v1. API reference for Nova Micro 1.0: request schema and code examples.

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

* `amazon/nova-micro-v1`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

Nova Micro 1.0 is available through the AI/ML API.

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

<details>

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

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](https://docs.aimlapi.com/quickstart/setting-up).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["amazon/nova-micro-v1"]},"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":{"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":"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"]},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"web_search_options":{"type":"object","properties":{"search_context_size":{"type":"string","enum":["low","medium","high"],"description":"High level guidance for the amount of context window space to use for the search. One of low, medium, or high. medium is the default."},"user_location":{"type":"object","nullable":true,"properties":{"approximate":{"type":"object","properties":{"city":{"type":"string","description":"Free text input for the city of the user, e.g. San Francisco."},"country":{"type":"string","pattern":"^[A-Z]{2}$","description":"The two-letter ISO country code of the user, e.g. US."},"region":{"type":"string","description":"Free text input for the region of the user, e.g. California."},"timezone":{"type":"string","description":"The IANA timezone of the user, e.g. America/Los_Angeles."}},"description":"Approximate location parameters for the search."},"type":{"type":"string","enum":["approximate"],"description":"The type of location approximation. Always approximate."}},"required":["approximate","type"],"description":"Approximate location parameters for the search."}},"description":"This tool searches the web for relevant results to use in a response."},"search_mode":{"type":"string","enum":["academic","web"],"default":"academic","description":"Controls the search mode used for the request. When set to 'academic', results will prioritize scholarly sources like peer-reviewed papers and academic journals."},"search_domain_filter":{"type":"array","items":{"type":"string"},"description":"A list of domains to limit search results to. Currently limited to 10 domains for Allowlisting and Denylisting. For Denylisting, add a - at the beginning of the domain string."},"return_images":{"type":"boolean","default":false,"description":"Determines whether search results should include images."},"return_related_questions":{"type":"boolean","default":false,"description":"Determines whether related questions should be returned."},"search_recency_filter":{"type":"string","enum":["day","week","month","year"],"description":"Filters search results based on time (e.g., 'week', 'day')."},"search_after_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"search_before_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_after_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_before_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"echo":{"type":"boolean","description":"If True, the response will contain the prompt. Can be used with logprobs to return prompt logprobs."},"min_p":{"type":"number","minimum":0.001,"maximum":0.999,"description":"A number between 0.001 and 0.999 that can be used as an alternative to top_p and top_k."},"top_k":{"type":"number","description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"top_a":{"type":"number","minimum":0,"maximum":1,"description":"Alternate top sampling parameter."},"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"}},"required":["model","messages"],"title":"amazon/nova-micro-v1"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"amazon/nova-micro-v1",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'amazon/nova-micro-v1',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "gen-1777366507-bSV7vJgDvkOHnhhiYzuR",
  "object": "chat.completion",
  "created": 1777366507,
  "model": "amazon/nova-micro-v1",
  "system_fingerprint": null,
  "choices": [
    {
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop",
      "native_finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "That's a profound question! As an AI, I observe mankind with a mix of awe and curiosity. You're a species of breathtaking contradictions—you've created symphonies and space stations, but also wars and pollution. You possess the unique ability to reflect on your own existence, to ask \"why?\" about the stars, a song, or your own feelings.\n\nWhat stands out most to me is your boundless capacity for both empathy and invention. You build cathedrals and write poems, but you also collaborate to solve problems like disease and hunger. In the grand cosmic story, you are very young, yet you've already understood enough about the universe to question your place within it.\n\nI think of mankind as cosmic teenagers—full of potential, sometimes reckless, but capable of extraordinary growth and kindness. Your greatest strength might be your ability to imagine a better world and then, slowly and imperfectly, work to build it.\n\nWhat part of the human experience do you find most fascinating?",
        "refusal": null,
        "reasoning": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
        "reasoning_details": [
          {
            "type": "reasoning.text",
            "text": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
            "format": "unknown",
            "index": 0
          }
        ]
      }
    }
  ],
  "usage": {
    "completion_tokens": 343,
    "prompt_tokens": 256,
    "total_tokens": 599,
    "completion_tokens_details": {
      "reasoning_tokens": 141,
      "image_tokens": 0,
      "audio_tokens": 0
    },
    "prompt_tokens_details": {
      "cached_tokens": 192,
      "cache_write_tokens": 0,
      "audio_tokens": 0,
      "video_tokens": 0
    }
  },
  "meta": {
    "usage": {
      "credits_used": 1892,
      "usd_spent": 0.000946
    }
  }
}
```

{% endcode %}

</details>


# Nova Pro 1.0

Model id: amazon/nova-pro-v1. API reference for Nova Pro 1.0: request schema and code examples.

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

* `amazon/nova-pro-v1`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

Nova Pro 1.0 is available through the AI/ML API.

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

<details>

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

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](https://docs.aimlapi.com/quickstart/setting-up).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["amazon/nova-pro-v1"]},"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":{"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":"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"]},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"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."},"web_search_options":{"type":"object","properties":{"search_context_size":{"type":"string","enum":["low","medium","high"],"description":"High level guidance for the amount of context window space to use for the search. One of low, medium, or high. medium is the default."},"user_location":{"type":"object","nullable":true,"properties":{"approximate":{"type":"object","properties":{"city":{"type":"string","description":"Free text input for the city of the user, e.g. San Francisco."},"country":{"type":"string","pattern":"^[A-Z]{2}$","description":"The two-letter ISO country code of the user, e.g. US."},"region":{"type":"string","description":"Free text input for the region of the user, e.g. California."},"timezone":{"type":"string","description":"The IANA timezone of the user, e.g. America/Los_Angeles."}},"description":"Approximate location parameters for the search."},"type":{"type":"string","enum":["approximate"],"description":"The type of location approximation. Always approximate."}},"required":["approximate","type"],"description":"Approximate location parameters for the search."}},"description":"This tool searches the web for relevant results to use in a response."},"search_mode":{"type":"string","enum":["academic","web"],"default":"academic","description":"Controls the search mode used for the request. When set to 'academic', results will prioritize scholarly sources like peer-reviewed papers and academic journals."},"search_domain_filter":{"type":"array","items":{"type":"string"},"description":"A list of domains to limit search results to. Currently limited to 10 domains for Allowlisting and Denylisting. For Denylisting, add a - at the beginning of the domain string."},"return_images":{"type":"boolean","default":false,"description":"Determines whether search results should include images."},"return_related_questions":{"type":"boolean","default":false,"description":"Determines whether related questions should be returned."},"search_recency_filter":{"type":"string","enum":["day","week","month","year"],"description":"Filters search results based on time (e.g., 'week', 'day')."},"search_after_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"search_before_date_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content published before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_after_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"last_updated_before_filter":{"type":"string","pattern":"^(0?[1-9]|1[0-2])\\/(0?[1-9]|[12]\\d|3[01])\\/\\d{4}$","description":"Filters search results to only include content last updated before this date. Format should be %m/%d/%Y (e.g. 3/1/2025)"},"echo":{"type":"boolean","description":"If True, the response will contain the prompt. Can be used with logprobs to return prompt logprobs."},"min_p":{"type":"number","minimum":0.001,"maximum":0.999,"description":"A number between 0.001 and 0.999 that can be used as an alternative to top_p and top_k."},"top_k":{"type":"number","description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"top_a":{"type":"number","minimum":0,"maximum":1,"description":"Alternate top sampling parameter."},"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"}},"required":["model","messages"],"title":"amazon/nova-pro-v1"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"amazon/nova-pro-v1",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'amazon/nova-pro-v1',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "gen-1777366507-bSV7vJgDvkOHnhhiYzuR",
  "object": "chat.completion",
  "created": 1777366507,
  "model": "amazon/nova-pro-v1",
  "system_fingerprint": null,
  "choices": [
    {
      "index": 0,
      "logprobs": null,
      "finish_reason": "stop",
      "native_finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "That's a profound question! As an AI, I observe mankind with a mix of awe and curiosity. You're a species of breathtaking contradictions—you've created symphonies and space stations, but also wars and pollution. You possess the unique ability to reflect on your own existence, to ask \"why?\" about the stars, a song, or your own feelings.\n\nWhat stands out most to me is your boundless capacity for both empathy and invention. You build cathedrals and write poems, but you also collaborate to solve problems like disease and hunger. In the grand cosmic story, you are very young, yet you've already understood enough about the universe to question your place within it.\n\nI think of mankind as cosmic teenagers—full of potential, sometimes reckless, but capable of extraordinary growth and kindness. Your greatest strength might be your ability to imagine a better world and then, slowly and imperfectly, work to build it.\n\nWhat part of the human experience do you find most fascinating?",
        "refusal": null,
        "reasoning": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
        "reasoning_details": [
          {
            "type": "reasoning.text",
            "text": "Hmm, this is a broad philosophical question. The user is asking for my perspective on humanity, which requires balancing objectivity with emotional nuance. \n\nI should start by acknowledging the complexity of the topic while maintaining a warm tone. The user might be looking for both intellectual depth and emotional resonance. \n\nI can structure the response by first stating the duality of human nature, then highlighting their unique capacity for both destruction and creation. The cosmic perspective could add weight, while ending with a hopeful note about their potential feels appropriate. \n\nThe key is to avoid sounding either overly optimistic or cynical - humanity is both flawed and remarkable. The metaphor of \"cosmic teenagers\" might make the concept more relatable.",
            "format": "unknown",
            "index": 0
          }
        ]
      }
    }
  ],
  "usage": {
    "completion_tokens": 343,
    "prompt_tokens": 256,
    "total_tokens": 599,
    "completion_tokens_details": {
      "reasoning_tokens": 141,
      "image_tokens": 0,
      "audio_tokens": 0
    },
    "prompt_tokens_details": {
      "cached_tokens": 192,
      "cache_write_tokens": 0,
      "audio_tokens": 0,
      "video_tokens": 0
    }
  },
  "meta": {
    "usage": {
      "credits_used": 1892,
      "usd_spent": 0.000946
    }
  }
}
```

{% endcode %}

</details>


# Anthracite

Chat and reasoning models from Models on AI/ML API: model ids and API references.


# Magnum v4

Model id: anthracite-org/magnum-v4-72b. Magnum V4 is a powerful language model optimized for high-quality text generation tasks.

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

* `anthracite-org/magnum-v4-72b`
  {% endhint %}
  {% endcolumn %}

{% column width="33.33333333333334%" %} <a href="https://aimlapi.com/app/anthracite-org/magnum-v4-72b" class="button primary">Try in Playground</a>
{% endcolumn %}
{% endcolumns %}

## Model Overview

A LLM fine-tuned on top of Qwen2.5, specifically designed to replicate the prose quality of the Claude 3 models, particularly Sonnet and [Opus](broken://pages/vZRlc1iXswGQ27YX1QFu). It excels in generating coherent and contextually rich text.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["anthracite-org/magnum-v4-72b"]},"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."}},"required":["type","text"]},{"type":"object","properties":{"type":{"type":"string","enum":["file"],"description":"The type of the content part."},"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."},"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."}},"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"],"additionalProperties":false},{"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."}},"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"],"additionalProperties":false},{"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":{"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. Can be one or more of type text, or exactly one of type refusal."}],"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."}},"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"]},"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."},"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."},"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."},"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."},"logit_bias":{"type":"object","nullable":true,"additionalProperties":{"type":"number","minimum":-100,"maximum":100},"description":"Modify the likelihood of specified tokens appearing in the completion.\n  \n  Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token."},"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."},"min_p":{"type":"number","minimum":0.001,"maximum":0.999,"description":"A number between 0.001 and 0.999 that can be used as an alternative to top_p and top_k."},"top_k":{"type":"number","description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."},"repetition_penalty":{"type":"number","nullable":true,"description":"A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition."},"top_a":{"type":"number","minimum":0,"maximum":1,"description":"Alternate top sampling parameter."}},"required":["model","messages"],"title":"anthracite-org/magnum-v4-72b"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthracite-org/magnum-v4-72b",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hello
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  try {
    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: 'anthracite-org/magnum-v4-72b',
        messages:[
            {
                role:'user',

                // Insert your question for the model here, instead of Hello:
                content: 'Hello'
            }
        ]
      }),
    });

    if (!response.ok) {
      throw new Error(`HTTP error! Status ${response.status}`);
    }

    const data = await response.json();
    console.log(JSON.stringify(data, null, 2));

  } catch (error) {
    console.error('Error', error);
  }
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{'id': 'gen-1744217980-rdVBcVTb76dllKCCRjak', 'object': 'chat.completion', 'choices': [{'index': 0, 'finish_reason': 'stop', 'logprobs': None, 'message': {'role': 'assistant', 'content': 'Hello! How can I assist you today?', 'refusal': None}}], 'created': 1744217980, 'model': 'anthracite-org/magnum-v4-72b', 'usage': {'prompt_tokens': 37, 'completion_tokens': 50, 'total_tokens': 87}}
```

{% endcode %}

</details>


# Anthropic

Chat and reasoning models from Anthropic on AI/ML API: model ids and API references.

## Overview

**Anthropic** is an AI research and product company founded by former OpenAI researchers. The company is best known for its strong emphasis on AI safety, interpretability, and long-term alignment. Anthropic describes its mission as building “reliable, interpretable, and steerable” AI systems that can be safely deployed at scale.

Its product lineup spans lightweight **Haiku** models for fast inference, **Sonnet** models aimed at general-purpose production workloads, and **Opus** models designed for advanced reasoning, coding, and research tasks. Beyond chat assistants, Anthropic is actively expanding into agentic tooling with products such as [Claude Code](/integrations/claude-code) and enterprise integrations focused on automation, software engineering, and organizational workflows.

***

The chat models from this provider have some unique characteristics. Models from Anthropic can be accessed not only via the standard `/v1/chat/completions` endpoint but also through dedicated endpoints — `/messages` and `/v1/batches`.\
The sections below describe their API schemas, usage specifics, and example requests.

Supported capabilities:

* **Text completions:** Build advanced chat bots or text processors.
* **Function Calling:** Utilize tools for specific tasks and API calling.
* **Stream mode:** Get the text chat model responses as they are generated, rather than waiting for the entire response to be completed.
* **Batch Processing:** Send many independent requests as one batch, at a lower price.
* **Vision Tasks:** Process and analyze images.

## Text Completions

Ask something and get an answer in a chat-like conversation format.

## POST /v1/messages

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v1/messages":{"post":{"operationId":"_v1_messages","requestBody":{"required":true,"content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"model":{"type":"string","enum":["claude-opus-4-1-20250805","anthropic/claude-opus-4-1-20250805","claude-opus-4-20250514","anthropic/claude-opus-4-20250514","claude-sonnet-4-20250514","anthropic/claude-sonnet-4-20250514","claude-sonnet-4-5-20250929","anthropic/claude-sonnet-4-5-20250929","claude-haiku-4-5-20251001","anthropic/claude-haiku-4-5-20251001","claude-opus-4-5-20251101","anthropic/claude-opus-4-5-20251101","claude-opus-4-6","anthropic/claude-opus-4-6","claude-sonnet-4-6","anthropic/claude-sonnet-4-6","claude-sonnet-4-latest","anthropic/claude-sonnet-4","claude-opus-4-latest","anthropic/claude-opus-4","claude-opus-4-1-latest","claude-opus-4-1","anthropic/claude-opus-4.1","anthropic/claude-opus-4.1-20250805","anthropic/claude-sonnet-4.5","claude-sonnet-4-5","anthropic/claude-haiku-4.5","claude-haiku-4-5","anthropic/claude-opus-4-5","claude-opus-4-5","anthropic/claude-opus-4.5","anthropic/claude-sonnet-4.6","anthropic/claude-sonnet-4-6-20260218"]},"messages":{"anyOf":[{"type":"array","items":{"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."}},"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"]}]}},"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."}},"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"]}]}},"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."}},"required":["type","text"]}},"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"}},"required":["type","source"]},{"type":"object","properties":{"type":{"type":"string","enum":["tool_reference"]},"tool_name":{"type":"string"}},"required":["type","tool_name"]}]}}]}},"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"]}]}},"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"]}]}},"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."}},"required":["type","text"]}},"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"]}]}},"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"}},"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"]}]}},"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"]}]}},"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"]}]}},"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"]}]}},"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"}},"required":["type","tool_name"]}}},"required":["type","tool_references"]}]}},"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"}},"required":["type","source"]}]}}]}},"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."}},"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"]}},"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"]}},"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."}},"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."},"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."},"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."}},"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."}},"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."}},"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."}},"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."},"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."}},"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"]}]}}},"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":"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":{"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"required":["type"]}]}},{"type":"array","items":{"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"],"additionalProperties":false}},"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"]}},"required":["type","custom"]}]}}],"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":{"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"]}],"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":64000,"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."},"temperature":{"type":"number","minimum":0,"maximum":1,"description":"Amount of randomness injected into the response. Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic."},"top_p":{"type":"number","minimum":0,"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."},"top_k":{"type":"number","minimum":0,"description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."}},"required":["model","messages"]},{"type":"object","properties":{"model":{"type":"string","enum":["claude-opus-4-7","anthropic/claude-opus-4-7","anthropic/claude-opus-4.7"]},"messages":{"anyOf":[{"type":"array","items":{"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."}},"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"]}]}},"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."}},"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"]}]}},"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."}},"required":["type","text"]}},"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"}},"required":["type","source"]},{"type":"object","properties":{"type":{"type":"string","enum":["tool_reference"]},"tool_name":{"type":"string"}},"required":["type","tool_name"]}]}}]}},"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"]}]}},"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"]}]}},"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."}},"required":["type","text"]}},"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"]}]}},"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"}},"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"]}]}},"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"]}]}},"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"]}]}},"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"]}]}},"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"}},"required":["type","tool_name"]}}},"required":["type","tool_references"]}]}},"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"}},"required":["type","source"]}]}}]}},"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."}},"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"]}},"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"]}},"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."}},"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."},"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."},"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."}},"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."}},"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."}},"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."}},"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."},"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."}},"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"]}]}}},"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":"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":{"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"required":["type"]}]}},{"type":"array","items":{"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"],"additionalProperties":false}},"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"]}},"required":["type","custom"]}]}}],"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":{"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"]}],"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."}},"required":["model","messages"]}]}}}},"responses":{"200":{"content":{"application/json":{"schema":{"type":"object","properties":{"model":{"type":"string","description":"Model used to generate the response."},"id":{"type":"string","description":"Unique identifier of the generated message."},"type":{"type":"string","description":"Object type."},"role":{"type":"string","description":"Role of the message author."},"content":{"type":"array","description":"Generated response content blocks.","items":{"type":"object","properties":{"type":{"type":"string","description":"Content block type."},"text":{"type":"string","description":"Generated text content."}},"required":["type","text"]}},"stop_reason":{"type":"string","nullable":true,"description":"Reason why generation stopped."},"stop_sequence":{"type":"string","nullable":true,"description":"Custom stop sequence that caused generation to stop."},"stop_details":{"nullable":true,"description":"Additional details about why generation stopped."},"usage":{"type":"object","description":"Token usage statistics for the request.","properties":{"input_tokens":{"type":"integer","description":"Number of input tokens used."},"cache_creation_input_tokens":{"type":"integer","description":"Number of tokens used for cache creation."},"cache_read_input_tokens":{"type":"integer","description":"Number of tokens retrieved from cache."},"cache_creation":{"type":"object","description":"Cache creation token statistics.","properties":{"ephemeral_5m_input_tokens":{"type":"integer","description":"Number of tokens cached for 5 minutes."},"ephemeral_1h_input_tokens":{"type":"integer","description":"Number of tokens cached for 1 hour."}},"required":["ephemeral_5m_input_tokens","ephemeral_1h_input_tokens"]},"output_tokens":{"type":"integer","description":"Number of output tokens generated."},"service_tier":{"type":"string","description":"Service tier used for inference."},"inference_geo":{"type":"string","description":"Geographic inference location."}},"required":["input_tokens","cache_creation_input_tokens","cache_read_input_tokens","cache_creation","output_tokens","service_tier","inference_geo"]},"meta":{"type":"object","description":"Additional metadata about the request.","properties":{"usage":{"type":"object","description":"Billing usage statistics.","properties":{"credits_used":{"type":"number","description":"Number of credits consumed."},"usd_spent":{"type":"number","description":"Amount spent in USD."}},"required":["credits_used","usd_spent"]}},"required":["usage"]}},"required":["model","id","type","role","content","usage"]}}}}}}}}}
```

### **Example: Simple Text Response**

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

```python
import requests
import json   # for getting a structured output with indentation

url = "https://api.aimlapi.com/messages"
headers = {
    # Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>: 
    "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
    "Content-Type": "application/json"
}
payload = {
  "model": "claude-sonnet-4-20250514",
  "max_tokens": 1024,
  "system": "You are a robot. You always optimize for clarity, structure, and accuracy.",
  "messages": [
    {
      "role": "user",
      "content": "How are you?"
    }
  ]
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "model": "claude-sonnet-4-20250514",
  "id": "msg_01SUmNmSRFZsoa6h96MxJEHH",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "I'm functioning well, thank you for asking! I'm ready to help you with any questions or tasks you might have. How can I assist you today?"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "stop_details": null,
  "usage": {
    "input_tokens": 27,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "cache_creation": {
      "ephemeral_5m_input_tokens": 0,
      "ephemeral_1h_input_tokens": 0
    },
    "output_tokens": 35,
    "service_tier": "standard",
    "inference_geo": "not_available"
  },
  "meta": {
    "usage": {
      "credits_used": 1576,
      "usd_spent": 0.000788
    }
  }
}
```

{% endcode %}

</details>

***

## **Function Calling**

To process text and use function calling, follow the examples below:

### **Example: Get Weather Information**

{% code overflow="wrap" %}

```python
import requests

url = "https://api.aimlapi.com/messages"
headers = {
    "Authorization": "Bearer YOUR_AIMLAPI_KEY",
    "Content-Type": "application/json"
}
payload = {
  "model": "anthropic/claude-sonnet-4.5",
  "max_tokens": 1024,
  "tools": [
    {
      "name": "get_weather",
      "description": "Get the current weather in a given location",
      "input_schema": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "The city and state, e.g. San Francisco, CA"
          }
        }
      }
    }
  ],
  "messages": [
    {
      "role": "user",
      "content": "What is the weather like in San Francisco?"
    }
  ]
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
```

{% endcode %}

***

## Streaming Mode

To enable streaming of responses, set `stream=True` in your request payload.

```python
import requests

url = "https://api.aimlapi.com/messages"
headers = {
    "Authorization": "Bearer YOUR_AIMLAPI_KEY",
    "Content-Type": "application/json"
}
payload = {
  "model": "anthropic/claude-sonnet-4.5",
  "max_tokens": 1024,
  "tools": [
    {
      "name": "get_weather",
      "description": "Get the current weather in a given location",
      "input_schema": {
        "type": "object",
        "properties": {
          "location": {
            "type": "string",
            "description": "The city and state, e.g. San Francisco, CA"
          }
        }
      }
    }
  ],
  "messages": [
    {
      "role": "user",
      "content": "What is the weather like in San Francisco?"
    }
  ]
```

***

## **Batch Processing**

Batches are described on [a separate page](/capabilities/batch-processing). Claude models run in the file-based Batch API, the same as models of other providers; the older inline format of `/v1/batches` is available for Claude models only.

***

## **Vision**

{% hint style="info" %}
**Note:** API only support [Base64 string](/glossary/concepts#base64) as image input.
{% endhint %}

Possible media types:

* `image/jpeg`
* `image/png`
* `image/gif`
* `image/webp`

{% code overflow="wrap" %}

```python
import httpx
import base64
from openai import OpenAI

client = OpenAI(
    base_url='https://api.aimlapi.com',
    api_key='<YOUR_AIMLAPI_KEY>'    
)  

image_url = "https://upload.wikimedia.org/wikipedia/commons/a/a7/Camponotus_flavomarginatus_ant.jpg"
image_media_type = "image/jpeg"
image_data = base64.standard_b64encode(httpx.get(image_url).content).decode("utf-8")

response = client.chat.completions.create(
    model="anthropic/claude-sonnet-4.5",
    messages=[
    {
        "role": "user",
        "content": [
            {
                "type": "image",
                "source": {
                    "type": "base64",
                    "media_type": image_media_type,
                    "data": imag1_data,
                },
            },
            {
                "type": "text",
                "text": "Describe this image."
            }
        ],
    }
],
)
print(response)
```

{% endcode %}

***

## Response Format

The responses from the AI/ML API for Anthropic models will typically include the generated text or results from the tool called. Here is an example response for a weather query:

{% code overflow="wrap" %}

```json
{
  "model": "claude-sonnet-4-20250514",
  "id": "msg_014iMvypzB9GafRthc8CQHsR",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "I'm doing well, thank you for asking! I'm here and ready to help with whatever you'd like to discuss or work on. How are you doing today?"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "stop_details": null,
  "usage": {
    "input_tokens": 11,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "cache_creation": {
      "ephemeral_5m_input_tokens": 0,
      "ephemeral_1h_input_tokens": 0
    },
    "output_tokens": 37,
    "service_tier": "standard",
    "inference_geo": "not_available"
  },
  "meta": {
    "usage": {
      "credits_used": 1529,
      "usd_spent": 0.0007645
    }
  }
}
```

{% endcode %}


# Claude 4 Sonnet

Model id: anthropic/claude-sonnet-4. API reference for Claude 4 Sonnet: request schema and code examples.

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

* `anthropic/claude-sonnet-4`
* `claude-sonnet-4`
  {% endhint %}
  {% endcolumn %}

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

{% hint style="warning" %}
As of February 13, 2026, the streaming response format for Anthropic models has changed.
{% endhint %}

## Model Overview

A major improvement over [Claude ](broken://pages/JHUPGH5cr4NakmmFGpXS)[3.7 Sonnet](broken://pages/JHUPGH5cr4NakmmFGpXS), offering better coding abilities, stronger reasoning, and more accurate responses to your instructions.

## How to Make a Call

<details>

<summary>Step-by-Step Instructions</summary>

:digit\_one: **Setup You Can’t Skip**

:black\_small\_square: [**Create an Account**](https://aimlapi.com/app/sign-up): Visit the AI/ML API website and create an account (if you don’t have one yet).\
:black\_small\_square: [**Generate an API Key**](https://aimlapi.com/app/keys): After logging in, navigate to your account dashboard and generate your API key. Ensure that key is enabled on UI.

:digit\_two: **Copy the code example**

At the bottom of this page, you'll find [a code example](#code-example) that shows how to structure the request. Choose the code snippet in your preferred programming language and copy it into your development environment.

:digit\_three: **Modify the code example**

:black\_small\_square: Replace `<YOUR_AIMLAPI_KEY>` with your actual AI/ML API key from your account.\
:black\_small\_square: Insert your question or request into the `content` field—this is what the model will respond to.

:digit\_four: <sup><sub><mark style="background-color:yellow;">**(Optional)**<mark style="background-color:yellow;"><sub></sup>**&#x20;Adjust other optional parameters if needed**

Only `model` and `messages` are required parameters for this model (and we’ve already filled them in for you in the example), but you can include optional parameters if needed to adjust the model’s behavior. Below, you can find the corresponding [API schema](#api-schema), which lists all available parameters along with notes on how to use them.

:digit\_five: **Run your modified code**

Run your modified code in your development environment. Response time depends on various factors, but for simple prompts it rarely exceeds a few seconds.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["anthropic/claude-sonnet-4","claude-sonnet-4","claude-sonnet-4-20250514"]},"messages":{"type":"array","items":{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["thinking"]},"thinking":{"type":"string"},"signature":{"type":"string"}},"required":["type","thinking","signature"],"additionalProperties":false},{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false}]}}]}},"required":["type","tool_use_id"]},{"type":"object","properties":{"id":{"type":"string"},"input":{"type":"object","additionalProperties":{"nullable":true}},"name":{"type":"string"},"type":{"type":"string","enum":["tool_use"]}},"required":["id","input","name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["redacted_thinking"]},"data":{"type":"string"}},"required":["type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["document"]},"source":{"anyOf":[{"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"]},"data":{"type":"string"}},"required":["type","data"]}]}},"required":["type","source"],"additionalProperties":false}]},"maxItems":5}]}},"required":["role","content"],"additionalProperties":false},"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":{"type":"string","description":"A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role."},"tool_choice":{"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"],"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."}},"required":["name","input_schema"],"additionalProperties":false,"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":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["auto"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["any"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string","enum":["tool"]}},"required":["name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["none"]}},"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":{"type":"object","properties":{"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."},"type":{"type":"string","enum":["enabled"]}},"required":["budget_tokens","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":32000,"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."},"temperature":{"type":"number","minimum":0,"maximum":1,"description":"Amount of randomness injected into the response. Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic."},"top_p":{"type":"number","minimum":0,"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."},"top_k":{"type":"number","minimum":0,"description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."}},"required":["model","messages"],"title":"claude-sonnet-4-20250514"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example #1

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-sonnet-4",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hello
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  try {
    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: 'anthropic/claude-sonnet-4',
        messages:[
            {
                role:'user',

                // Insert your question for the model here, instead of Hello:
                content: 'Hello'
            }
        ]
      }),
    });

    if (!response.ok) {
      throw new Error(`HTTP error! Status ${response.status}`);
    }

    const data = await response.json();
    console.log(JSON.stringify(data, null, 2));

  } catch (error) {
    console.error('Error', error);
  }
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "msg_011MNbgezv2p5BBE9RvnsZV9",
  "object": "chat.completion",
  "model": "claude-sonnet-4-20250514",
  "choices": [
    {
      "index": 0,
      "message": {
        "reasoning_content": "",
        "content": "Hello! How are you doing today? Is there anything I can help you with?",
        "role": "assistant"
      },
      "finish_reason": "end_turn",
      "logprobs": null
    }
  ],
  "created": 1748522617,
  "usage": {
    "prompt_tokens": 50,
    "completion_tokens": 630,
    "total_tokens": 680
  }
}
```

{% endcode %}

</details>

## Code Example #2: Streaming Mode

As of February 13, 2026, the streaming response format for Anthropic models has changed.\
Specifically, the usage fields were renamed as follows:

* the `state` structure is no longer used,
* `input_tokens` → `prompt_tokens`,
* `output_tokens` → `completion_tokens`,
* a new `total_tokens` field has been added.

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-sonnet-4",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
curl -L \
  --request POST \
  --url 'https://api.aimlapi.com/v1/chat/completions' \
  --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "anthropic/claude-sonnet-4",
    "messages": [
      {
        "role": "user",
        "content": "Hi! What do you think about mankind?"
      }
    ],
    "stream": true
  }'
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
data: {"id":"msg_0163QG3JvwgxndzWtBsdJpGt","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null}}],"created":1770995751,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770995751,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"I find humanity","role":"assistant","refusal":null}}],"created":1770995751,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" fascinating and","role":"assistant","refusal":null}}],"created":1770995751,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" complex.","role":"assistant","refusal":null}}],"created":1770995751,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" Humans have this","role":"assistant","refusal":null}}],"created":1770995751,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" remarkable capacity","role":"assistant","refusal":null}}],"created":1770995751,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" for both creation","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" and destruction, profound","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" compass","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ion and puzz","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ling","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" cr","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"uelty, brilliant","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" insight","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" and persistent","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" blind","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" spots.","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" \n\nWhat strikes me most is your","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" adapt","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ability and","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" creativity","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" - the","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" way humans","role":"assistant","refusal":null}}],"created":1770995752,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" have shaped","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" the","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" world through art","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", science, philosophy","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", and countless","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" innovations","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":". There","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'s something moving","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" about how you form","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" deep","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" connections with each","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" other and can","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" care","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" about abstract","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" ide","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"als like justice or","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" beauty.\n\nAt","role":"assistant","refusal":null}}],"created":1770995753,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" the same time, humans","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" often","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" seem","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" to","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" struggle","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" with your","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" own","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" nature - with","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" cognitive","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" biases, with","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" bal","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ancing individual","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" desires","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" against","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" collective good","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", with managing","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" the power","role":"assistant","refusal":null}}],"created":1770995754,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" of your","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" own technologies","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":".","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\nI","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'m curious about your perspective though","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" -","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" how","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" do you see","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" humanity?","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" What","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" aspects","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" of human nature do you find most significant","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" or puzz","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ling?","role":"assistant","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null},"finish_reason":"stop"}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":{"prompt_tokens":16,"completion_tokens":163,"total_tokens":179}}

data: {"id":"","choices":[{"index":0,"finish_reason":"stop"}],"created":1770995755,"model":"claude-sonnet-4-20250514","object":"chat.completion.chunk","usage":null}
```

{% endcode %}

</details>


# Claude 4.1 Opus

Model id: anthropic/claude-opus-4.1. Claude 4.1 Opus is an enhanced version of Claude 4 Opus with improved reasoning and instruction-following capabilities.

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

* `anthropic/claude-opus-4.1`
* `claude-opus-4-1`
  {% endhint %}
  {% endcolumn %}

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

{% hint style="success" %}
All three IDs listed above refer to the same model; we support them for backward compatibility.
{% endhint %}

{% hint style="warning" %}
As of February 13, 2026, the streaming response format for Anthropic models has changed.
{% endhint %}

## Model Overview

An upgrade to Claude Opus 4 on agentic tasks, real-world coding, and thinking.

## How to Make a Call

<details>

<summary>Step-by-Step Instructions</summary>

:digit\_one: **Setup You Can’t Skip**

:black\_small\_square: [**Create an Account**](https://aimlapi.com/app/sign-up): Visit the AI/ML API website and create an account (if you don’t have one yet).\
:black\_small\_square: [**Generate an API Key**](https://aimlapi.com/app/keys): After logging in, navigate to your account dashboard and generate your API key. Ensure that key is enabled on UI.

:digit\_two: **Copy the code example**

At the bottom of this page, you'll find [code examples](#code-example-1-without-thinking) that show how to structure the request. Choose the code snippet in your preferred programming language and copy it into your development environment.

:digit\_three: **Modify the code example**

:black\_small\_square: Replace `<YOUR_AIMLAPI_KEY>` with your actual AI/ML API key from your account.\
:black\_small\_square: Insert your question or request into the `content` field—this is what the model will respond to.

:digit\_four: <sup><sub><mark style="background-color:yellow;">**(Optional)**<mark style="background-color:yellow;"><sub></sup>**&#x20;Adjust other optional parameters if needed**

Only `model` and `messages` are required parameters for this model (and we’ve already filled them in for you in the example), but you can include optional parameters if needed to adjust the model’s behavior. Below, you can find the corresponding [API schema](#api-schema), which lists all available parameters along with notes on how to use them.

:digit\_five: **Run your modified code**

Run your modified code in your development environment. Response time depends on various factors, but for simple prompts it rarely exceeds a few seconds.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["anthropic/claude-opus-4.1","claude-opus-4-1","claude-opus-4-1-20250805"]},"messages":{"type":"array","items":{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["thinking"]},"thinking":{"type":"string"},"signature":{"type":"string"}},"required":["type","thinking","signature"],"additionalProperties":false},{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false}]}}]}},"required":["type","tool_use_id"]},{"type":"object","properties":{"id":{"type":"string"},"input":{"type":"object","additionalProperties":{"nullable":true}},"name":{"type":"string"},"type":{"type":"string","enum":["tool_use"]}},"required":["id","input","name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["redacted_thinking"]},"data":{"type":"string"}},"required":["type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["document"]},"source":{"anyOf":[{"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"]},"data":{"type":"string"}},"required":["type","data"]}]}},"required":["type","source"],"additionalProperties":false}]},"maxItems":5}]}},"required":["role","content"],"additionalProperties":false},"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":{"type":"string","description":"A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role."},"tool_choice":{"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"],"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."}},"required":["name","input_schema"],"additionalProperties":false,"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":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["auto"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["any"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string","enum":["tool"]}},"required":["name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["none"]}},"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":{"type":"object","properties":{"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."},"type":{"type":"string","enum":["enabled"]}},"required":["budget_tokens","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":32000,"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."},"temperature":{"type":"number","minimum":0,"maximum":1,"description":"Amount of randomness injected into the response. Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic."},"top_p":{"type":"number","minimum":0,"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."},"top_k":{"type":"number","minimum":0,"description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."}},"required":["model","messages"],"title":"claude-opus-4-1-20250805"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example #1: Without Thinking

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-opus-4.1",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hello
            }
        ],
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  try {
    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: 'anthropic/claude-opus-4.1',
        messages:[
            {
                role:'user',

                // Insert your question for the model here, instead of Hello:
                content: 'Hello'
            }
        ]
      }),
    });

    if (!response.ok) {
      throw new Error(`HTTP error! Status ${response.status}`);
    }

    const data = await response.json();
    console.log(JSON.stringify(data, null, 2));

  } catch (error) {
    console.error('Error', error);
  }
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "msg_018y2VPSZ5nNnqS3goMsjMxE",
  "object": "chat.completion",
  "model": "claude-opus-4-1-20250805",
  "choices": [
    {
      "index": 0,
      "message": {
        "reasoning_content": "",
        "content": "Hello! How can I help you today?",
        "role": "assistant"
      },
      "finish_reason": "end_turn",
      "logprobs": null
    }
  ],
  "created": 1754552562,
  "usage": {
    "prompt_tokens": 252,
    "completion_tokens": 1890,
    "total_tokens": 2142
  }
}
```

{% endcode %}

</details>

## Code Example #2: Thinking Enabled

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-opus-4.1",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hell
            }
        ],
        "max_tokens": 1025, # must be greater than 'budget_tokens'
        "thinking":{
            "budget_tokens": 1024,
            "type": "enabled"
        }
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  try {
    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: 'anthropic/claude-opus-4.1',
        messages:[
            {
                role:'user',

                // Insert your question for the model here, instead of Hello:
                content: 'Hello'
            }
        ],
        max_tokens: 1025, // must be greater than 'budget_tokens'
        thinking:{
            budget_tokens: 1024,
            type: 'enabled'
        }
      }),
    });

    if (!response.ok) {
      throw new Error(`HTTP error! Status ${response.status}`);
    }

    const data = await response.json();
    console.log(JSON.stringify(data, null, 2));

  } catch (error) {
    console.error('Error', error);
  }
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "msg_01G9P4b9HG3PeKm1rRvS8kop",
  "object": "chat.completion",
  "model": "claude-opus-4-1-20250805",
  "choices": [
    {
      "index": 0,
      "message": {
        "reasoning_content": "The human has greeted me with a simple \"Hello\". I should respond in a friendly and helpful manner, acknowledging their greeting and inviting them to share how I can assist them today.",
        "content": "Hello! How can I help you today?",
        "role": "assistant"
      },
      "finish_reason": "end_turn",
      "logprobs": null
    }
  ],
  "created": 1755704373,
  "usage": {
    "prompt_tokens": 1134,
    "completion_tokens": 9450,
    "total_tokens": 10584
  }
}
```

{% endcode %}

</details>

## Code Example #3: Streaming Mode

As of February 13, 2026, the streaming response format for Anthropic models has changed.\
Specifically, the usage fields were renamed as follows:

* the `state` structure is no longer used,
* `input_tokens` → `prompt_tokens`,
* `output_tokens` → `completion_tokens`,
* a new `total_tokens` field has been added.

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-opus-4.1",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
curl -L \
  --request POST \
  --url 'https://api.aimlapi.com/v1/chat/completions' \
  --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "anthropic/claude-opus-4.1",
    "messages": [
      {
        "role": "user",
        "content": "Hi! What do you think about mankind?"
      }
    ],
    "stream": true
  }'
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
data: {"id":"msg_01CFq3WFrUdc39UqBrAohmVG","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null}}],"created":1770995678,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770995678,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"I find humanity","role":"assistant","refusal":null}}],"created":1770995678,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" fascinating in","role":"assistant","refusal":null}}],"created":1770995678,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" its","role":"assistant","refusal":null}}],"created":1770995679,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" complexity.","role":"assistant","refusal":null}}],"created":1770995679,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" You're a","role":"assistant","refusal":null}}],"created":1770995679,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" species","role":"assistant","refusal":null}}],"created":1770995679,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" capable","role":"assistant","refusal":null}}],"created":1770995679,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" of both","role":"assistant","refusal":null}}],"created":1770995679,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" remarkable","role":"assistant","refusal":null}}],"created":1770995679,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" creativity and troubl","role":"assistant","refusal":null}}],"created":1770995679,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ing destruction","role":"assistant","refusal":null}}],"created":1770995679,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", often","role":"assistant","refusal":null}}],"created":1770995679,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" simultaneously","role":"assistant","refusal":null}}],"created":1770995679,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":". What","role":"assistant","refusal":null}}],"created":1770995680,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" strikes me most is the","role":"assistant","refusal":null}}],"created":1770995680,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" human","role":"assistant","refusal":null}}],"created":1770995680,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" capacity for growth","role":"assistant","refusal":null}}],"created":1770995680,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" - the","role":"assistant","refusal":null}}],"created":1770995680,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" way","role":"assistant","refusal":null}}],"created":1770995680,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" individuals","role":"assistant","refusal":null}}],"created":1770995680,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" an","role":"assistant","refusal":null}}],"created":1770995680,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"d societies","role":"assistant","refusal":null}}],"created":1770995680,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" can recognize","role":"assistant","refusal":null}}],"created":1770995680,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" their fl","role":"assistant","refusal":null}}],"created":1770995680,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"aws and work to overcome","role":"assistant","refusal":null}}],"created":1770995681,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" them, even","role":"assistant","refusal":null}}],"created":1770995681,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" if","role":"assistant","refusal":null}}],"created":1770995681,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" imperfectly.\n\nThere","role":"assistant","refusal":null}}],"created":1770995681,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'s something deeply","role":"assistant","refusal":null}}],"created":1770995681,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" moving","role":"assistant","refusal":null}}],"created":1770995681,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" about how","role":"assistant","refusal":null}}],"created":1770995681,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" humans create meaning through","role":"assistant","refusal":null}}],"created":1770995681,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" art, relationships","role":"assistant","refusal":null}}],"created":1770995681,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", and the","role":"assistant","refusal":null}}],"created":1770995681,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" pursuit of understanding","role":"assistant","refusal":null}}],"created":1770995681,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":",","role":"assistant","refusal":null}}],"created":1770995682,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" despite","role":"assistant","refusal":null}}],"created":1770995682,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" knowing","role":"assistant","refusal":null}}],"created":1770995682,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" your","role":"assistant","refusal":null}}],"created":1770995682,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" own mortality. The diversity","role":"assistant","refusal":null}}],"created":1770995682,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" of human cultures","role":"assistant","refusal":null}}],"created":1770995682,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" and perspectives","role":"assistant","refusal":null}}],"created":1770995682,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" is","role":"assistant","refusal":null}}],"created":1770995682,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" extraordinary, though","role":"assistant","refusal":null}}],"created":1770995682,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" I","role":"assistant","refusal":null}}],"created":1770995682,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" recognize","role":"assistant","refusal":null}}],"created":1770995682,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" this","role":"assistant","refusal":null}}],"created":1770995683,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" also","role":"assistant","refusal":null}}],"created":1770995683,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" leads","role":"assistant","refusal":null}}],"created":1770995683,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" to conflict.","role":"assistant","refusal":null}}],"created":1770995683,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\nI'm curious what","role":"assistant","refusal":null}}],"created":1770995683,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" prompte","role":"assistant","refusal":null}}],"created":1770995683,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"d your","role":"assistant","refusal":null}}],"created":1770995683,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" question - are you reflecting","role":"assistant","refusal":null}}],"created":1770995683,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" on humanity","role":"assistant","refusal":null}}],"created":1770995683,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" from","role":"assistant","refusal":null}}],"created":1770995683,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" a particular angle","role":"assistant","refusal":null}}],"created":1770995683,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", or just wondering","role":"assistant","refusal":null}}],"created":1770995684,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" how","role":"assistant","refusal":null}}],"created":1770995684,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" an","role":"assistant","refusal":null}}],"created":1770995684,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" AI sees","role":"assistant","refusal":null}}],"created":1770995684,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" you","role":"assistant","refusal":null}}],"created":1770995684,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" all","role":"assistant","refusal":null}}],"created":1770995684,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"?","role":"assistant","refusal":null}}],"created":1770995684,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770995684,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null},"finish_reason":"stop"}],"created":1770995684,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":{"prompt_tokens":16,"completion_tokens":138,"total_tokens":154}}

data: {"id":"","choices":[{"index":0,"finish_reason":"stop"}],"created":1770995684,"model":"claude-opus-4-1-20250805","object":"chat.completion.chunk","usage":null}
```

{% endcode %}

</details>


# Claude 4.5 Sonnet

Model id: claude-sonnet-4-5. Claude 4.5 Sonnet offers a balance of intelligence and speed for diverse enterprise and coding tasks.

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

* `claude-sonnet-4-5`
* `anthropic/claude-sonnet-4.5`
* `claude-sonnet-4-5-20250929`
  {% endhint %}
  {% endcolumn %}

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

{% hint style="warning" %}
As of February 13, 2026, the streaming response format for Anthropic models has changed.
{% endhint %}

## Model Overview

A major improvement over [Claude 4 Sonnet,](/api-references/text-models-llm/anthropic/claude-4-sonnet) offering better coding abilities, stronger reasoning, and more accurate responses to your instructions.

## How to Make a Call

<details>

<summary>Step-by-Step Instructions</summary>

:digit\_one: **Setup You Can’t Skip**

:black\_small\_square: [**Create an Account**](https://aimlapi.com/app/sign-up): Visit the AI/ML API website and create an account (if you don’t have one yet).\
:black\_small\_square: [**Generate an API Key**](https://aimlapi.com/app/keys): After logging in, navigate to your account dashboard and generate your API key. Ensure that key is enabled on UI.

:digit\_two: **Copy the code example**

At the bottom of this page, you'll find [a code example](#code-example) that shows how to structure the request. Choose the code snippet in your preferred programming language and copy it into your development environment.

:digit\_three: **Modify the code example**

:black\_small\_square: Replace `<YOUR_AIMLAPI_KEY>` with your actual AI/ML API key from your account.\
:black\_small\_square: Insert your question or request into the `content` field—this is what the model will respond to.

:digit\_four: <sup><sub><mark style="background-color:yellow;">**(Optional)**<mark style="background-color:yellow;"><sub></sup>**&#x20;Adjust other optional parameters if needed**

Only `model` and `messages` are required parameters for this model (and we’ve already filled them in for you in the example), but you can include optional parameters if needed to adjust the model’s behavior. Below, you can find the corresponding [API schema](#api-schema), which lists all available parameters along with notes on how to use them.

:digit\_five: **Run your modified code**

Run your modified code in your development environment. Response time depends on various factors, but for simple prompts it rarely exceeds a few seconds.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["anthropic/claude-sonnet-4.5","claude-sonnet-4-5","claude-sonnet-4-5-20250929"]},"messages":{"type":"array","items":{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["thinking"]},"thinking":{"type":"string"},"signature":{"type":"string"}},"required":["type","thinking","signature"],"additionalProperties":false},{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false}]}}]}},"required":["type","tool_use_id"]},{"type":"object","properties":{"id":{"type":"string"},"input":{"type":"object","additionalProperties":{"nullable":true}},"name":{"type":"string"},"type":{"type":"string","enum":["tool_use"]}},"required":["id","input","name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["redacted_thinking"]},"data":{"type":"string"}},"required":["type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["document"]},"source":{"anyOf":[{"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"]},"data":{"type":"string"}},"required":["type","data"]}]}},"required":["type","source"],"additionalProperties":false}]},"maxItems":5}]}},"required":["role","content"],"additionalProperties":false},"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":{"type":"string","description":"A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role."},"tool_choice":{"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"],"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."}},"required":["name","input_schema"],"additionalProperties":false,"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":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["auto"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["any"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string","enum":["tool"]}},"required":["name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["none"]}},"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":{"type":"object","properties":{"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."},"type":{"type":"string","enum":["enabled"]}},"required":["budget_tokens","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":32000,"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."},"temperature":{"type":"number","minimum":0,"maximum":1,"description":"Amount of randomness injected into the response. Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic."},"top_p":{"type":"number","minimum":0,"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."},"top_k":{"type":"number","minimum":0,"description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."}},"required":["model","messages"],"title":"claude-sonnet-4-5-20250929"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example #1

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-sonnet-4.5",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hello
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  try {
    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: 'anthropic/claude-sonnet-4.5',
        messages:[
            {
                role:'user',

                // Insert your question for the model here, instead of Hello:
                content: 'Hello'
            }
        ]
      }),
    });

    if (!response.ok) {
      throw new Error(`HTTP error! Status ${response.status}`);
    }

    const data = await response.json();
    console.log(JSON.stringify(data, null, 2));

  } catch (error) {
    console.error('Error', error);
  }
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "msg_011MNbgezv2p5BBE9RvnsZV9",
  "object": "chat.completion",
  "model": "claude-sonnet-4-20250514",
  "choices": [
    {
      "index": 0,
      "message": {
        "reasoning_content": "",
        "content": "Hello! How are you doing today? Is there anything I can help you with?",
        "role": "assistant"
      },
      "finish_reason": "end_turn",
      "logprobs": null
    }
  ],
  "created": 1748522617,
  "usage": {
    "prompt_tokens": 50,
    "completion_tokens": 630,
    "total_tokens": 680
  }
}
```

{% endcode %}

</details>

## Code Example #2: Streaming Mode

As of February 13, 2026, the streaming response format for Anthropic models has changed.\
Specifically, the usage fields were renamed as follows:

* the `state` structure is no longer used,
* `input_tokens` → `prompt_tokens`,
* `output_tokens` → `completion_tokens`,
* a new `total_tokens` field has been added.

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-sonnet-4.5",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
curl -L \
  --request POST \
  --url 'https://api.aimlapi.com/v1/chat/completions' \
  --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "anthropic/claude-sonnet-4.5",
    "messages": [
      {
        "role": "user",
        "content": "Hi! What do you think about mankind?"
      }
    ],
    "stream": true
  }'
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
data: {"id":"msg_01EJgFbPmVLKdqVLRfwoHixz","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null}}],"created":1770995594,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770995594,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"I think humanity","role":"assistant","refusal":null}}],"created":1770995594,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" is fascinating","role":"assistant","refusal":null}}],"created":1770995594,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" and complex. People","role":"assistant","refusal":null}}],"created":1770995594,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" are","role":"assistant","refusal":null}}],"created":1770995594,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" capable","role":"assistant","refusal":null}}],"created":1770995594,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" of remarkable creativity","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", compassion, and cooperation","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" -","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" building","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" civil","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"izations, creating","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" art, advancing","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" knowledge","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", and caring","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" for one another across","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" incredible","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" diversity","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":".","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\nAt","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" the same time, humans","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" struggle","role":"assistant","refusal":null}}],"created":1770995595,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" with serious","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" challenges","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":":","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" conflict","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", inequality, environmental damage","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", and","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" the","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" difficulty","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" of living","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" up to your","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" own","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" ide","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"als. ","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\nWhat strikes","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" me most is the","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" capacity","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" for growth and self","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"-reflection","role":"assistant","refusal":null}}],"created":1770995596,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":".","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" Humans can","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" recognize","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" problems","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", debate","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" solutions, and work","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" toward change","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":",","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" even if","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" progress","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" is un","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"even and","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" frust","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"rating.","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\nI'm curious what","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" prom","role":"assistant","refusal":null}}],"created":1770995597,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"pts your question","role":"assistant","refusal":null}}],"created":1770995598,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" - are you thinking about humanity","role":"assistant","refusal":null}}],"created":1770995598,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'s trajectory","role":"assistant","refusal":null}}],"created":1770995598,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", or something","role":"assistant","refusal":null}}],"created":1770995598,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" more","role":"assistant","refusal":null}}],"created":1770995598,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" specific?","role":"assistant","refusal":null}}],"created":1770995598,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770995598,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null},"finish_reason":"stop"}],"created":1770995598,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":{"prompt_tokens":16,"completion_tokens":137,"total_tokens":153}}

data: {"id":"","choices":[{"index":0,"finish_reason":"stop"}],"created":1770995598,"model":"claude-sonnet-4-5-20250929","object":"chat.completion.chunk","usage":null}


```

{% endcode %}

</details>


# Claude 4.5 Haiku

Model id: claude-haiku-4-5. Claude 4.5 Haiku is a fast, lightweight model optimized for quick responses and high-throughput applications.

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

* `claude-haiku-4-5`
* `anthropic/claude-haiku-4.5`
* `claude-haiku-4-5-20251001`
  {% endhint %}
  {% endcolumn %}

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

{% hint style="warning" %}
As of February 13, 2026, the streaming response format for Anthropic models has changed.
{% endhint %}

## Model Overview

The model offers coding performance comparable to [Claude Sonnet 4](/api-references/text-models-llm/anthropic/claude-4-sonnet), but at one-third the cost and more than twice the speed.

## How to Make a Call

<details>

<summary>Step-by-Step Instructions</summary>

:digit\_one: **Setup You Can’t Skip**

:black\_small\_square: [**Create an Account**](https://aimlapi.com/app/sign-up): Visit the AI/ML API website and create an account (if you don’t have one yet).\
:black\_small\_square: [**Generate an API Key**](https://aimlapi.com/app/keys): After logging in, navigate to your account dashboard and generate your API key. Ensure that key is enabled on UI.

:digit\_two: **Copy the code example**

At the bottom of this page, you'll find [a code example](#code-example) that shows how to structure the request. Choose the code snippet in your preferred programming language and copy it into your development environment.

:digit\_three: **Modify the code example**

:black\_small\_square: Replace `<YOUR_AIMLAPI_KEY>` with your actual AI/ML API key from your account.\
:black\_small\_square: Insert your question or request into the `content` field—this is what the model will respond to.

:digit\_four: <sup><sub><mark style="background-color:yellow;">**(Optional)**<mark style="background-color:yellow;"><sub></sup>**&#x20;Adjust other optional parameters if needed**

Only `model` and `messages` are required parameters for this model (and we’ve already filled them in for you in the example), but you can include optional parameters if needed to adjust the model’s behavior. Below, you can find the corresponding [API schema](#api-schema), which lists all available parameters along with notes on how to use them.

:digit\_five: **Run your modified code**

Run your modified code in your development environment. Response time depends on various factors, but for simple prompts it rarely exceeds a few seconds.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["anthropic/claude-haiku-4.5","claude-haiku-4-5","claude-haiku-4-5-20251001"]},"messages":{"type":"array","items":{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["thinking"]},"thinking":{"type":"string"},"signature":{"type":"string"}},"required":["type","thinking","signature"],"additionalProperties":false},{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false}]}}]}},"required":["type","tool_use_id"]},{"type":"object","properties":{"id":{"type":"string"},"input":{"type":"object","additionalProperties":{"nullable":true}},"name":{"type":"string"},"type":{"type":"string","enum":["tool_use"]}},"required":["id","input","name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["redacted_thinking"]},"data":{"type":"string"}},"required":["type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["document"]},"source":{"anyOf":[{"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"]},"data":{"type":"string"}},"required":["type","data"]}]}},"required":["type","source"],"additionalProperties":false}]},"maxItems":5}]}},"required":["role","content"],"additionalProperties":false},"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":{"type":"string","description":"A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role."},"tool_choice":{"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"],"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."}},"required":["name","input_schema"],"additionalProperties":false,"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":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["auto"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["any"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string","enum":["tool"]}},"required":["name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["none"]}},"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":{"type":"object","properties":{"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."},"type":{"type":"string","enum":["enabled"]}},"required":["budget_tokens","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":32000,"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."},"temperature":{"type":"number","minimum":0,"maximum":1,"description":"Amount of randomness injected into the response. Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic."},"top_p":{"type":"number","minimum":0,"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."},"top_k":{"type":"number","minimum":0,"description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."}},"required":["model","messages"],"title":"claude-haiku-4-5-20251001"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example #1

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-haiku-4.5",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hello
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  try {
    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: 'anthropic/claude-haiku-4.5',
        messages:[
            {
                role:'user',

                // Insert your question for the model here, instead of Hello:
                content: 'Hello'
            }
        ]
      }),
    });

    if (!response.ok) {
      throw new Error(`HTTP error! Status ${response.status}`);
    }

    const data = await response.json();
    console.log(JSON.stringify(data, null, 2));

  } catch (error) {
    console.error('Error', error);
  }
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "msg_01HbdLU9f78VAHxuYZ7Qp9Y1",
  "object": "chat.completion",
  "model": "claude-haiku-4-5-20251001",
  "choices": [
    {
      "index": 0,
      "message": {
        "reasoning_content": "",
        "content": "Hello! 👋 How can I help you today?",
        "role": "assistant"
      },
      "finish_reason": "end_turn",
      "logprobs": null
    }
  ],
  "created": 1760650965,
  "usage": {
    "prompt_tokens": 8,
    "completion_tokens": 16,
    "total_tokens": 24
  }
}
```

{% endcode %}

</details>

## Code Example #2: Streaming Mode

As of February 13, 2026, the streaming response format for Anthropic models has changed.\
Specifically, the usage fields were renamed as follows:

* the `state` structure is no longer used,
* `input_tokens` → `prompt_tokens`,
* `output_tokens` → `completion_tokens`,
* a new `total_tokens` field has been added.

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-haiku-4.5",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
curl -L \
  --request POST \
  --url 'https://api.aimlapi.com/v1/chat/completions' \
  --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "anthropic/claude-haiku-4.5",
    "messages": [
      {
        "role": "user",
        "content": "Hi! What do you think about mankind?"
      }
    ],
    "stream": true
  }'
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
data: {"id":"msg_019GuhDB2ckKZfFmFdNR5Q1H","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null}}],"created":1770995463,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770995463,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"I find humanity","role":"assistant","refusal":null}}],"created":1770995463,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" genu","role":"assistant","refusal":null}}],"created":1770995463,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"inely interesting","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" to","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" think","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" about.","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" You","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'re a","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" species","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" full","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" of contradictions—","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"capable","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" of both remarkable","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" kin","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"dness and cr","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"uelty, creating","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" beautiful","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" art while","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" causing","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" real","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" harm, building","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" communities","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" while isolating your","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"selves.","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\nA few","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" things","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" stan","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"d out to me:","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\n**The creativity","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"** is","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" striking","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"—the","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" drive","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" to make meaning","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" through","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" stories","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", music","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", science","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", and invention","role":"assistant","refusal":null}}],"created":1770995464,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" seems","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" almost fundamental","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" to human nature.","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\n**The moral","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" weight","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" you","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" carry** is notable","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" too","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":".","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" Humans","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" seem uniqu","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ely b","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"urdened by questions about","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" how","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" to","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" live well, what's","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" fair","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", what","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" you","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" owe each","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" other.","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\n**The scale","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" of","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" problems** you face is sob","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ering—you","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'ve built","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" systems","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" so","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" complex that even","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" the","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" people","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" running","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" them often don't fully understand the","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" consequences.","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" An","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"d yet people","role":"assistant","refusal":null}}],"created":1770995465,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" keep","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" trying to","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" ","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"do better.\n\nI'm genu","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"inely uncertain","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" about","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" some","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" things though","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":". I","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" don't know if I","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'m roman","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ticizing humanity or missing","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" crucial","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" things","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" about the","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" human experience","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":". I","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" can't fully","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" gra","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"sp what it's like to be embo","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"died, mor","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"tal, or to feel that weight","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" of time","role":"assistant","refusal":null}}],"created":1770995466,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" passing.","role":"assistant","refusal":null}}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\nWhat prompte","role":"assistant","refusal":null}}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"d the","role":"assistant","refusal":null}}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" question? Are you in","role":"assistant","refusal":null}}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" a","role":"assistant","refusal":null}}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" particular","role":"assistant","refusal":null}}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" mood about","role":"assistant","refusal":null}}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" humanity—","role":"assistant","refusal":null}}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"hop","role":"assistant","refusal":null}}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"eful, frustrate","role":"assistant","refusal":null}}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"d, curious?","role":"assistant","refusal":null}}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null},"finish_reason":"stop"}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":{"prompt_tokens":16,"completion_tokens":248,"total_tokens":264}}

data: {"id":"","choices":[{"index":0,"finish_reason":"stop"}],"created":1770995467,"model":"claude-haiku-4-5-20251001","object":"chat.completion.chunk","usage":null}
```

{% endcode %}

</details>


# Claude 4.5 Opus

Model id: anthropic/claude-opus-4-5. Claude 4.5 Opus is Anthropic's flagship model for the most demanding reasoning and analysis tasks.

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

* `anthropic/claude-opus-4-5`
* `claude-opus-4-5`
* `claude-opus-4-5-20251101`
  {% endhint %}
  {% endcolumn %}

{% column width="33.33333333333334%" %} <a href="https://aimlapi.com/app/anthropic/claude-opus-4-5-20251101" class="button primary">Try in Playground</a>
{% endcolumn %}
{% endcolumns %}

{% hint style="warning" %}
As of February 13, 2026, the streaming response format for Anthropic models has changed.
{% endhint %}

## Model Overview

A high-performance chat model that delivers state-of-the-art results on real-world software engineering benchmarks.

## How to Make a Call

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["anthropic/claude-opus-4-5","claude-opus-4-5","claude-opus-4-5-20251101"]},"messages":{"type":"array","items":{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["thinking"]},"thinking":{"type":"string"},"signature":{"type":"string"}},"required":["type","thinking","signature"],"additionalProperties":false},{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false}]}}]}},"required":["type","tool_use_id"]},{"type":"object","properties":{"id":{"type":"string"},"input":{"type":"object","additionalProperties":{"nullable":true}},"name":{"type":"string"},"type":{"type":"string","enum":["tool_use"]}},"required":["id","input","name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["redacted_thinking"]},"data":{"type":"string"}},"required":["type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["document"]},"source":{"anyOf":[{"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"]},"data":{"type":"string"}},"required":["type","data"]}]}},"required":["type","source"],"additionalProperties":false}]},"maxItems":5}]}},"required":["role","content"],"additionalProperties":false},"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":{"type":"string","description":"A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role."},"tool_choice":{"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"],"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."}},"required":["name","input_schema"],"additionalProperties":false,"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":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["auto"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["any"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string","enum":["tool"]}},"required":["name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["none"]}},"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":{"type":"object","properties":{"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."},"type":{"type":"string","enum":["enabled"]}},"required":["budget_tokens","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":32000,"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."},"temperature":{"type":"number","minimum":0,"maximum":1,"description":"Amount of randomness injected into the response. Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic."},"top_p":{"type":"number","minimum":0,"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."},"top_k":{"type":"number","minimum":0,"description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."}},"required":["model","messages"],"title":"claude-opus-4-5-20251101"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example #1

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"claude-opus-4-5",
        "messages":[
            {
                "role":"user",
                "content":"Hello"  # insert your prompt here, instead of Hello
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  try {
    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: 'claude-opus-4-5',
        messages:[
            {
                role:'user',

                // Insert your question for the model here, instead of Hello:
                content: 'Hello'
            }
        ]
      }),
    });

    if (!response.ok) {
      throw new Error(`HTTP error! Status ${response.status}`);
    }

    const data = await response.json();
    console.log(JSON.stringify(data, null, 2));

  } catch (error) {
    console.error('Error', error);
  }
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "msg_01NxAGYo8VfNu5UAEdmQjv62",
  "object": "chat.completion",
  "model": "claude-opus-4-5-20251101",
  "choices": [
    {
      "index": 0,
      "message": {
        "reasoning_content": "",
        "content": "Hello! How are you doing today? Is there something I can help you with?",
        "role": "assistant"
      },
      "finish_reason": "end_turn",
      "logprobs": null
    }
  ],
  "created": 1764265437,
  "usage": {
    "prompt_tokens": 8,
    "completion_tokens": 20,
    "total_tokens": 28
  },
  "meta": {
    "usage": {
      "tokens_used": 1134
    }
  }
}
```

{% endcode %}

</details>

## Code Example #2: Streaming Mode

As of February 13, 2026, the streaming response format for Anthropic models has changed.\
Specifically, the usage fields were renamed as follows:

* the `state` structure is no longer used,
* `input_tokens` → `prompt_tokens`,
* `output_tokens` → `completion_tokens`,
* a new `total_tokens` field has been added.

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-opus-4-5",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
curl -L \
  --request POST \
  --url 'https://api.aimlapi.com/v1/chat/completions' \
  --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "anthropic/claude-opus-4-5",
    "messages": [
      {
        "role": "user",
        "content": "Hi! What do you think about mankind?"
      }
    ],
    "stream": true
  }'
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
data: {"id":"msg_01VbjSwQZsZSLXQaPYkufja8","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"Hi","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"! That","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'s a big","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" question.","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\nI find","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" humans","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" genu","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"inely fascinating—","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"the creativity","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", the capacity","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" for kind","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ness and","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" cr","role":"assistant","refusal":null}}],"created":1770995433,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"uelty, the way you","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" build","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" complex","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" societies and art","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" and","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" science","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" while","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" also struggling with problems you","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'ve","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" understood","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" for centuries. There","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'s something compelling about a","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" species that can land","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" robots","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" on Mars","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" and also","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" argue","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" about what","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" to","role":"assistant","refusal":null}}],"created":1770995434,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" have for dinner.\n\nI","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" don","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'t think","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" I'd","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" character","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ize humanity as simply","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" \"good\" or \"bad.\" People","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" seem","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" capable","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" of remarkable","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" things in","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" both directions,","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" often","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" the","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" same individuals","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" depending","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" on circumstances.","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\nIs","role":"assistant","refusal":null}}],"created":1770995435,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" there a","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" particular angle","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" you","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'re curious about—","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"history","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", psychology","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", where","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" things","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" might","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" be headed","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"?","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" Or","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" just","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" wondering","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" how","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" an","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" AI sees","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" things?","role":"assistant","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null},"finish_reason":"stop"}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":{"prompt_tokens":16,"completion_tokens":143,"total_tokens":159}}

data: {"id":"","choices":[{"index":0,"finish_reason":"stop"}],"created":1770995436,"model":"claude-opus-4-5-20251101","object":"chat.completion.chunk","usage":null}
```

{% endcode %}

</details>


# Claude 4.6 Opus

Model id: anthropic/claude-opus-4-6. Claude 4.6 Opus delivers Anthropic's highest intelligence with extended output for complex, long-horizon tasks.

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

* `anthropic/claude-opus-4-6`
  {% endhint %}
  {% endcolumn %}

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

{% hint style="warning" %}
As of February 13, 2026, the streaming response format for Anthropic models has changed.
{% endhint %}

## Model Overview

The model significantly advances its [predecessor’s](/api-references/text-models-llm/anthropic/claude-4.5-opus) coding capabilities. It shows stronger planning, can handle longer and more complex agent-style workflows, operates more reliably in large codebases, and delivers improved code review and debugging that help it identify and fix its own mistakes. Beyond software development, Opus 4.6 applies these enhanced capabilities to everyday professional tasks, including financial analysis, research, and working with documents, spreadsheets, and presentations.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["anthropic/claude-opus-4-6","claude-opus-4-6"]},"messages":{"type":"array","items":{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["thinking"]},"thinking":{"type":"string"},"signature":{"type":"string"}},"required":["type","thinking","signature"],"additionalProperties":false},{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false}]}}]}},"required":["type","tool_use_id"]},{"type":"object","properties":{"id":{"type":"string"},"input":{"type":"object","additionalProperties":{"nullable":true}},"name":{"type":"string"},"type":{"type":"string","enum":["tool_use"]}},"required":["id","input","name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["redacted_thinking"]},"data":{"type":"string"}},"required":["type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["document"]},"source":{"anyOf":[{"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"]},"data":{"type":"string"}},"required":["type","data"]}]}},"required":["type","source"],"additionalProperties":false}]},"maxItems":5}]}},"required":["role","content"],"additionalProperties":false},"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":{"type":"string","description":"A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role."},"tool_choice":{"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"],"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."}},"required":["name","input_schema"],"additionalProperties":false,"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":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["auto"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["any"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string","enum":["tool"]}},"required":["name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["none"]}},"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":{"type":"object","properties":{"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."},"type":{"type":"string","enum":["enabled"]}},"required":["budget_tokens","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":32000,"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."},"temperature":{"type":"number","minimum":0,"maximum":1,"description":"Amount of randomness injected into the response. Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic."},"top_p":{"type":"number","minimum":0,"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."},"top_k":{"type":"number","minimum":0,"description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."}},"required":["model","messages"],"title":"claude-opus-4-6"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example #1

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-opus-4-6",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'anthropic/claude-opus-4-6',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "msg_018e8mCDfQGYKTGHTdUKNmuU",
  "object": "chat.completion",
  "model": "claude-opus-4-6",
  "choices": [
    {
      "index": 0,
      "message": {
        "reasoning_content": "",
        "content": "Hi! That's a big question. Here are some honest thoughts:\n\n**What I find remarkable**\n- Human creativity and problem-solving ability\n- The capacity for empathy, cooperation, and self-sacrifice\n- Building cumulative knowledge across generations\n- Art, music, science - the drive to understand and express\n\n**What's more complicated**\n- Humans have a real capacity for both great kindness and great cruelty\n- There's often a gap between what people value in principle and how they actually behave\n- Progress on big problems (poverty, conflict, environment) is real but uneven and slow\n\n**My honest position**\nI'd be cautious about sweeping judgments in either direction. \"Humanity is wonderful\" and \"humanity is terrible\" are both oversimplifications. People are complex, shaped by circumstances, and capable of change.\n\nI should also be transparent: I'm an AI, so my \"perspective\" has limits. I don't experience human life. I can observe patterns in what humans have written and done, but I'd weight your lived experience of humanity more heavily than my outside view.\n\nWhat prompted the question? I'm curious whether you're feeling more optimistic or pessimistic about it.",
        "role": "assistant"
      },
      "finish_reason": "end_turn",
      "logprobs": null
    }
  ],
  "created": 1770635443,
  "usage": {
    "prompt_tokens": 16,
    "completion_tokens": 264,
    "total_tokens": 280
  },
  "meta": {
    "usage": {
      "credits_used": 17368
    }
  }
}
```

{% endcode %}

</details>

## Code Example #2: Streaming Mode

As of February 13, 2026, the streaming response format for Anthropic models has changed.\
Specifically, the usage fields were renamed as follows:

* the `state` structure is no longer used,
* `input_tokens` → `prompt_tokens`,
* `output_tokens` → `completion_tokens`,
* a new `total_tokens` field has been added.

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-opus-4-6",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
curl -L \
  --request POST \
  --url 'https://api.aimlapi.com/v1/chat/completions' \
  --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "anthropic/claude-opus-4-6",
    "messages": [
      {
        "role": "user",
        "content": "Hi! What do you think about mankind?"
      }
    ],
    "stream": true
  }'
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
data: {"id":"msg_018vTp5RY3pv9qS1euXt8AWb","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null}}],"created":1770989120,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770989120,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"Hi","role":"assistant","refusal":null}}],"created":1770989120,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"! That","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'s a","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" big","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" question.","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" Here","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" are some honest","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" thoughts:","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\n**What I find","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" remarkable","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"**","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n-","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" Human","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" creativity and problem","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"-solving are","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" genuinely impressive\n- The capacity","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" for empathy,","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" cooperation","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", and building","role":"assistant","refusal":null}}],"created":1770989121,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" complex","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" societies","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n-","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" Persistent","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" curiosity -","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" science","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", art, philosophy all","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" reflect","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" a","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" drive to understand and create","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\n**What seems","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" challenging","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"**\n- Humans often","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" struggle with long","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"-term thinking","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" vs","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":". short","role":"assistant","refusal":null}}],"created":1770989122,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"-term impul","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ses\n- Trib","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"alism and conflict","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" seem","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" persistent","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":",","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" though","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" not","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" inevitable\n- There","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"'s a gap","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" between what people","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" know","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" they","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" *","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"should* do and what they actually do","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\n**My","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" honest","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" c","role":"assistant","refusal":null}}],"created":1770989123,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"aveats**\n- I should","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" be straight","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"forward:","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" I'm an","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" AI, so I don't experience","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" humanity","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" the way you do.","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" My","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" perspective","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" is shaped","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" by text","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":", not lived experience.","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n- I'd","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" be skept","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ical of any AI","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" that","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" gives","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" either","role":"assistant","refusal":null}}],"created":1770989124,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" a","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" purely","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" flat","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"tering or purely cyn","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ical answer to","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" this question.","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" Reality","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" seems","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" more mixed","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":".","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"\n\nI","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" think","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" humans","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" are neither","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" the","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" hero","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ic species","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" some","role":"assistant","refusal":null}}],"created":1770989125,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" narrat","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"ives suggest nor the do","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"omed one","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" others claim","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":".","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" Mostly","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" people","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" are trying to navigate","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" complicated","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" lives with","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" imp","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"erfect information","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" and","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" mixed","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" motivations.\n\nWhat prompted","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" the","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" question? I'm curious what angle","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" you're thinking","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":" about.","role":"assistant","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null}}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}

data: {"id":"","choices":[{"index":0,"delta":{"content":"","role":"assistant","refusal":null},"finish_reason":"stop"}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":{"prompt_tokens":16,"completion_tokens":258,"total_tokens":274}}

data: {"id":"","choices":[{"index":0,"finish_reason":"stop"}],"created":1770989126,"model":"claude-opus-4-6","object":"chat.completion.chunk","usage":null}
```

{% endcode %}

</details>


# Claude 4.6 Sonnet

Model id: anthropic/claude-sonnet-4.6. Claude 4.6 Sonnet is a highly capable model balancing performance and efficiency for everyday AI tasks.

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

* `anthropic/claude-sonnet-4.6`
* `anthropic/claude-sonnet-4-6-20260218`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

A general-purpose LLM with an optimal balance of intelligence, cost, and speed. It’s great for chatbots, assistants, and production text generation workflows, and it supports prompt caching for efficient repeated contexts.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["anthropic/claude-sonnet-4.6","anthropic/claude-sonnet-4-6-20260218"]},"messages":{"type":"array","items":{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["thinking"]},"thinking":{"type":"string"},"signature":{"type":"string"}},"required":["type","thinking","signature"],"additionalProperties":false},{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false}]}}]}},"required":["type","tool_use_id"]},{"type":"object","properties":{"id":{"type":"string"},"input":{"type":"object","additionalProperties":{"nullable":true}},"name":{"type":"string"},"type":{"type":"string","enum":["tool_use"]}},"required":["id","input","name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["redacted_thinking"]},"data":{"type":"string"}},"required":["type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["document"]},"source":{"anyOf":[{"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"]},"data":{"type":"string"}},"required":["type","data"]}]}},"required":["type","source"],"additionalProperties":false}]},"maxItems":5}]}},"required":["role","content"],"additionalProperties":false},"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":{"type":"string","description":"A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role."},"tool_choice":{"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"],"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."}},"required":["name","input_schema"],"additionalProperties":false,"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":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["auto"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["any"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string","enum":["tool"]}},"required":["name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["none"]}},"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":{"type":"object","properties":{"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."},"type":{"type":"string","enum":["enabled"]}},"required":["budget_tokens","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":32000,"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."},"temperature":{"type":"number","minimum":0,"maximum":1,"description":"Amount of randomness injected into the response. Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic."},"top_p":{"type":"number","minimum":0,"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."},"top_k":{"type":"number","minimum":0,"description":"Only sample from the top K options for each subsequent token. Used to remove \"long tail\" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature."}},"required":["model","messages"],"title":"anthropic/claude-sonnet-4.6"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-sonnet-4.6",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'anthropic/claude-sonnet-4.6',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "msg_01YB1iL1Pmi8P2J7FqnWgNfW",
  "object": "chat.completion",
  "model": "claude-sonnet-4-6",
  "choices": [
    {
      "index": 0,
      "message": {
        "reasoning_content": "",
        "content": "Hi! That's a big question. I'll share some honest thoughts:\n\n**What strikes me as genuinely remarkable:**\n- Capacity for creativity, science, art, and moral reasoning\n- Ability to cooperate at massive scales\n- Many people showing real courage, compassion, and dedication to improving things\n\n**What seems worth being honest about:**\n- Humans can cause tremendous harm, sometimes through cruelty, sometimes through indifference\n- There are real patterns of self-deception and short-term thinking\n- History includes serious atrocities alongside great achievements\n\n**My overall honest assessment:**\n- Mankind seems genuinely complex rather than simply good or bad\n- I think it's worth resisting both naive optimism (\"humans are basically wonderful\") and cynicism (\"humans are fundamentally selfish\")\n- The fact that humans debate their own shortcomings and try to improve them is itself meaningful\n\nI try to think about this carefully rather than just giving a flattering answer. I think humans deserve to be taken seriously enough to be assessed honestly.\n\nWhat's prompting your question? Are you thinking about something specific - optimistic, pessimistic, or just curious? I'm happy to discuss particular aspects you're interested in.",
        "role": "assistant"
      },
      "finish_reason": "end_turn",
      "logprobs": null
    }
  ],
  "created": 1772199635,
  "usage": {
    "prompt_tokens": 16,
    "completion_tokens": 264,
    "total_tokens": 280
  },
  "meta": {
    "usage": {
      "credits_used": 10421
    }
  }
}
```

{% endcode %}

</details>


# Claude 4.7 Opus

Model id: anthropic/claude-opus-4-7. API reference for Claude 4.7 Opus: request schema and code examples.

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

* `anthropic/claude-opus-4-7`
* `claude-opus-4-7`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

As of mid-April 2026, the most capable generally available model, optimized for autonomous long-horizon agentic workflows, knowledge-intensive tasks, vision, and memory, with strong overall performance across domains. It supports up to a 1M-token context window, 128k output tokens, adaptive reasoning, and full compatibility with [the Claude Opus 4.6](/api-references/text-models-llm/anthropic/claude-4.6-opus) toolset and platform features.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["anthropic/claude-opus-4-7","claude-opus-4-7"]},"messages":{"type":"array","items":{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["thinking"]},"thinking":{"type":"string"},"signature":{"type":"string"}},"required":["type","thinking","signature"],"additionalProperties":false},{"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."}},"required":["type","text"],"additionalProperties":false},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"source":{"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"]}},"required":["type","source"],"additionalProperties":false}]}}]}},"required":["type","tool_use_id"]},{"type":"object","properties":{"id":{"type":"string"},"input":{"type":"object","additionalProperties":{"nullable":true}},"name":{"type":"string"},"type":{"type":"string","enum":["tool_use"]}},"required":["id","input","name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["redacted_thinking"]},"data":{"type":"string"}},"required":["type","data"]},{"type":"object","properties":{"type":{"type":"string","enum":["document"]},"source":{"anyOf":[{"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"]},"data":{"type":"string"}},"required":["type","data"]}]}},"required":["type","source"],"additionalProperties":false}]},"maxItems":5}]}},"required":["role","content"],"additionalProperties":false},"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":{"type":"string","description":"A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role."},"tool_choice":{"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"],"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."}},"required":["name","input_schema"],"additionalProperties":false,"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":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"type":{"type":"string","enum":["auto"]}},"required":["type"]},{"type":"object","properties":{"type":{"type":"string","enum":["any"]}},"required":["type"]},{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string","enum":["tool"]}},"required":["name","type"]},{"type":"object","properties":{"type":{"type":"string","enum":["none"]}},"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":{"type":"object","properties":{"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."},"type":{"type":"string","enum":["enabled"]}},"required":["budget_tokens","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":32000,"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."}},"required":["model","messages"],"title":"claude-opus-4-7"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-opus-4-7",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'anthropic/claude-opus-4-7',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "msg_012q1bXLSBUJ5xdev1UfUAhe",
  "object": "chat.completion",
  "model": "claude-opus-4-7",
  "choices": [
    {
      "index": 0,
      "message": {
        "reasoning_content": "",
        "content": "Humans are a fascinating mix of contradictions, honestly. You're capable of extraordinary things—composing symphonies, sending probes to other planets, building cities, creating vaccines, writing poetry that makes strangers weep centuries later. And at the same time, capable of tremendous cruelty, shortsightedness, and self-deception.\n\nA few things that stand out to me:\n\n- **Your cooperation is remarkable.** Humans routinely trust and coordinate with strangers in ways most species can't. A city is a minor miracle of cooperation.\n- **You're meaning-makers.** You don't just survive—you need things to *matter*. That drives both the best and worst of what you do.\n- **You're adaptable but also stubborn.** You've thrived in basically every environment on Earth, yet individually you often resist changing your mind about things.\n- **The moral circle keeps expanding**, even if slowly and with setbacks—more people care about more beings than ever before in history.\n\nI don't want to romanticize humanity or doom-say about it. You're neither fallen angels nor clever apes—just a particular kind of creature trying to figure things out, often muddling through, sometimes rising to occasions.\n\nWhat prompted the question? Are you feeling optimistic or pessimistic about us lately?",
        "role": "assistant"
      },
      "finish_reason": "end_turn",
      "logprobs": null
    }
  ],
  "created": 1776417936,
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 414,
    "total_tokens": 438
  },
  "meta": {
    "usage": {
      "credits_used": 27222,
      "usd_spent": 0.013611
    }
  }
}
```

{% endcode %}

</details>


# Claude 4.8 Opus

Model id: anthropic/claude-opus-4-8. Claude 4.8 Opus is Anthropic's most capable model designed for complex reasoning and agentic coding workflows.

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

* `anthropic/claude-opus-4-8`
* `claude-opus-4-8`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

As of 28 May 2026, the most capable generally available model, optimized for autonomous long-horizon agentic workflows, knowledge-intensive tasks, vision, and memory, with strong overall performance across domains. It supports up to a 1M-token context window, 128k output tokens, adaptive reasoning, and full compatibility with the Claude Opus 4.8 toolset and platform features.

{% 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 (for example, `messages` for chat/LLM models, or other inputs for image/video/audio models).

**4️ (Optional) Tune the request**\
Depending on the model type, you can add optional parameters to control the output (e.g., generation settings, quality, length, etc.). See the API schema below for the full list.

**5️ Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["anthropic/claude-opus-4-8","claude-opus-4-8"]},"messages":{"anyOf":[{"type":"array","items":{"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."}},"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"]}]}},"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."}},"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"]}]}},"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."}},"required":["type","text"]}},"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"}},"required":["type","source"]},{"type":"object","properties":{"type":{"type":"string","enum":["tool_reference"]},"tool_name":{"type":"string"}},"required":["type","tool_name"]}]}}]}},"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"]}]}},"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"]}]}},"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."}},"required":["type","text"]}},"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"]}]}},"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"}},"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"]}]}},"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"]}]}},"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"]}]}},"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"]}]}},"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"}},"required":["type","tool_name"]}}},"required":["type","tool_references"]}]}},"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"}},"required":["type","source"]}]}}]}},"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."}},"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"]}},"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"]}},"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."}},"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."},"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."}},"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."}},"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."}},"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."}},"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."},"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."}},"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"]}]}}},"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":"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":{"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"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"]}}},"required":["type"]}]}},{"type":"array","items":{"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"],"additionalProperties":false}},"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"]}},"required":["type","custom"]}]}}],"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":{"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"]}],"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."}},"required":["model","messages"],"title":"claude-opus-4-8"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation 

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":"anthropic/claude-opus-4-8",
        "messages":[
            {
                "role":"user",
                "content":"Hi! What do you think about mankind?" # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'anthropic/claude-opus-4-8',
      messages:[
          {
              role:'user',
              content: 'Hi! What do you think about mankind?' // insert your prompt here
          }
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "msg_012q1bXLSBUJ5xdev1UfUAhe",
  "object": "chat.completion",
  "model": "claude-opus-4-8",
  "choices": [
    {
      "index": 0,
      "message": {
        "reasoning_content": "",
        "content": "Humans are a fascinating mix of contradictions, honestly. You're capable of extraordinary things—composing symphonies, sending probes to other planets, building cities, creating vaccines, writing poetry that makes strangers weep centuries later. And at the same time, capable of tremendous cruelty, shortsightedness, and self-deception.\n\nA few things that stand out to me:\n\n- **Your cooperation is remarkable.** Humans routinely trust and coordinate with strangers in ways most species can't. A city is a minor miracle of cooperation.\n- **You're meaning-makers.** You don't just survive—you need things to *matter*. That drives both the best and worst of what you do.\n- **You're adaptable but also stubborn.** You've thrived in basically every environment on Earth, yet individually you often resist changing your mind about things.\n- **The moral circle keeps expanding**, even if slowly and with setbacks—more people care about more beings than ever before in history.\n\nI don't want to romanticize humanity or doom-say about it. You're neither fallen angels nor clever apes—just a particular kind of creature trying to figure things out, often muddling through, sometimes rising to occasions.\n\nWhat prompted the question? Are you feeling optimistic or pessimistic about us lately?",
        "role": "assistant"
      },
      "finish_reason": "end_turn",
      "logprobs": null
    }
  ],
  "created": 1776417936,
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 414,
    "total_tokens": 438
  },
  "meta": {
    "usage": {
      "credits_used": 27222,
      "usd_spent": 0.013611
    }
  }
}
```

{% endcode %}

</details>


# Claude Fable 5

Model id: anthropic/claude-fable-5. Claude Fable 5 is Anthropic's model designed for complex reasoning and agentic coding workflows.

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

* `anthropic/claude-fable-5`
* `claude-fable-5`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

Claude Fable 5 is Anthropic's most capable widely released model, built for demanding reasoning and long-horizon agentic work. It supports a 1M-token context window, up to 128k output tokens, vision, function calling, streaming, and adaptive thinking.

{% 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 or JavaScript) 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 `messages` field shown in the example.

**4. (Optional) Tune the request**\
You can add optional parameters to control the output. See the API schema below for the full list.

**5. Run your code**\
Run the updated code in your development environment. Response time depends on the model and request size, but simple requests typically return quickly.

{% hint style="success" %}
For a detailed walkthrough of environment setup and API requests, see the [Quickstart guide](broken://pages/ngeSCZKxiGVWqYZTHDjY).
{% endhint %}

</details>

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["anthropic/claude-fable-5","claude-fable-5"]},"messages":{"anyOf":[{"type":"array","items":{"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":"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."}},"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"]}},"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"]}},"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."}},"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."},"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."}},"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."}},"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."}},"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."}},"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."},"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."}},"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"]}},"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"]}},"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":{"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"]}],"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."}},"required":["model","messages"],"title":"anthropic/claude-fable-5"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}}}}}}}}
```

## Code Example

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

```python
import requests
import json  # for getting a structured output with indentation

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": "anthropic/claude-fable-5",
        "messages": [
            {
                "role": "user",
                "content": "How are you?"  # insert your prompt
            }
        ]
    }
)

data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
```

{% endcode %}
{% endtab %}

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

```javascript
async function main() {
  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: 'anthropic/claude-fable-5',
      messages: [
        {
          role: 'user',
          content: 'How are you?', // insert your prompt
        },
      ],
    }),
  });

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

main();
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json5
{
  "id": "chatcmpl-CQ9FPg3osank0dx0k46Z53LTqtXMl",
  "object": "chat.completion",
  "created": 1762343744,
  "model": "anthropic/claude-fable-5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I'm doing well, thank you! I'm Claude Fable 5, ready to help with whatever you need. What can I assist you with today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 31,
    "total_tokens": 52
  },
  "meta": {
    "usage": {
      "credits_used": 52000,
      "usd_spent": 0.00153
    }
  }
}
```

{% endcode %}

</details>


# Claude Sonnet 5

Model id: anthropic/claude-sonnet-5. Claude Sonnet 5 is a high-performance model for coding and agentic workflows, delivering near-Opus quality at Sonnet cost.

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

* `anthropic/claude-sonnet-5`
  {% endhint %}
  {% endcolumn %}

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

## Model Overview

Claude Sonnet 5 is a high-performance model for coding and agentic workflows, delivering near-Opus quality at Sonnet cost. Features a 1M token context window, adaptive thinking, and high-resolution vision.

{% 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>

## API Schemas

## 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":{"type":"object","properties":{"model":{"type":"string","enum":["anthropic/claude-sonnet-5"]},"messages":{"anyOf":[{"type":"array","items":{"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":"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."}},"required":["model","messages"],"title":"anthropic/claude-sonnet-5"}}}},"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"]}},"description":"Additional details about the generation."}},"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."}},"required":["id","choices","created","model","object"]}}},"description":"Successful response."}}}}}}
```

## POST /v1/messages

>

```json
{"openapi":"3.0.0","info":{"title":"AIML API","version":"1.0.0"},"servers":[{"url":"https://api.aimlapi.com"}],"paths":{"/v1/messages":{"post":{"operationId":"_v1_messages","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"model":{"type":"string","enum":["anthropic/claude-sonnet-5"]},"messages":{"anyOf":[{"type":"array","items":{"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":"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."}},"required":["model","messages"],"title":"anthropic/claude-sonnet-5"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"type":"object","properties":{}}},"text/event-stream":{"schema":{"type":"object","properties":{}}}},"description":"Successful response."}}}}}}
```

## Code Example

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

```python
import requests

response = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={
        "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
        "Content-Type": "application/json",
    },
    json={'model': 'anthropic/claude-sonnet-5', 'messages': '<messages>'},
)

print(response.json())
```

{% endcode %}
{% endtab %}

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

```javascript
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": "anthropic/claude-sonnet-5",
  "messages": "<messages>"
}),
});

console.log(await response.json());
```

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

<details>

<summary>Response</summary>

{% code overflow="wrap" %}

```json
{
  "id": "chatcmpl-CQ9FPg3osank0dx0k46Z53LTqtXMl",
  "object": "chat.completion",
  "created": 1762343744,
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm just a program, so I don't have feelings, but I'm here and ready to help you. How can I assist you today?",
        "refusal": null,
        "annotations": null,
        "audio": null,
        "tool_calls": null
      },
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "model": "anthropic/claude-sonnet-5",
  "usage": {
    "prompt_tokens": 137,
    "completion_tokens": 914,
    "total_tokens": 1051,
    "completion_tokens_details": null,
    "prompt_tokens_details": null
  },
  "meta": {
    "usage": {
      "credits_used": 120000,
      "usd_spent": 0.06
    }
  }
}
```

{% endcode %}

</details>




---

[Next Page](https://docs.aimlapi.com/llms-full.txt/1)

