Docs menu
Core API

Tool calling

Function calling works out of the box. Pass tools and tool_choice exactly as you would with OpenAI — Sluice forwards them to the model and returns tool_calls unchanged.

Define tools

Send a tools array; set tool_choice to "auto", "required", or a specific function. The model replies with tool_calls, which you execute and feed back as tool messages.

const res = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "What's the weather in Lisbon?" }],
  tools: [
    {
      type: "function",
      function: {
        name: "get_weather",
        description: "Get the current weather for a city",
        parameters: {
          type: "object",
          properties: { city: { type: "string" } },
          required: ["city"],
        },
      },
    },
  ],
  tool_choice: "auto",
});

const call = res.choices[0].message.tool_calls?.[0];
// -> { function: { name: "get_weather", arguments: '{"city":"Lisbon"}' } }

Routing & tools

When a request includes tools, Sluice only routes to providers whose model actually supports tool calling, and failover respects that too. You can still pin a provider or restrict with routing controls.

Tool results aren't cached
Responses that contain tool_calls are never served from or written to the cache — a tool call is a side-effecting step, so every one runs fresh.