Tool Calling

Tool calling lets a model produce structured function arguments. Your application must validate the arguments, authorize and execute the operation, and return the result. The model never executes your function by itself.

Choose a protocol

Use caseProtocol
Broad SDK and client compatibilityChat Completions
New OpenAI agent workflowsResponses API
Claude-native toolsAnthropic Messages
Gemini-native function callingGemini-compatible API

Chat Completions declares functions under tools[].function. Responses places name, description, and parameters directly on a type: "function" tool. Do not copy request bodies between protocols.

Safe execution checklist

  1. Validate arguments against a strict schema.
  2. Check the end user's permission.
  3. Apply timeouts and resource limits.
  4. Require confirmation for writes or destructive actions.
  5. Make repeated tool-call IDs idempotent.
  6. Return structured failures instead of pretending success.

A successful text prompt does not prove tool calling works. Verify the exact model, protocol, and client combination before production use.

See the Chat Completions guide, Responses guide, and API Reference.