Function calling
Enable models to call external functions and APIs. Both SDKs work — the tool schema is normalized on our router.
OpenAI
Python
tools = [{ "type": "function", "function": { "name": "get_weather", "description": "Get weather for a city", "parameters": { "type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"], }, },}] response = client.chat.completions.create( model="Qwen/Qwen3-235B-A22B", messages=[{"role": "user", "content": "What's the weather in London?"}], tools=tools, tool_choice="auto",) tool_call = response.choices[0].message.tool_calls[0]print(tool_call.function.name, tool_call.function.arguments)Anthropic
Python
tools = [{ "name": "get_weather", "description": "Get weather for a city", "input_schema": { "type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"], },}] message = client.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=1024, messages=[{"role": "user", "content": "What's the weather in London?"}], tools=tools,) for block in message.content: if block.type == "tool_use": print(block.name, block.input)