agents/api
Tools & integrations

Function calling & application tools

Connect your own APIs with schemas, required actions, durable results, and explicit authorization.

Define JSON Schema
Receive required action
Validate & execute
Return tool result
Harness continues

Your code executes the function

A function definition describes a name, purpose, and JSON Schema for arguments. The model requests a call; your handler validates and executes it. Attaching a sandbox does not automatically execute application functions there. Handlers can live in your server or worker.

Handle the required action

Listen for agent.session.requires_action and read session.required_actions. Each pending call includes identifiers such as turn_id and call_id. A historical function_call item alone is not proof that a result is still pending.

Return a result to the right call

Send agent.session.input.tool_result through the session events endpoint with the matching turn and call IDs. Supply success: true with a string or supported content output, or success: false with an error. Serialize JSON objects before sending them as string output.

Make retries safe

Authorize each operation for the application user. Store side-effect results by session, turn, and call ID. After a disconnect, return the saved result instead of executing the action again. If execution may have succeeded without a saved result, reconcile the downstream outcome first.

Read the official reference

Check the source for current API fields, account requirements, and service limits.

OpenAI: functions