Skip to main content
The v1/chat/completions endpoint supports function calling through the tools and tool_choice parameters. For reasoning models, you can also set reasoning_effort to control how much internal reasoning the model performs before responding.
The Jinja chat template of the tokenizer must accept tools for function calling to work.

Defining tools

Provide tool definitions so the model knows which functions it can call:

Tool choice

Use tool_choice to control whether and which tool the model should call:
  • auto (default): The model decides whether to call a tool.
  • none: The model will not call any tools.
  • required: The model must call one or more tools.
  • Specific function: Pass {"type": "function", "function": {"name": "get_current_weather"}} to force a particular function.

Reasoning effort

For supported reasoning models, set reasoning_effort to balance quality and latency:
Supported values depend on the model and may include none, minimal, low, medium, high, and xhigh.

Handling tool calls

We attempt to parse tool calls from model responses and return them in the standard tool_calls field on the assistant message. When parsing succeeds, you can use the response directly:
Tool call parsing may fail for some models or chat templates. If tool_calls is empty but the model clearly intended to call a function, fall back to manual parsing from the raw message content (see below).

Manual parsing fallback

If automatic parsing does not work for your model, parse tool calls from the generated text yourself:

Streaming with tools

You can stream responses when using tools. Accumulate the full response and check for tool calls as chunks arrive:
For parameter details, see the API reference for tools, tool_choice, and reasoning_effort.