Tools and sessions

Understand custom and hosted tools, tool results, and session continuation.

Custom and hosted tools

With function calling, your application normally executes a function and sends its result back. Hosted tools such as web_search or code_interpreter execute server-side. Accepting a tool definition does not prove that a model and route can execute it.

Verify actual execution

Check the published protocol, then test tool events, execution results, and final output. HTTP 200 alone is not evidence that a search or code execution occurred.

Sessions and tool_choice

Preserve conversation context, tool-call IDs, tool results, and required history using the selected protocol. Do not mix protocols or assume stored state is portable between models. tool_choice="none" disables new calls for this turn; it does not execute old calls or reconstruct missing history.

Tests before production

Test initial execution, history continuation, none continuation, streaming, and non-streaming. Images, reasoning settings, structured output, and tools depend on the model and route. Correct invalid parameters before retrying.

Browse models and integration guides