← Blog

Claude API Multi-Tool Orchestration Example

2026-11-15 · 5 min read · SubToAPI Team

Multi-tool orchestration means giving Claude access to more than one tool in a single conversation and letting it decide which tools to call, in what order, and how to combine their results before answering. This is different from single-tool setups where you bind one function to one specific task. The pattern shows up constantly in real applications: a support bot that needs to look up an order, check inventory, and then draft a refund; a research assistant that searches the web, queries a database, and runs a calculation; a DevOps assistant that reads logs, checks a status API, and files a ticket.

Below is a concrete, runnable example showing how to define multiple tools, handle the back-and-forth tool-use loop, and deal with the two orchestration patterns you'll actually hit: sequential tool calls (output of one feeds into the next) and parallel tool calls (Claude requests several tools at once because it has already decided it needs all of them).

The scenario

Assume an internal assistant for an e-commerce team with three tools:

A single user message like "Order #4521 arrived damaged, refund it if the item is still unavailable to replace" requires Claude to call the first tool, use its output to decide whether to call the second, and then conditionally call the third. That's orchestration — not just tool use.

Defining multiple tools

[
  {
    "name": "get_order_status",
    "description": "Fetch order details and current status by order ID.",
    "input_schema": {
      "type": "object",
      "properties": {
        "order_id": { "type": "string" }
      },
      "required": ["order_id"]
    }
  },
  {
    "name": "check_inventory",
    "description": "Check stock level for a SKU.",
    "input_schema": {
      "type": "object",
      "properties": {
        "sku": { "type": "string" }
      },
      "required": ["sku"]
    }
  },
  {
    "name": "issue_refund",
    "description": "Issue a refund for an order.",
    "input_schema": {
      "type": "object",
      "properties": {
        "order_id": { "type": "string" },
        "amount": { "type": "number" }
      },
      "required": ["order_id", "amount"]
    }
  }
]

Each tool is self-contained. Claude decides the sequence based on the descriptions and the conversation — you don't hardcode "call tool A then tool B" anywhere.

The orchestration loop

The core pattern for any multi-tool setup is the same loop, repeated until Claude stops requesting tools:

  1. Send the message history + tool definitions.
  2. If the response contains tool_use blocks, execute each one against your real backend.
  3. Append the tool_use and matching tool_result blocks to the message history.
  4. Send the updated history back to Claude.
  5. Repeat until the response has no more tool_use blocks — that's your final answer.
async function runOrchestration(messages, tools, callTool) {
  while (true) {
    const res = await fetch("https://api.subtoapi.app/v1/messages", {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        model: "claude-sonnet-4",
        max_tokens: 1024,
        messages,
        tools
      })
    });

    const data = await res.json();
    const toolUses = data.content.filter(b => b.type === "tool_use");

    if (toolUses.length === 0) {
      return data.content; // final answer
    }

    messages.push({ role: "assistant", content: data.content });

    // Execute tool calls — in parallel if there are multiple
    const results = await Promise.all(
      toolUses.map(async (tu) => ({
        type: "tool_result",
        tool_use_id: tu.id,
        content: JSON.stringify(await callTool(tu.name, tu.input))
      }))
    );

    messages.push({ role: "user", content: results });
  }
}

This loop handles both orchestration patterns without special-casing them:

Routing tool calls to real functions

In production, callTool is a dispatcher to your actual backend logic:

async function callTool(name, input) {
  switch (name) {
    case "get_order_status":
      return await db.orders.findById(input.order_id);
    case "check_inventory":
      return await inventory.getStock(input.sku);
    case "issue_refund":
      return await payments.refund(input.order_id, input.amount);
    default:
      return { error: `Unknown tool: ${name}` };
  }
}

Always return a well-formed result even on failure — a JSON error object, not a thrown exception — so Claude can see what went wrong and adjust its next step instead of the whole request failing.

Practical issues in multi-tool orchestration

If you're building this against a direct Anthropic subscription, you're often limited by seat-based access rather than a clean API key. SubToAPI turns that access into a standard HTTPS endpoint with sub_live_... API keys, so the orchestration loop above works unchanged whether you're prototyping solo or running it across a team. See the tool use docs and messages reference for request/response details, or start with the quickstart.

FAQs

Can Claude call multiple tools in one response? Yes. If Claude determines it needs several independent pieces of information at once, it returns multiple tool_use blocks in a single response, which you can execute concurrently.

How do I force a specific tool execution order? You can't force it directly, but you can make dependencies explicit in tool descriptions and system prompts, or split the task into sequential API calls where you only expose the next tool after the prior result is known.

What happens if a tool call fails during orchestration? Return a structured error as the tool_result content instead of throwing — Claude will see the error and can retry, choose a different tool, or explain the failure to the user.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →