Function tools
Describe functions, inspect structured calls, execute only authorized actions in your application, and return matching results.
Own the complete loop.
The model proposes a call. Your application validates it and decides whether to execute it.
- Send a function name, optional description and JSON parameters; omit the unsupported strict flag.
- Read
message.tool_callsand validate function names and arguments before acting. - Execute under your client's own permission policy.
- Return the assistant tool-call message and a
role: toolmessage with the sametool_call_id. - Bound model turns, outputs, concurrency and permissions.
Concrete call and result.
The complete custom-agent example uses this function with a three-file read allow-list.
JSON
{"model":"<model-id>","messages":[{"role":"user","content":"Read README.md and summarize the setup."}],"tools":[{"type":"function","function":{"name":"read_project_file","description":"Read an allow-listed public project file.","parameters":{"type":"object","properties":{"file":{"type":"string"}},"required":["file"],"additionalProperties":false}}}],"tool_choice":"auto","max_tokens":1024}JSON
{"role":"tool","tool_call_id":"call_123","content":"# Blaschke ..."}Protocol boundaries.
Valid request syntax does not guarantee reliable model selection or valid arguments.
| Item | Limit |
|---|---|
| Definitions | 1–64 |
| Calls per assistant history message | 8 |
| Function name | 1–128 characters |
| Description | 16,384 characters |
| Encoded arguments | 32,768 characters |
| Tool choice | auto, none, required or named function |