> This page is for Model APIs.

> Sarvam Voice Agents (Samvaad) is a voice AI agent platform for Indian languages: build, test and deploy AI calling agents on your own phone numbers, from ₹3 a minute. Start here: https://docs.sarvam.ai/voice-agents/why-voice-agents.
> For clean Markdown of any page, append `.md` to the page URL.
> For a complete documentation index, see https://docs.sarvam.ai/llms.txt. For a section index, append `/llms.txt` to any section URL (for example https://docs.sarvam.ai/voice-agents/llms.txt).
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server.

# Responses API

> Create stateless text, reasoning, structured-output, and tool-calling responses with Sarvam's OpenAI-compatible Responses API.

The Responses API provides an OpenAI-compatible interface for text generation,
reasoning, structured output, and tool calling. **Streaming is optional**: the same
pattern as [Chat Completion V2](/api-reference/chat/chat-completions-v2): omit `stream`
or set it to `false` for one JSON response (default).

> **Note**
>
> The Responses API supports `sarvam-105b`, `glm5.3`, `glm5.3-flash`, and `gemma4`,
> plus the [beta models](/api-reference/beta-apis) `deepseekv4.1-flash-1017`, `deepseekv4-pro`,
> `kimi-k3`, `mimo-v2.6-flash`, and `mimo-v2.6-pro`.

> **Tip**
>
> Moving Responses API code from [OpenRouter](/api/token-factory/migrations/from-openrouter/responses-api) or [Fireworks AI](/api/token-factory/migrations/from-fireworks/responses-api)? See the Responses API migration guides.

## Create a response

Use [`POST /v2/responses`](/api-reference/responses/create). The endpoint is **stateless**:
send the complete conversation in `input` on every request. Omit `store` or set it to
`false` (`true` returns **`400`**).

Nothing is stored for later retrieval, `GET /v2/responses/{id}` returns **`404`**.
`GET /v2/responses` and `DELETE /v2/responses/{id}` return **`405`** (documented in the
[API Reference](/api-reference/responses/create) alongside `POST /v2/responses`).

#### Python

```python
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")

response = client.responses.create(
    model="glm5.3",
    input="Explain database indexing in three short points.",
    store=False,
)

print(response.output)
```

#### JavaScript

```javascript
import { SarvamAIClient } from "sarvamai";

const client = new SarvamAIClient({
    apiSubscriptionKey: "YOUR_SARVAM_API_KEY",
});

async function main() {
    const response = await client.responses.create({
        model: "glm5.3",
        input: "Explain database indexing in three short points.",
        store: false,
    });

    console.log(response.output);
}

main();
```

#### cURL

```bash
curl -X POST https://api.sarvam.ai/v2/responses \
  -H "api-subscription-key: $SARVAM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm5.3",
    "input": "Explain database indexing in three short points.",
    "store": false
  }'
```

> **Note**
>
> The examples above do **not** set `stream`. That returns a single JSON body (**HTTP 200**),
> same as Chat Completion V2 when `stream` is omitted. Only add `"stream": true` when you
> want server-sent events.

## Stream a response (optional)

Set `stream` to `true` when you want named server-sent events instead of one JSON body. Streams end with
`response.completed`, `response.incomplete`, or `response.failed`; they do **not** emit a
`[DONE]` sentinel. On `glm5.3`, streamed items can **nest**: pair events by `item_id`.
Usage appears on the terminal event (there is no `stream_options`).

#### Python

```python
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")

stream = client.responses.create(
    model="glm5.3",
    input="Explain database indexing in three short points.",
    store=False,
    stream=True,
)

for event in stream:
    print(event.type)
```

#### JavaScript

```javascript
import { SarvamAIClient } from "sarvamai";

const client = new SarvamAIClient({
    apiSubscriptionKey: "YOUR_SARVAM_API_KEY",
});

async function main() {
    const stream = await client.responses.create({
        model: "glm5.3",
        input: "Explain database indexing in three short points.",
        store: false,
        stream: true,
    });

    for await (const event of stream) {
        console.log(event.type);
    }
}

main();
```

#### cURL

```bash
curl -N -X POST https://api.sarvam.ai/v2/responses \
  -H "api-subscription-key: $SARVAM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm5.3",
    "input": "Explain database indexing in three short points.",
    "store": false,
    "stream": true
  }'
```

## Continue a conversation

The endpoint does not store response state. To continue a conversation, send the prior
messages and outputs again in `input`. Do not use `previous_response_id` or `conversation`
, both return **`400`**.

```python
from sarvamai import SarvamAI

client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")

response = client.responses.create(
    model="gemma4",
    input=[
        {"role": "user", "content": "Name one advantage of a B-tree index."},
        {"role": "assistant", "content": "It keeps lookups efficient as data grows."},
        {"role": "user", "content": "When should I avoid one?"},
    ],
    store=False,
)
```

