Tools and structured output
Function calling and JSON schema replies on Chat Completions.
Function calling
/v1/chat/completions supports function
tools on ChatGPT and Claude candidates. Requests with tools skip Grok.
curl https://code.test.indicia-ai.com/v1/chat/completions \
-H "Authorization: Bearer $INDICIA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "indicia/snel",
"messages": [{"role": "user", "content": "What is the weather in Utrecht?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}]
}'{
"object": "chat.completion",
"model": "indicia/snel",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_mJbpAroeitGQMXp5AWdqVWLN",
"type": "function",
"function": {"name": "get_weather", "arguments": "{\"city\":\"Utrecht\"}"}
}
]
},
"finish_reason": "tool_calls"
}
]
}Run the tool, then send the conversation back with the assistant message and
one tool message per call:
[
{"role": "user", "content": "What is the weather in Utrecht?"},
{"role": "assistant", "content": null, "tool_calls": [{"id": "call_mJbp…", "type": "function", "function": {"name": "get_weather", "arguments": "{\"city\":\"Utrecht\"}"}}]},
{"role": "tool", "tool_call_id": "call_mJbp…", "content": "{\"temp_c\": 14, \"sky\": \"cloudy\"}"}
]arguments must be valid JSON. Only function tools are supported.
/v1/messages takes Anthropic tools and passes
them on.
Structured output
response_format with json_schema makes the reply match a JSON schema.
json_object asks for any JSON object.
ChatGPT only
Only ChatGPT candidates support response_format, so these requests skip
Claude and Grok. When the ChatGPT pool is unavailable, they fail with 429
or 503.
curl https://code.test.indicia-ai.com/v1/chat/completions \
-H "Authorization: Bearer $INDICIA_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "indicia/snel",
"messages": [{"role": "user", "content": "Name a Dutch city and its province."}],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "city",
"strict": true,
"schema": {
"type": "object",
"properties": {"city": {"type": "string"}, "province": {"type": "string"}},
"required": ["city", "province"],
"additionalProperties": false
}
}
}
}'The reply's message.content is the JSON text, such as
{"city":"Amsterdam","province":"North Holland"}.