LLM
Function calling with OpenAI, Anthropic and Meta via API
In POST /llm/chat/completions, tools and tool_choice follow the OpenAI format. The model returns tool_calls, you run the function and send the result in a message with role tool. For Anthropic, Connect translates tools and tool_calls, so the code is the same.
The request
POST /api/llm/chat/completions
Authorization: Bearer <merchant token>
{
"model": "openai/gpt-5.4-mini",
"models": [
"anthropic/claude-haiku-5-5"
],
"max_tokens": 512,
"messages": [
{
"role": "user",
"content": "What was yesterday's reach?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_reach",
"description": "Account reach on a given day",
"parameters": {
"type": "object",
"properties": {
"date": {
"type": "string",
"format": "date"
}
},
"required": [
"date"
]
}
}
}
],
"tool_choice": "auto"
}What you can do
- Declare functions in tools and let the model decide when to call them.
- Return the function result with a role: tool message and tool_call_id.
- Use tool_choice auto or none on all models.
- Check in GET /llm/models which models have supports_tools.
- Combine tools with fallback and stream.
Rules and limits
- tools and tool_choice are only accepted if every model in the call (model and each item of models) has supports_tools. Otherwise: 400 llm_unsupported_field.
- Not every model supports tools: check supports_tools in GET /llm/models before choosing.
- tool_choice accepts auto and none on all models.
- On Anthropic, tools that are not of type function return 400 llm_unsupported_field.
- The response carries tool_calls in choices[].message, with finish_reason tool_calls when the model asks for a function.
Main fields
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model id from GET /llm/models, in provider/model form. |
| messages | array | Yes | The conversation, as in OpenAI. role: system, developer, user, assistant or tool. |
| max_tokens | integer | Yes | Required (or max_completion_tokens). Up to the account cap and each model's max_output_tokens in the call. |
| tools | array | No | Functions the model can call, as in OpenAI. Only on models with supports_tools. |
| tool_choice | string | No | auto or none on all models. |
| tool_calls | array | No | In the response: the function calls the model asked for, in choices[].message. |
Who it is for
Agent that queries customer data
The model calls a function of yours that fetches the customer's metrics through the Connect API and answers with the numbers.
Assistant that performs actions
Declare functions such as create task or book meeting in your SaaS and let the model choose when to use them.
Structured extraction
Use a function with typed parameters so the model returns structured data from free text.
Frequently asked questions
Do all models support tools?
No. Each model in GET /llm/models has a supports_tools field. Sending tools to a model without it returns 400 llm_unsupported_field.
Does the format change between providers?
No. You send tools in the OpenAI format and read tool_calls from the response. For Anthropic, Connect translates tools and tool_calls.
Does it work with fallback?
Yes, as long as every model in the call has supports_tools. If any lacks it, the call is refused before reaching the model.
See Connect applied to your product.
Try it for 15 days with no card, or walk our team through your use case.
