Request parameters
AuthorizationstringRequiredBearer sk-zerofa-xxxContent-TypestringRequiredapplication/jsonmodelstringRequiredyour-chat-model-idmessagesarrayRequired[{"role":"user","content":"hi"}]streambooleanOptionalfalsetemperaturenumber 0–2Optional1.0top_pnumber 0–1Optional1.0max_tokensintegerOptional1024stopstring | string[]Optionaltools / tool_choicearray / string|objectOptionalresponse_formatobjectOptionalreasoning_effortstringOptionalmediumuserstringOptional{
"model": "your-chat-model-id",
"messages": [
{
"role": "user",
"content": "Hello, introduce yourself"
}
],
"stream": false,
"temperature": 1,
"max_tokens": 1024
}Function calling
Send tools and tool_choice in the OpenAI format. ZeroFA translates Claude and Gemini requests to their native formats and converts responses back to tool_calls. Streaming, non-streaming, and multi-turn tool results are supported.
{
"model": "your-chat-model-id",
"messages": [{"role": "user", "content": "What is the weather in Beijing?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}],
"tool_choice": "auto"
}When the model calls a tool, finish_reason is tool_calls and the call appears in message.tool_calls.
"message": {
"role": "assistant",
"content": "",
"tool_calls": [{
"id": "call_abc",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"city\":\"Beijing\"}"
}
}]
}After executing the tool, send its result as a role: tool message with tool_call_id, together with the previous assistant tool_calls, so the model can continue.
Multimodal image input
messages[].content can be an array mixing text and image_url parts. Images can use data URLs or public URLs, and Claude and Gemini protocols are translated automatically.
{
"model": "your-chat-model-id",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url",
"image_url": {"url": "data:image/png;base64,..."}}
]
}]
}Check the Vision capability badge on a model card to confirm image support.
Streaming responses (SSE)
With stream: true, the endpoint returns text/event-stream. Each chunk is a data: {...} line and the stream ends with data: [DONE].
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]Available models
Every chat model works through this endpoint; change only model to switch. See the complete list and prices in the Model Catalog, or retrieve them with GET /v1/models.
Common errors
See Errors and billing for complete details. Common errors include:
400 model_not_allowed— The model does not exist or the current plan cannot use it402 insufficient_credits— The wallet balance is insufficient429 rate_limited— An RPM or daily limit was exceeded, or upstream capacity is busy503 upstream_unavailable— All upstream providers failed (uncommon)
Response
idstringRequiredobjectstringRequiredchat.completioncreatedintegerRequiredmodelstringRequiredchoicesarrayRequiredusageobjectOptional{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1715961234,
"model": "your-chat-model-id",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "Hello! I am…" },
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 64,
"total_tokens": 76
}
}Request and response bodies
Use the examples below to verify the request and response structures. To send a request, select Debug at the top of the page.
curl https://zerofa.ai/v1/chat/completions \
-H "Authorization: Bearer sk-zerofa-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "your-chat-model-id",
"messages": [
{"role": "user", "content": "Hello, introduce yourself"}
]
}'{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1715961234,
"model": "your-chat-model-id",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "Hello! I am…" },
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 64,
"total_tokens": 76
}
}