Function calling, structured output and vision
The gateway does not translate a request body: the fields tools and tool_choice, response_format (including json_schema) and image_url parts reach the model's vendor as you sent them, and the vendor's answer comes back as it is. So a model that has these capabilities at its own vendor has them here; which of them a given model accepts is up to its vendor. Server-side tools are a separate matter: only the ones whose cost can be metered are allowed.
Last updated:
What passes through
| Capability | Fields | Route |
|---|---|---|
| Function calling | Fields:tools (type: "function"), tool_choice, parallel_tool_calls | Route:/v1/chat/completions, /v1/responses |
| Structured output | Fields:response_format (json_object, json_schema) | Route:/v1/chat/completions |
| Vision | Fields:An image_url part in content (a URL or a data URL) | Route:/v1/chat/completions |
| Audio input | Fields:An input_audio part in content | Route:/v1/chat/completions |
| Reasoning parameters | Fields:reasoning_effort, reasoning | Route:/v1/chat/completions, /v1/responses |
| Anthropic tools | Fields:tools, tool_choice, thinking, cache_control | Route:/anthropic/v1/messages |
| Gemini tools | Fields:tools.functionDeclarations, generationConfig.responseSchema | Route:/gemini/v1beta/models/{model}:generateContent |
- The only changes the gateway makes to a body are in this list. One of them matters here: for DeepSeek models,
json_schemabecomesjson_object(state the schema in the prompt as well). - When a model does not accept a field, the vendor's own error reaches you with its status, and nothing is billed.
- Images and files inside a request count toward the body size.
Example: function calling
curl https://1xai.ir/v1/chat/completions \
-H "Authorization: Bearer 1xai-..." \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5-mini",
"messages": [{"role": "user", "content": "What is the weather in Tehran?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}],
"tool_choice": "auto"
}'The answer has the function's name and arguments in choices[0].message.tool_calls. Run the function yourself and return its result in a message with the role tool and the same tool_call_id.
Example: structured output
curl https://1xai.ir/v1/chat/completions \
-H "Authorization: Bearer 1xai-..." \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5-mini",
"messages": [{"role": "user", "content": "Give the title and year of one famous book."}],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "book",
"strict": true,
"schema": {
"type": "object",
"properties": {"title": {"type": "string"}, "year": {"type": "integer"}},
"required": ["title", "year"],
"additionalProperties": false
}
}
}
}'Example: vision
curl https://1xai.ir/v1/chat/completions \
-H "Authorization: Bearer 1xai-..." \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.5-flash",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,/9j/4AAQ..."}}
]
}]
}'Send the image as a data URL (base64), so that you do not depend on a URL being reachable from the vendor's side. The whole request body may be up to 25 MiB.
Hosted (server-side) tools
A hosted tool is one the vendor runs itself and charges for apart from tokens. Only the ones whose cost we can meter exactly are allowed; the rest are refused before anything is sent, and cost nothing.
| Route | Allowed | Refused |
|---|---|---|
/v1/chat/completions | Allowed:Function tools (function, custom); the web_search_options field | Refused:Any other tool type |
/v1/responses | Allowed:Function tools and web_search | Refused:code_interpreter, file_search, image_generation, computer_use, mcp |
/anthropic/v1/messages | Allowed:Your own tools, and web_search, web_fetch, bash, text_editor, computer and memory | Refused:code_execution |
/gemini/…:generateContent | Allowed:functionDeclarations and Google Search grounding | Refused:Google Maps grounding |
- Web search is billed per search at the model's search rate. Before the call the price of a few searches (up to 3 on OpenAI and Anthropic) is held, and after the answer the searches actually made are charged.
- A model with no search rate answers
400with codesearch_not_pricedwhen a search tool is requested. - A refused tool answers
400with codehosted_tool_unmetered(on Gemini, Google Maps grounding answers402with the same code). - The Anthropic tools
bash,text_editor,computerandmemoryare executed by your own application; they cost tokens only.
1xAi is an independent gateway. It is not affiliated with, endorsed by, or a reseller for OpenAI, Anthropic, Google, DeepSeek, xAI, Moonshot AI, Z.ai, Alibaba Qwen, MiniMax or Tencent Hunyuan. Requests are relayed upstream rather than answered by models of our own, so each provider's own usage policies apply to what their models will and will not do, and their model availability is theirs to change. Current reachability is published on the status page.