For message parts in `input`, text uses `{"type": "input_text", "text": "…"}` (not chat
completions' `{"type": "text"}`).

## Reasoning

The reasoning models (`glm5.3`, `glm5.3-flash`, `gemma4`, `deepseekv4.1-flash-1017`,
`deepseekv4-pro`, `kimi-k3`, `mimo-v2.6-flash`, and `mimo-v2.6-pro`) support three modes, `low`, `high`, and `max`, and Chat
Completion V2 accepts all three directly. `gemma4` reasons only when you set an effort. On this route (Responses), the models
differ:

| Model                              | Accepted `reasoning.effort` values on this route                                                                                             |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `glm5.3`, `glm5.3-flash`           | `"low"` or `"high"` only; the literal string `"max"` returns `400`. Omitting the field gives `max` on `glm5.3` and `high` on `glm5.3-flash`. |
| `gemma4`                           | `"low"` or `"high"`. No reasoning when the field is omitted.                                                                                 |
| `deepseekv4.1-flash-1017`          | `"low"`, `"high"`, or `"max"`, all three work directly, same as on chat. Default `high`. `"none"` turns thinking off.                        |
| `deepseekv4-pro`                   | `"low"`, `"high"`, or `"max"`; default `high`. `"none"` turns thinking off.                                                                  |
| `kimi-k3`                          | `"low"`, `"high"`, or `"max"`; default `max`. Thinking is always on.                                                                         |
| `mimo-v2.6-flash`, `mimo-v2.6-pro` | Thinking is on by default. `"none"` turns it off; any other value only switches it on.                                                       |

**Chat trace:** `choices[].message.reasoning_content`.

**Responses trace:** reasoning models return a **`reasoning` item** in `output` when they
reason. Read the trace from its **`content[0].text`**. Its `summary` is empty unless you set the
optional **`reasoning.summary`** to `auto` or `detailed`. At `low` effort, `glm5.3` often skips
reasoning on simple prompts and returns no reasoning item. `gemma4` reasons when you set an
effort but doesn't return a reasoning item; its reasoning shows only in
`usage.output_tokens_details.reasoning_tokens`.

Reasoning tokens count toward **`max_output_tokens`**, which has **no default cap** on
this route, omitting it means unbounded generation. On chat, the equivalent budget is
**`max_tokens`**, which defaults to `2048` on `glm5.3` only. Set it explicitly. See the
[Chat Completion V2 API Reference](/api-reference/chat/chat-completions-v2).

## Defaults when omitted (`glm5.3`)

| Field               | Default when omitted             |
| ------------------- | -------------------------------- |
| `temperature`       | `1`                              |
| `top_p`             | `0.95`                           |
| `max_output_tokens` | No default, unbounded generation |
| `stream`            | `false`                          |

## Parameters

| Parameter             | Required | Description                                                                                                                                                                                                                                            |
| --------------------- | -------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `model`               |      Yes | `sarvam-105b`, `glm5.3`, `glm5.3-flash`, `gemma4`, `deepseekv4.1-flash-1017`, `deepseekv4-pro`, `kimi-k3`, `mimo-v2.6-flash`, or `mimo-v2.6-pro`.                                                                                                      |
| `input`               |      Yes | A prompt string or the complete conversation as input items.                                                                                                                                                                                           |
| `stream`              |       No | Optional, omit or `false` for one JSON body (default **`false`** on `glm5.3`); `true` for named SSE events, same pattern as chat completions.                                                                                                          |
| `max_output_tokens`   |       No | Cap on generated tokens including reasoning. **No default**: omitting it means unbounded generation. Always set this explicitly in production.                                                                                                         |
| `temperature`         |       No | `0`–`2`; default **`1`** on `glm5.3`.                                                                                                                                                                                                                  |
| `top_p`               |       No | Default **`0.95`** on `glm5.3`; must be > `0`.                                                                                                                                                                                                         |
| `top_k`               |       No | Not supported on `glm5.3`; any value returns `400`.                                                                                                                                                                                                    |
| `reasoning`           |       No | Optional on reasoning models. `effort` accepts `"low"` or `"high"` on `glm5.3` (omit for `max`, the string `"max"` is `400`), or all three values directly on `deepseekv4.1-flash-1017` (omit for `high`). `summary` accepts `"auto"` or `"detailed"`. |
| `text`                |       No | Output format in `text.format` (`text`, `json_object`, `json_schema`).                                                                                                                                                                                 |
| `tools`               |       No | **Flat** function tools (`name` at the top level). Nested chat tool shape is **`400`**.                                                                                                                                                                |
| `tool_choice`         |       No | `auto`, `none`, `required`, or a named function.                                                                                                                                                                                                       |
| `parallel_tool_calls` |       No | **`false`** limits a turn to one tool call on every open-weight model. `sarvam-105b` ignores it on this route.                                                                                                                                         |
| `n`                   |       No | Not supported on the open-weight models: any value, even `1`, returns `400`.                                                                                                                                                                           |
| `store`               |       No | Must be omitted or `false`.                                                                                                                                                                                                                            |

### Refused or unsupported on this route

These return **`400`** (the error names the field): `store: true`, `background: true`,
`previous_response_id`, `conversation`, `max_tool_calls`, `prompt`, `item_reference`.

On Responses, the open-weight models return `400` for `logprobs` and `repetition_penalty`.
For log probabilities on `glm5.3-flash` and `deepseekv4.1-flash-1017`, send `top_logprobs` with
`include: ["message.output_text.logprobs"]` instead; `glm5.3` and `gemma4` don't support them on
this route. On Chat Completion V2, `logprobs` and
`top_logprobs` are supported on every model except `glm5.3`, which returns a clean `400`. See
[Chat Completion V2](/api-reference/chat/chat-completions-v2) for details.

See the [Responses API Reference](/api-reference/responses/create) for the complete
request, response, error, and streaming-event schemas. Model-specific limits for
`glm5.3` are also summarized on the [GLM-5.3 model page](/api/token-factory/models/glm-5-3).