Basic Tool Definition
Define tools with the OpenAI-compatibletools array:
Execute the Tool
When the model chooses a tool, inspectmessage.tool_calls, parse the arguments, execute your application function, then send the result back as a tool message.
Python
Choose a Model
Function calling support is model-specific. Use the Text Models page or the Models API to find models withsupportsFunctionCalling.
Design Tips
- Keep tool names and descriptions short and literal.
- Use JSON Schema to make valid arguments easy for the model to produce.
- Prefer narrow tools with clear inputs over one broad tool with many optional behaviors.
- Return concise tool results so the final answer has enough context without wasting tokens.