The two simplest patterns: one tool, one call (simple), and many tools available with the model picking one (multiple).Documentation Index
Fetch the complete documentation index at: https://docs.together.ai/llms.txt
Use this file to discover all available pages before exploring further.
Simple function calling
Suppose your application has access to aget_current_weather function that takes two named arguments, location and unit:
tools key alongside the user’s query. Suppose the user asks, “What is the current temperature of New York?”
tool_calls array, specifying the function name and arguments needed to get the weather for New York.
JSON
Streaming
Function calling also works with streaming responses. When you enable streaming, the model returns tool calls incrementally, accessible from thedelta.tool_calls object in each chunk.
Tool calls don’t show up in
message.content: When a model decides to call a tool, the call lands in message.tool_calls, not in the content string. Some models return null for message.content on a tool-calling turn. Read the call from message.tool_calls[0].function.name and .arguments.Multiple function calling
Multiple function calling makes several functions available and lets the model choose the best one based on the user’s intent. The model has to understand the request and pick the appropriate tool from the options. The example below provides two tools to the model. The model responds with one tool invocation.get_current_stock_price function.
Select a specific tool
To force the model to use a specific tool, pass the tool’s name to thetool_choice parameter:
tool_choice options
The tool_choice parameter controls how the model uses functions. It accepts:
String values:
"auto"(default): The model decides whether to call a function or generate a text response."none": The model never calls functions, only generates text."required": The model must call at least one function.