GatewayDocsOpen workspace ↗
Developer preview · Synthetic data only Launch status ↗

Function tool calling

Let models request functions that your application executes.

Define customer-executed functions

Pass up to 16 tools with type function, a unique function name, parameters schema, and optional description/strict flag. tool_choice accepts auto, none, required, or a specific declared function. parallel_tool_calls:false limits the model to one returned call. Only the caller’s application executes functions; this gateway does not open tool URLs, use customer credentials, or run arbitrary code.

JSON
{
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "lookup_schedule",
        "strict": true,
        "parameters": {
          "type": "object",
          "properties": {
            "day": {
              "type": "string"
            }
          },
          "required": [
            "day"
          ],
          "additionalProperties": false
        }
      }
    }
  ],
  "tool_choice": "required"
}

Return tool results

  1. Send the user message and tool definitions.
  2. Read choices[0].message.tool_calls. Validate and authorize each action in your application.
  3. Append the complete assistant message, then one role:"tool" message for each call with its exact tool_call_id and a string result.
  4. Send the updated conversation with a new idempotency key for this next model request. Each model request is separately metered.

Tool names and arguments are checked against the supplied definitions before being returned. Streaming tool arguments are delivered only after completion and validation. Treat arguments and results as potentially sensitive content; they are excluded from Gateway logs and audit records.

JSON
[
  {
    "role": "assistant",
    "content": null,
    "tool_calls": [
      {
        "id": "call_example",
        "type": "function",
        "function": {
          "name": "lookup_schedule",
          "arguments": "{\"day\":\"Tuesday\"}"
        }
      }
    ]
  },
  {
    "role": "tool",
    "tool_call_id": "call_example",
    "content": "Fictional slots: 10:00, 14:00"
  }
]

Model and healthcare limits

Chat Completions tool support is enabled for GPT-6 Luna and GPT-6.1 Terra. GPT-6 Astra and GPT-6.1 Sol require OpenAI’s Responses API for tool calling; that endpoint is a future compatibility addition. Unsupported requests are rejected before dispatch. Model capabilities and patient-data approval are separate; new capabilities require a route-specific healthcare review before use with PHI.

Search documentation

Search all 25 guides and references.