import type * as SarvamAI from "../../../../index.mjs"; /** * @example * { * "x-session-affinity": "3f9c2b1e-7a4d-4e8b-9c1a-2d5e6f7a8b9c", * messages: [{ * role: "user", * content: "Summarise the causes of the 2008 financial crisis." * }], * model: "glm5.3" * } */ export interface CreateChatCompletionV2Request { /** Optional session ID for a multi-turn conversation. Send the same value on every turn of a conversation so the turns are routed together and can reuse cached prompt context, which lowers latency on later turns. Use a new value for each conversation. The ID is scoped to your API subscription and is never shared with other customers. Use an opaque value such as a UUID, and do not put personal data in it. Requests without this header are unaffected. */ "x-session-affinity"?: string; /** Non-empty conversation history. Roles: `system`, `developer`, `user`, `assistant`, `tool`. Content is a string or an array of parts (`text`, `image_url`). Images must use inline `data:image/…;base64,…` URLs — remote HTTP(S) image URLs are rejected. */ messages: SarvamAI.ChatCompletionRequestMessage[]; model: SarvamAI.V2ModelIds; /** Sampling temperature from `0` to `2`. Higher values increase variation; lower values focus the output. Output is not guaranteed to be identical across requests, even at `0`. Prefer changing either `temperature` or `top_p`, not both. */ temperature?: number; /** Nucleus sampling: greater than `0` and at most `1`. On `glm5.3`, `top_p: 0` is rejected. Prefer changing either `top_p` or `temperature`, not both. */ top_p?: number; /** On reasoning models: **`low`**, **`high`**, or **`max`** on every reasoning model, and **`medium`** on `sarvam-105b`, `deepseekv4.1-flash-1017`, `deepseekv4.1-flash-1017-interactive`, `deepseekv4-pro`, `kimi-k3.1-pro`, and `qwen38-27b` (`kimi-k3.1-pro` runs `medium` as `high`). Default when omitted is **`max`** on `glm5.3` and `kimi-k3.1-pro`, **`high`** on `glm5.3-flash`, `deepseekv4.1-flash-1017`, `deepseekv4.1-flash-1017-interactive`, and `deepseekv4-pro`, and no reasoning on `gemma4`; `qwen38-27b` thinks by default. **`none`** turns thinking off on `deepseekv4.1-flash-1017`, `deepseekv4.1-flash-1017-interactive`, `deepseekv4-pro`, and `qwen38-27b`. `kimi-k3.1-pro` always thinks: `none`, `minimal`, and `xhigh` return `400`. Trace in `message.reasoning_content`; billed as completion tokens and counts toward `max_tokens`. On `gemma4`, reasoning is off unless this is set (`low`, `high`, or `max`). */ reasoning_effort?: SarvamAI.ReasoningEffort; /** Maximum tokens to generate in the completion, including reasoning tokens on reasoning models. Default `2048`. Set explicitly when you need longer answers — a low limit can yield `finish_reason: "length"` with little or no visible `content` if reasoning consumes the budget. */ max_tokens?: number; /** Optional. Default `false` — omit or `false` for one JSON response. If `true`, the response is streamed as server-sent events and ends with a `[DONE]` line. Use `stream_options.include_usage: true` to receive a final usage chunk (including `reasoning_tokens`). That chunk has an empty `choices` array — do not assume `choices[0]` is present on every event. */ stream?: boolean; stop?: SarvamAI.StopConfiguration; /** Number of chat completion choices. Only `1` is supported (the default); values above `1` return `400 invalid_request_error`. Send separate requests for more completions. */ n?: number; /** Optional integer seed for OpenAI SDK compatibility. */ seed?: number; /** * 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. */ frequency_penalty?: number; /** * Number between -2.0 and 2.0. 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. */ presence_penalty?: number; /** A list of tools the model may call. Currently, only functions are supported as a tool. */ tools?: SarvamAI.ChatCompletionTool[]; /** Controls tool calling: `auto`, `none`, `required`, or a named function object. `required` with an empty `tools` array returns `400`. A named function that is not listed in `tools` returns `400`. */ tool_choice?: SarvamAI.ToolChoiceOption; /** An object specifying the format that the model must output. Setting `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which guarantees the model generates output matching the supplied JSON Schema. Setting `{ "type": "json_object" }` enables the older JSON mode, which guarantees valid JSON but not a specific schema. */ response_format?: SarvamAI.ResponseFormat; /** Additional model-specific options merged into the request. Must not duplicate a top-level field documented on this endpoint; duplicates return `400 invalid_request_error`. */ extra_body?: Record; /** Top-k sampling. Omit or set to `-1` to disable. Values `>= 1` enable top-k; `0` is rejected. There is no documented upper bound. */ top_k?: number; /** Repetition penalty. Must be greater than 0 and at most 2. `0` and values above 2 are `400`. */ repetition_penalty?: number; /** **`false`** limits a turn to a single tool call on every model. */ parallel_tool_calls?: boolean; /** Only valid with `stream: true` (otherwise `400`). Must be a top-level field, not inside `extra_body`. Use `{"include_usage": true}` to receive token usage in the final SSE chunk. */ stream_options?: SarvamAI.ChatStreamOptions; /** If `true`, return log probabilities for output tokens (use with `top_logprobs`). Supported on **`sarvam-105b`**, **`gemma4`**, **`glm5.3-flash`**, **`deepseekv4.1-flash-1017`**, **`deepseekv4.1-flash-1017-interactive`**, **`deepseekv4-pro`**, and **`qwen38-27b`**. Not supported on **`glm5.3`** or **`kimi-k3.1-pro`** (`400` if enabled). */ logprobs?: boolean; /** How many top token log probabilities to return at each position. Takes effect only when `logprobs` is `true`; without it, some models ignore the field and others return **`400`**. Same model support as `logprobs`: works on `sarvam-105b`, `gemma4`, `glm5.3-flash`, `deepseekv4.1-flash-1017`, `deepseekv4.1-flash-1017-interactive`, `deepseekv4-pro`, and `qwen38-27b`; on `glm5.3` and `kimi-k3.1-pro`, omit entirely — do not send `0`, since many SDKs add it by default. */ top_logprobs?: number; }