Capabilities
Markdown ↗

Tool calling

Tool calling returns structured requests for your code to execute. Zrelay does not execute your functions.

Define a tool

json
{
  "model": "gpt-6.1-sol",
  "messages": [
    {
      "role": "user",
      "content": "What is the weather in Madrid?"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Read weather for a city",
        "parameters": {
          "type": "object",
          "properties": {
            "city": {
              "type": "string"
            }
          },
          "required": [
            "city"
          ],
          "additionalProperties": false
        }
      }
    }
  ]
}

Validate and execute

Read message.tool_calls, validate each function name and parse its JSON arguments against your schema. Apply permissions in your application before executing. Treat tool output and model arguments as untrusted data.

Return results to the model

For Chat Completions, append the assistant message containing the calls, then a role: tool message for each result with the matching tool_call_id. Send the conversation again to obtain a final answer. Messages and Responses use their own tool result formats.

Bound the loop

Limit iterations, execution time and spend. Require explicit approval for destructive or external effects. Retry only operations whose effects you can safely identify or deduplicate; a repeated model request can propose the same action again.

Questions about your integration? support@zrelay.net