Tool calling
Define functions a model can call and send their results back to it.
Tool calling lets a model request that your application run a function with specific arguments. All three text endpoints support function tools (function).
Check the model catalog or look for tools in supported_parameters from GET /v1/models.
Tool calling flow
Send tool definitions
Include the function name, description, and argument JSON Schema in tools.
Read the tool call
When the model calls a tool, it returns the function name and arguments. Look for finish_reason: "tool_calls" in Chat Completions, stop_reason: "tool_use" in Anthropic Messages, or a function_call item in Responses.
Run the function and send its result
Run the function on your server. Send the result along with the earlier turns so the model can produce its final answer. Include the full conversation in each request because outerlane does not store it.
Example
import json
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.outerlane.app/v1",
api_key=os.environ["OUTERLANE_API_KEY"],
)
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Look up the current weather in a city.",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}]
messages = [{"role": "user", "content": "What's the weather in Seoul?"}]
response = client.chat.completions.create(
model="openai/gpt-6.1-sol", messages=messages, tools=tools
)
calls = response.choices[0].message.tool_calls or []
messages.append({"role": "assistant", "tool_calls": [call.model_dump() for call in calls]})
for call in calls:
args = json.loads(call.function.arguments)
result = {"city": args["city"], "temp_c": 21} # Run your function here
messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(result)})
final = client.chat.completions.create(
model="openai/gpt-6.1-sol", messages=messages, tools=tools
)
print(final.choices[0].message.content)Control tool selection
| Behavior | Chat Completions | Responses | Anthropic Messages |
|---|---|---|---|
| Model decides (default) | "auto" | "auto" | { "type": "auto" } |
| Require a tool | "required" | "required" | { "type": "any" } |
| Require a specific tool | { "type": "function", "function": { "name": "..." } } | { "type": "function", "name": "..." } | { "type": "tool", "name": "..." } |
| Disable tools | "none" | "none" | { "type": "none" } |
To disable parallel tool calls, use parallel_tool_calls: false in Chat Completions and Responses or disable_parallel_tool_use: true inside tool_choice in Anthropic Messages.
Limitations
- Only function tools are supported. Built-in tools such as web search and unnamed tools return
400 unsupported_toolin Responses and Anthropic Messages. - Responses
function_call_outputand Anthropic Messagestool_resultaccept text only. Send any images in the nextusermessage. - See Streaming behavior for how function arguments arrive in streams.