Documentation · tool calling · updated 15 November 2026

Tool calling: let the model call your functions

Declare tools as JSON, let the model decide when to call them, run the function on your side and send the result back. The format is OpenAI's; the loop stays in your code.

What tool calling covers

A description contract, not remote execution.

You send a list of tools (name, description, JSON Schema parameters) and optionally tool_choice. The model answers either text or one or more tool_calls with JSON arguments. The API never runs your functions: you execute them, then send the result back as a role: "tool" message with the matching tool_call_id.

Typical use cases: booking a slot, reading an internal database, a deterministic calculation, calling a business API. For pure deterministic logic, call your function directly: the model adds no guarantee of accuracy.

Compatible models

Declared in the catalogue and enabled on the backend.

Tool calling depends on the model first: the gateway does not invent tool calls, it forwards the schema and lets the backend (vLLM) parse the output. Only models whose tools capability is declared in the catalogue are configured with a tool parser.

ModelAPI idContext
Dolphin 3.0 (Llama 3.1 8B)dolphin-3.0-llama3.1-8b32 768 tokens
Qwen3.6 35B A3B (abliterated)qwen3.6-35b-a3b-abliterated65 536 tokens
Qwen3.8 27B (abliterated)qwen3.8-27b-abliterated65 536 tokens

Complete example: a tool loop

Definition, call, local execution, second turn.

import json
from openai import OpenAI

client = OpenAI(base_url="https://api.effrenus.com/v1", api_key="sk-ef-...")

def get_weather(city: str) -> dict:
    return {"city": city, "temperature_c": 18, "conditions": "cloudy"}

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Current weather for a city (demo data).",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string", "description": "City name"}},
            "required": ["city"],
        },
    },
}]

messages = [{"role": "user", "content": "What is the weather in Lyon?"}]
response = client.chat.completions.create(
    model="dolphin-3.0-llama3.1-8b",
    messages=messages,
    tools=tools,
    tool_choice="auto",
)
message = response.choices[0].message
messages.append(message)

for call in message.tool_calls or []:
    fn = call.function
    args = json.loads(fn.arguments or "{}")
    result = get_weather(**args) if fn.name == "get_weather" else {"error": f"unknown tool: {fn.name}"}
    messages.append({
        "role": "tool",
        "tool_call_id": call.id,
        "content": json.dumps(result),
    })

final = client.chat.completions.create(
    model="dolphin-3.0-llama3.1-8b",
    messages=messages,
    tools=tools,
)
print(final.choices[0].message.content)

The second call is not optional: it turns the function result into a natural language answer. It is billed as a normal call (tool schemas count as input tokens).

Read the response

Arguments are a JSON string, not an object.

Common pitfalls

FAQ

Which models support tool calling?

Those whose tools capability is declared in the served catalogue. The table above reflects this instance's real catalogue; the capability is also available via /v1/models.

Can I force a tool call?

Yes with tool_choice: "required" (or a named tool). Not all compatible models respect the constraint perfectly: validate the response before executing.

Going further

A tool to connect?

Test the loop on a catalogue model with €5 of credits.

Create API key