Skip to documentation
deepthroat
DocsAPI reference
DEEPTHROAT DEVELOPER GUIDE

Tool calling

Let a model request functions that your application executes.

On this pageDefine a toolReturn the resultStreaming tool calls

Define a tool

Provide a name, description, and JSON schema. The model requests the tool; your application executes it.

json
{
  "model": "gpt-6.1-sol",
  "messages": [
    {
      "role": "user",
      "content": "What time is it in Auckland?"
    }
  ],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "gettime",
        "description": "Read the current time for a city",
        "parameters": {
          "type": "object",
          "properties": {
            "city": {
              "type": "string"
            }
          },
          "required": [
            "city"
          ]
        }
      }
    }
  ],
  "tool_choice": "auto"
}

Return the result

Keep the assistant’s tool call in the conversation. Add a tool message with the matching tool_call_id and the result, then request the next response.

json
[
  {
    "role": "assistant",
    "content": null,
    "tool_calls": [
      {
        "id": "call-example",
        "type": "function",
        "function": {
          "name": "gettime",
          "arguments": "{\"city\":\"Auckland\"}"
        }
      }
    ]
  },
  {
    "role": "tool",
    "tool_call_id": "call-example",
    "content": "{\"time\":\"14:30\"}"
  }
]

Validate arguments and apply your application’s access controls before executing a tool. The API does not execute a harness’s filesystem or shell actions.

Streaming tool calls

Accumulate tool-call deltas by their index. A name or arguments string can span several events; parse arguments as JSON after the tool call is complete.

Empty arguments in a harness?
Check that the client collects every argument delta and preserves each call ID. Verify the model’s tool support and inspect the final structured tool call.