Function calling and tool use across providers

OpenAI invented the modern tools[] / tool_calls schema, but every major provider — Anthropic, Google, Mistral, Llama hosts — has slightly different quirks (id field, parallel calls, streaming partial calls). VerticalAPI normalizes those edge cases so the same OpenAI-format tool definition works against any provider.

How it fits together

Caller → VerticalAPI /v1/chat/completions with tools[] → provider returns tool_calls → caller executes tool → caller resubmits with tool message → provider returns final answer. VerticalAPI normalizes tool_call_id, finish_reason and parallel-call shape across providers.

Working example in python

tool-calling.pythonPython
from openai import OpenAI
client = OpenAI(base_url="https://api.verticalapi.com/v1", api_key="vapi_...")

tools = [
    {"type": "function", "function": {
        "name": "get_weather",
        "description": "Get weather for a city",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"]
        }
    }}
]

# Same call works on GPT-4o, Claude, Gemini, Mistral, Llama
for model in ["gpt-4o", "claude-sonnet-4-5", "gemini-2.5-flash", "mistral-large-latest"]:
    r = client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": "Weather in Aix?"}],
        tools=tools,
        tool_choice="auto",
    )
    print(model, r.choices[0].message.tool_calls)

Typical cost at production volume

Tool calls themselves don't cost extra — you pay only for the tokens. A typical tool-calling agent with ~10 calls per task costs $0.01-0.10 per task depending on the model. VerticalAPI does not add per-tool-call charges.

See VerticalAPI plan pricing →

Common questions

Do all providers support parallel tool calls?

GPT-4o and Claude Sonnet 4.5 yes. Gemini and Mistral typically return one call per response (you loop). VerticalAPI surfaces both shapes consistently as tool_calls[] arrays.

What about strict JSON schema?

OpenAI's response_format json_schema is forwarded to providers that support it (Mistral, Gemini in 2026). On Claude, schema is enforced via prompt + post-processing. VerticalAPI does not silently fail — error responses make it explicit.

Can I A/B test tool-call accuracy across models?

Yes — that's a core VerticalAPI use case. Run identical tool definitions against multiple models, observe pass-rates and latency in the dashboard.