Create a chat completion
Generates the next assistant message for a conversation, in the OpenAI Chat Completions format. The operation supports system messages, multi-turn conversations, sampling parameters, stop sequences, streaming, function calling, JSON output, image input and reasoning effort.
Request
POST https://models.convergestudios.ai/v1/chat/completionsThe gateway also accepts the same request at /chat/completions.
A Converge AI Gateway virtual key, sent as Authorization: Bearer <virtual key>. The key is issued per team and is valid only for the model routes of the gateway.
Request body
JSON, with Content-Type: application/json. A dash in the Required column means that requiredness is not stated.
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | — | Model id from `GET /v1/models`, for example `gemini/gemini-3.1-flash-lite`. |
| messages | array | Yes | The conversation. Each item has a `role` (`system`, `user`, `assistant` or `tool`) and `content`. `content` is a string, or an array of parts (`text`, `image_url`) for image input. |
| max_tokens | integer | — | Maximum number of completion tokens. On reasoning models, hidden reasoning tokens count against this limit. |
| temperature | number | — | Sampling temperature. |
| top_p | number | — | Nucleus sampling probability mass. |
| seed | integer | — | Seed for sampling. |
| stop | array | — | Stop sequences. Generation ends before the first stop sequence, and the stop sequence is not part of the output. |
| stream | boolean | — | When `true`, the response is a server-sent event stream of `chat.completion.chunk` objects that ends with `data: [DONE]`. |
| stream_options | object | — | `{"include_usage": true}` adds a final chunk with `usage` before `data: [DONE]`. |
| tools | array | — | Function definitions that the model can call. |
| tool_choice | object | — | Forces a call to the named function. |
| response_format | object | — | `{"type": "json_object"}` for JSON output, or `{"type": "json_schema", "json_schema": {...}}` for output that matches a JSON Schema. |
| reasoning_effort | string | — | Reasoning effort for reasoning models. The values that each model accepts are in `supported_reasoning_efforts` of `GET /model_group/info`. |
| n | integer | — | Number of choices. Only `1` is accepted; a larger value returns `400`. |
Examples
Basic chat completionShow
curl -sS -X POST https://models.convergestudios.ai/v1/chat/completions \
-H "Authorization: Bearer $GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": "Reply with the single word: pong"
}
],
"max_tokens": 10
}'{
"id": "example-1",
"created": 1795612209,
"model": "gemini/gemini-3.1-flash-lite",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "pong",
"role": "assistant",
"images": [],
"thinking_blocks": [],
"provider_specific_fields": {
"thought_signatures": [
"EqkBCqYBAWkU…[truncated 232 chars]"
],
"thinking_blocks": []
}
},
"provider_specific_fields": {}
}
],
"usage": {
"completion_tokens": 1,
"prompt_tokens": 8,
"total_tokens": 9,
"completion_tokens_details": {
"text_tokens": 1
},
"prompt_tokens_details": {
"text_tokens": 8
}
},
"service_tier": "default"
}System messageShow
curl -sS -X POST https://models.convergestudios.ai/v1/chat/completions \
-H "Authorization: Bearer $GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "system",
"content": "You answer in UPPERCASE letters only."
},
{
"role": "user",
"content": "Say hello to Manila in three words."
}
],
"max_tokens": 20,
"temperature": 0
}'{
"id": "example-2",
"created": 1795612295,
"model": "gemini/gemini-3.1-flash-lite",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "HELLO MANILA CITY!",
"role": "assistant",
"images": [],
"thinking_blocks": [],
"provider_specific_fields": {
"thought_signatures": [
"EqkBCqYBAWkU…[truncated 232 chars]"
]
}
},
"provider_specific_fields": {
"native_finish_reason": "STOP"
}
}
],
"usage": {
"completion_tokens": 5,
"prompt_tokens": 17,
"total_tokens": 22,
"completion_tokens_details": {
"text_tokens": 5
},
"prompt_tokens_details": {
"text_tokens": 17
}
},
"service_tier": "default"
}Multi-turn conversationShow
curl -sS -X POST https://models.convergestudios.ai/v1/chat/completions \
-H "Authorization: Bearer $GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": "My name is Ana."
},
{
"role": "assistant",
"content": "Nice to meet you, Ana."
},
{
"role": "user",
"content": "What is my name? Answer with one word."
}
],
"max_tokens": 10,
"temperature": 0
}'{
"id": "example-3",
"created": 1795612299,
"model": "gemini/gemini-3.1-flash-lite",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Ana.",
"role": "assistant",
"images": [],
"thinking_blocks": [],
"provider_specific_fields": {
"thought_signatures": [
"EqkBCqYBAWkU…[truncated 232 chars]"
]
}
},
"provider_specific_fields": {
"native_finish_reason": "STOP"
}
}
],
"usage": {
"completion_tokens": 2,
"prompt_tokens": 25,
"total_tokens": 27,
"completion_tokens_details": {
"text_tokens": 2
},
"prompt_tokens_details": {
"text_tokens": 25
}
},
"service_tier": "default"
}Sampling parameters; output cut at max_tokensShow
curl -sS -X POST https://models.convergestudios.ai/v1/chat/completions \
-H "Authorization: Bearer $GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": "Count from 1 to 50, separated by commas."
}
],
"temperature": 0,
"top_p": 0.9,
"seed": 7,
"max_tokens": 5
}'{
"id": "example-4",
"created": 1795612304,
"model": "gemini/gemini-3.1-flash-lite",
"object": "chat.completion",
"choices": [
{
"finish_reason": "length",
"index": 0,
"message": {
"content": "1",
"role": "assistant",
"images": [],
"thinking_blocks": [],
"provider_specific_fields": {
"thought_signatures": [
"EqkBCqYBAWkU…[truncated 232 chars]"
]
}
},
"provider_specific_fields": {
"native_finish_reason": "MAX_TOKENS"
}
}
],
"usage": {
"completion_tokens": 1,
"prompt_tokens": 14,
"total_tokens": 15,
"completion_tokens_details": {
"text_tokens": 1
},
"prompt_tokens_details": {
"text_tokens": 14
}
},
"service_tier": "default"
}Stop sequenceShow
curl -sS -X POST https://models.convergestudios.ai/v1/chat/completions \
-H "Authorization: Bearer $GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": "Count from 1 to 10, separated by spaces. Output only the numbers."
}
],
"stop": [
"5"
],
"max_tokens": 30,
"temperature": 0
}'{
"id": "example-11",
"created": 1795612240,
"model": "gemini/gemini-3.1-flash-lite",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "1 2 3 4 ",
"role": "assistant",
"images": [],
"thinking_blocks": [],
"provider_specific_fields": {
"thought_signatures": [
"EqkBCqYBAWkU…[truncated 232 chars]"
],
"thinking_blocks": []
}
},
"provider_specific_fields": {}
}
],
"usage": {
"completion_tokens": 8,
"prompt_tokens": 19,
"total_tokens": 27,
"completion_tokens_details": {
"text_tokens": 8
},
"prompt_tokens_details": {
"text_tokens": 19
}
},
"service_tier": "default"
}Streaming with usageShow
curl -sSN -X POST https://models.convergestudios.ai/v1/chat/completions \
-H "Authorization: Bearer $GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": "Count from 1 to 5, separated by spaces."
}
],
"max_tokens": 20,
"stream": true,
"stream_options": {
"include_usage": true
}
}'data: {"id":"example-5","object":"chat.completion.chunk","created":1795612308,"model":"gemini/gemini-3.1-flash-lite","choices":[{"index":0,"delta":{"role":"assistant","content":"1 "}}]}
data: {"id":"example-5","object":"chat.completion.chunk","created":1795612308,"model":"gemini/gemini-3.1-flash-lite","choices":[{"index":0,"delta":{"content":"2 "}}]}
data: {"id":"example-5","object":"chat.completion.chunk","created":1795612308,"model":"gemini/gemini-3.1-flash-lite","choices":[{"index":0,"delta":{"content":"3 "}}]}
data: {"id":"example-5","object":"chat.completion.chunk","created":1795612308,"model":"gemini/gemini-3.1-flash-lite","choices":[{"index":0,"delta":{"content":"4 "}}]}
data: {"id":"example-5","object":"chat.completion.chunk","created":1795612308,"model":"gemini/gemini-3.1-flash-lite","choices":[{"index":0,"delta":{"content":"5"}}]}
data: {"id":"example-5","object":"chat.completion.chunk","created":1795612308,"model":"gemini/gemini-3.1-flash-lite","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"id":"example-5","created":1795612308,"model":"gemini/gemini-3.1-flash-lite","object":"chat.completion.chunk","choices":[{"index":0,"delta":{}}],"usage":{"completion_tokens":9,"prompt_tokens":13,"total_tokens":22,"completion_tokens_details":{"reasoning_tokens":0,"text_tokens":9},"cost":"<number>"}}
data: [DONE]
Function calling: the model calls a toolShow
curl -sS -X POST https://models.convergestudios.ai/v1/chat/completions \
-H "Authorization: Bearer $GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": "What is the weather in Manila right now?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name"
}
},
"required": [
"city"
]
}
}
}
],
"tool_choice": {
"type": "function",
"function": {
"name": "get_weather"
}
},
"max_tokens": 50
}'{
"id": "example-6",
"created": 1795612218,
"model": "gemini/gemini-3.1-flash-lite",
"object": "chat.completion",
"choices": [
{
"finish_reason": "tool_calls",
"index": 0,
"message": {
"role": "assistant",
"tool_calls": [
{
"index": 0,
"provider_specific_fields": {
"thought_signature": "EqkBCqYBAWkU…[truncated 232 chars]"
},
"function": {
"arguments": "{\"city\": \"Manila\"}",
"name": "get_weather"
},
"id": "call_example-1",
"type": "function"
}
],
"images": [],
"thinking_blocks": [],
"provider_specific_fields": {
"thought_signatures": [
"EqkBCqYBAWkU…[truncated 232 chars]"
],
"thinking_blocks": []
},
"content": null
},
"provider_specific_fields": {}
}
],
"usage": {
"completion_tokens": 17,
"prompt_tokens": 62,
"total_tokens": 79,
"completion_tokens_details": {
"text_tokens": 17
},
"prompt_tokens_details": {
"text_tokens": 62
}
},
"service_tier": "default"
}Function calling: the tool result goes backShow
curl -sS -X POST https://models.convergestudios.ai/v1/chat/completions \
-H "Authorization: Bearer $GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": "What is the weather in Manila right now?"
},
{
"role": "assistant",
"tool_calls": [
{
"index": 0,
"provider_specific_fields": {
"thought_signature": "EqkBCqYBAWkU…[truncated 232 chars]"
},
"function": {
"arguments": "{\"city\": \"Manila\"}",
"name": "get_weather"
},
"id": "call_example-1",
"type": "function"
}
],
"images": [],
"thinking_blocks": [],
"provider_specific_fields": {
"thought_signatures": [
"EqkBCqYBAWkU…[truncated 232 chars]"
],
"thinking_blocks": []
},
"content": null
},
{
"role": "tool",
"tool_call_id": "call_example-1",
"content": "{\"temp_c\":31,\"condition\":\"sunny\"}"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name"
}
},
"required": [
"city"
]
}
}
}
],
"max_tokens": 40
}'{
"id": "example-7",
"created": 1795612317,
"model": "gemini/gemini-3.1-flash-lite",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "The weather in Manila is currently sunny with a temperature of 31°C.",
"role": "assistant",
"images": [],
"thinking_blocks": [],
"provider_specific_fields": {
"thought_signatures": [
"EqkBCqYBAWkU…[truncated 232 chars]"
]
}
},
"provider_specific_fields": {
"native_finish_reason": "STOP"
}
}
],
"usage": {
"completion_tokens": 17,
"prompt_tokens": 100,
"total_tokens": 117,
"completion_tokens_details": {
"text_tokens": 17
},
"prompt_tokens_details": {
"text_tokens": 100
}
},
"service_tier": "default"
}JSON output (json_object)Show
curl -sS -X POST https://models.convergestudios.ai/v1/chat/completions \
-H "Authorization: Bearer $GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": "Return a JSON object with the keys city and country for Manila."
}
],
"response_format": {
"type": "json_object"
},
"max_tokens": 40
}'{
"id": "example-8",
"created": 1795612322,
"model": "gemini/gemini-3.1-flash-lite",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "{\n \"city\": \"Manila\",\n \"country\": \"Philippines\"\n}",
"role": "assistant",
"images": [],
"thinking_blocks": [],
"provider_specific_fields": {
"thought_signatures": [
"EqkBCqYBAWkU…[truncated 232 chars]"
]
}
},
"provider_specific_fields": {
"native_finish_reason": "STOP"
}
}
],
"usage": {
"completion_tokens": 20,
"prompt_tokens": 14,
"total_tokens": 34,
"completion_tokens_details": {
"text_tokens": 20
},
"prompt_tokens_details": {
"text_tokens": 14
}
},
"service_tier": "default"
}Structured output (json_schema)Show
curl -sS -X POST https://models.convergestudios.ai/v1/chat/completions \
-H "Authorization: Bearer $GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": "Give the city name and the approximate population of Manila city proper."
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "city_population",
"strict": true,
"schema": {
"type": "object",
"properties": {
"city": {
"type": "string"
},
"population": {
"type": "integer"
}
},
"required": [
"city",
"population"
],
"additionalProperties": false
}
}
},
"max_tokens": 200
}'{
"id": "example-9",
"created": 1795612326,
"model": "gemini/gemini-3.1-flash-lite",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "{\n \"city\": \"Manila\",\n \"population\": 1846513\n}",
"role": "assistant",
"images": [],
"thinking_blocks": [],
"provider_specific_fields": {
"thought_signatures": [
"EqkBCqYBAWkU…[truncated 232 chars]"
]
}
},
"provider_specific_fields": {
"native_finish_reason": "STOP"
}
}
],
"usage": {
"completion_tokens": 25,
"prompt_tokens": 14,
"total_tokens": 39,
"completion_tokens_details": {
"text_tokens": 25
},
"prompt_tokens_details": {
"text_tokens": 14
}
},
"service_tier": "default"
}Image inputShow
curl -sS -X POST https://models.convergestudios.ai/v1/chat/completions \
-H "Authorization: Bearer $GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What colour is this image? Answer with one word."
},
{
"type": "image_url",
"image_url": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAFklEQVR42mP4z8BAEmIY1TCqYfhqAACQ+f8B8u7oVwAAAABJRU5ErkJggg=="
}
}
]
}
],
"max_tokens": 10,
"temperature": 0
}'{
"id": "example-10",
"created": 1795612231,
"model": "gemini/gemini-3.1-flash-lite",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Red",
"role": "assistant",
"images": [],
"thinking_blocks": [],
"provider_specific_fields": {
"thought_signatures": [
"EqkBCqYBAWkU…[truncated 232 chars]"
],
"thinking_blocks": []
}
},
"provider_specific_fields": {}
}
],
"usage": {
"completion_tokens": 1,
"prompt_tokens": 1101,
"total_tokens": 1102,
"completion_tokens_details": {
"text_tokens": 1
},
"prompt_tokens_details": {
"text_tokens": 12,
"image_tokens": 1089
}
},
"service_tier": "default"
}Reasoning effortShow
curl -sS -X POST https://models.convergestudios.ai/v1/chat/completions \
-H "Authorization: Bearer $GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": "What is 17 * 23? Answer with the number only."
}
],
"reasoning_effort": "low",
"max_tokens": 400
}'{
"id": "example-12",
"created": 1795612245,
"model": "gemini/gemini-3.1-flash-lite",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "391",
"role": "assistant",
"images": [],
"reasoning_content": "Here's my thought process on this straightforward calculation:\n\n**Calculating the Product of 17 and 23**\n\nOkay, so the user wants the result of 17 multiplied by 23, and they're specifically asking for just the numerical answer. No problem.\n\nMy first step is to recognize the prompt and confirm the calculation needed. It's a simple multiplication, but I want to be sure I understand the intent, which is to return the product only.\n\nNext, I'll run the calculation. I'll use a distribution method which, although not the fastest for me, is useful to display the underlying steps.\n\nMy approach will be to break down 23 into (20 + 3), then multiply 17 by each part:\n\n* 17 * 20 = 340\n* 17 * 3 = 51\n\nFinally, I'll sum the results: 340 + 51, to get 391. I could have used a different method, such as carrying out the calculation directly. However, the distribution method provides good clarity.\n\n\n",
"thinking_blocks": [
{
"type": "thinking",
"thinking": "Here's my thought process on this straightforward calculation:\n\n**Calculating the Product of 17 and 23**\n\nOkay, so the user wants the result of 17 multiplied by 23, and they're specifically asking for just the numerical answer. No problem.\n\nMy first step is to recognize the prompt and confirm the calculation needed. It's a simple multiplication, but I want to be sure I understand the intent, which is to return the product only.\n\nNext, I'll run the calculation. I'll use a distribution method which, although not the fastest for me, is useful to display the underlying steps.\n\nMy approach will be to break down 23 into (20 + 3), then multiply 17 by each part:\n\n* 17 * 20 = 340\n* 17 * 3 = 51\n\nFinally, I'll sum the results: 340 + 51, to get 391. I could have used a different method, such as carrying out the calculation directly. However, the distribution method provides good clarity.\n\n\n"
}
],
"provider_specific_fields": {
"thought_signatures": [
"EoMECoAEAWkU…[truncated 692 chars]"
],
"thinking_blocks": [
{
"type": "thinking",
"thinking": "Here's my thought process on this straightforward calculation:\n\n**Calculating the Product of 17 and 23**\n\nOkay, so the user wants the result of 17 multiplied by 23, and they're specifically asking for just the numerical answer. No problem.\n\nMy first step is to recognize the prompt and confirm the calculation needed. It's a simple multiplication, but I want to be sure I understand the intent, which is to return the product only.\n\nNext, I'll run the calculation. I'll use a distribution method which, although not the fastest for me, is useful to display the underlying steps.\n\nMy approach will be to break down 23 into (20 + 3), then multiply 17 by each part:\n\n* 17 * 20 = 340\n* 17 * 3 = 51\n\nFinally, I'll sum the results: 340 + 51, to get 391. I could have used a different method, such as carrying out the calculation directly. However, the distribution method provides good clarity.\n\n\n"
}
]
}
},
"provider_specific_fields": {}
}
],
"usage": {
"completion_tokens": 142,
"prompt_tokens": 17,
"total_tokens": 159,
"completion_tokens_details": {
"reasoning_tokens": 139,
"text_tokens": 3
},
"prompt_tokens_details": {
"text_tokens": 17
}
},
"service_tier": "default"
}Response
200. The assistant message in choices[0].message, the reason that generation stopped in choices[0].finish_reason (stop, length or tool_calls), and token counts in usage.
| Field | Type | Description |
|---|---|---|
| id | string | — |
| created | integer | — |
| model | string | — |
| object | string | — |
| choices[] | array | — |
| choices[].finish_reason | string | — |
| choices[].index | integer | — |
| choices[].message | object | — |
| choices[].message.content | null | string | — |
| choices[].message.role | string | — |
| choices[].message.images[] | array | — |
| choices[].message.thinking_blocks[] | array | — |
| choices[].message.provider_specific_fields | object | — |
| choices[].message.tool_calls[] | array | — |
| choices[].message.tool_calls[].index | integer | — |
| choices[].message.tool_calls[].provider_specific_fields | object | — |
| choices[].message.tool_calls[].function | object | — |
| choices[].message.tool_calls[].id | string | — |
| choices[].message.tool_calls[].type | string | — |
| choices[].message.reasoning_content | string | — |
| choices[].provider_specific_fields | object | — |
| usage | object | — |
| usage.completion_tokens | integer | — |
| usage.prompt_tokens | integer | — |
| usage.total_tokens | integer | — |
| usage.completion_tokens_details | object | — |
| usage.completion_tokens_details.text_tokens | integer | — |
| usage.completion_tokens_details.reasoning_tokens | integer | — |
| usage.prompt_tokens_details | object | — |
| usage.prompt_tokens_details.text_tokens | integer | — |
| usage.prompt_tokens_details.image_tokens | integer | — |
| service_tier | string | — |
Response headers
| Header | Description | Example |
|---|---|---|
| x-litellm-call-id | Identifier of this call on the gateway. Quote it in a support request. | — |
| x-litellm-model-group | The model id that served the call, as sent in model. | gemini/gemini-3.1-flash-lite |
| x-litellm-response-cost | Spend of this call, as a decimal number in the unit of the team budget. Some responses do not carry this header, for example streamed responses. | — |
| x-litellm-key-spend | Approximate spend of the key, as a decimal number in the unit of the team budget. The value is the spend cached on the gateway replica that served the call, plus the spend of this call. The cached part lags behind the real total and can differ between replicas. Do not use it as an exact balance. | — |
| x-ratelimit-limit-requests | Request limit per minute of the deployment that served the call. | 15 |
| x-ratelimit-remaining-requests | Requests that remain in the current minute on the deployment that served the call. | 11 |
| x-ratelimit-limit-tokens | Token limit per minute of the deployment that served the call. | 250000 |
| x-ratelimit-remaining-tokens | Tokens that remain in the current minute on the deployment that served the call. | 249982 |
Errors
400The body is not valid JSONinvalid_request_error
{"model":"gemini/gemini-3.1-flash-lite","messages":{
"error": {
"message": "Invalid JSON payload: unexpected end of data: line 1 column 52 (char 51)",
"type": "invalid_request_error",
"param": "request_body",
"code": "400"
}
}400A required parameter is missinginvalid_request_error
{
"model": "gemini/gemini-3.1-flash-lite"
}{
"error": {
"message": "/chat/completions: Missing required parameter: 'messages'.",
"type": "invalid_request_error",
"param": "messages",
"code": "400"
}
}400n is larger than 1invalid_request_error
{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": "Name one colour. One word."
}
],
"n": 2,
"max_tokens": 5,
"temperature": 1
}{
"error": {
"message": "Multiple candidates is not enabled for this model",
"type": "invalid_request_error",
"param": null,
"code": "400"
}
}401No keyauth_error
{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": "hi"
}
],
"max_tokens": 5
}{
"error": {
"message": "Authentication Error, No api key passed in.",
"type": "auth_error",
"param": "None",
"code": "401"
}
}401Unknown keytoken_not_found_in_db
{
"model": "gemini/gemini-3.1-flash-lite",
"messages": [
{
"role": "user",
"content": "hi"
}
],
"max_tokens": 5
}{
"error": {
"message": "Authentication Error, Invalid proxy server token passed.",
"type": "token_not_found_in_db",
"param": "key",
"code": "401"
}
}403Model not available to the keyteam_model_access_denied
{
"model": "no-such-model",
"messages": [
{
"role": "user",
"content": "hi"
}
],
"max_tokens": 5
}{
"error": {
"message": "The requested model 'no-such-model' is not available for this API key, or the model name is invalid. Check the models available to you and try again.",
"type": "team_model_access_denied",
"param": "model",
"code": "403"
}
}422Team budget exceededbudget_exceeded
{
"error": {
"message": "Budget has been exceeded! Team=<team id> Current cost: <spend>, Max budget: <budget>",
"type": "budget_exceeded",
"param": null,
"code": "422"
}
}Behaviour
The assistant message that requests a tool call carries opaque signature data in tool_calls[].id and in provider_specific_fields. Send that message back exactly as received, followed by the tool message with the same tool_call_id. Do not rebuild the assistant message from its parts.
Reasoning models spend completion tokens on hidden reasoning before the visible answer. These tokens count against max_tokens and appear in usage.completion_tokens_details.reasoning_tokens. When max_tokens is small, a reasoning model can use the full limit on reasoning and return finish_reason: "length" with no content. Set max_tokens high enough for reasoning and the answer, or lower reasoning_effort.
On some models, reasoning_effort: "none" still produces a small number of reasoning tokens.
A streamed response has no usage unless the request sets stream_options.include_usage to true. With it, the last chunk before data: [DONE] carries usage and an empty choices[0].delta.
