---
title: Tool-Nutzung mit Claude
url: https://platform.claude.com/docs/de/agents-and-tools/tool-use/overview
description: Verbinde Claude mit externen Tools und APIs. Erfahre, wo Tools ausgeführt werden, wann Claude sie aufruft und welches Tool zu deiner Aufgabe passt.
---

„Tool use“ (Tool-Nutzung), auch „function calling“ (Funktionsaufruf) genannt, ermöglicht es Claude, Funktionen aufzurufen, die du definierst oder die Anthropic bereitstellt. Claude entscheidet anhand der Anfrage des Nutzers und der Beschreibung des Tools, wann ein Tool aufgerufen wird. Anschließend gibt Claude einen strukturierten Aufruf zurück, den deine Anwendung ausführt (Client-Tools) oder den Anthropic ausführt (Server-Tools).

Hier ist ein minimales Beispiel mit einem Server-Tool, dem [Web-Search-Tool](https://platform.claude.com/docs/de/agents-and-tools/tool-use/web-search-tool), das Anthropic für dich ausführt:

<CodeGroup>
  ```bash cURL
  curl https://api.anthropic.com/v1/messages \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d '{
      "model": "claude-opus-5-5",
      "max_tokens": 1024,
      "tools": [{"type": "web_search_20260209", "name": "web_search"}],
      "messages": [{"role": "user", "content": "What'\''s the latest on the Mars rover?"}]
    }'
  ```

  ```bash CLI
  ant messages create --transform content --format yaml \
    --model claude-opus-5-5 \
    --max-tokens 1024 \
    --tool '{type: web_search_20260209, name: web_search}' \
    --message '{role: user, content: "What is the latest on the Mars rover?"}'
  ```

  ```python Python
  client = anthropic.Anthropic()
  response = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      tools=[{"type": "web_search_20260209", "name": "web_search"}],
      messages=[{"role": "user", "content": "What's the latest on the Mars rover?"}],
  )
  print(response.content)
  ```

  ```typescript TypeScript
  const client = new Anthropic();
  const response = await client.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    tools: [{ type: "web_search_20260209", name: "web_search" }],
    messages: [{ role: "user", content: "What's the latest on the Mars rover?" }]
  });
  console.log(response.content);
  ```

  ```csharp C#
  AnthropicClient client = new();

  var parameters = new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Tools = [new ToolUnion(new WebSearchTool20260209())],
      Messages = [new() { Role = Role.User, Content = "What's the latest on the Mars rover?" }]
  };

  var message = await client.Messages.Create(parameters);
  Console.WriteLine(message.Content);
  ```

  ```go Go
  client := anthropic.NewClient()

  response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
  	Model:     anthropic.ModelClaudeOpus5_5,
  	MaxTokens: 1024,
  	Tools: []anthropic.ToolUnionParam{
  		{OfWebSearchTool20260209: &anthropic.WebSearchTool20260209Param{}},
  	},
  	Messages: []anthropic.MessageParam{
  		anthropic.NewUserMessage(anthropic.NewTextBlock("What's the latest on the Mars rover?")),
  	},
  })
  if err != nil {
  	log.Fatal(err)
  }
  fmt.Println(response.Content)
  ```

  ```java Java
  import com.anthropic.models.messages.WebSearchTool20260209;

  void main() {
      AnthropicClient client = AnthropicOkHttpClient.fromEnv();

      MessageCreateParams params = MessageCreateParams.builder()
          .model(Model.CLAUDE_OPUS_5_5)
          .maxTokens(1024L)
          .addTool(WebSearchTool20260209.builder().build())
          .addUserMessage("What's the latest on the Mars rover?")
          .build();

      Message response = client.messages().create(params);
      IO.println(response.content());
  }
  ```

  ```php PHP
  $client = new Client();

  $message = $client->messages->create(
      model: 'claude-opus-5-5',
      maxTokens: 1024,
      tools: [
          ['type' => 'web_search_20260209', 'name' => 'web_search'],
      ],
      messages: [
          ['role' => 'user', 'content' => "What's the latest on the Mars rover?"],
      ],
  );

  echo $message;
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  message = client.messages.create(
    model: "claude-opus-5-5",
    max_tokens: 1024,
    tools: [{ type: "web_search_20260209", name: "web_search" }],
    messages: [{ role: "user", content: "What's the latest on the Mars rover?" }]
  )
  puts message.content
  ```
</CodeGroup>

Claude führt die Suche auf der Infrastruktur von Anthropic aus und gibt die zitierten Ergebnisse in derselben Antwort zurück. Damit Claude eine von dir definierte Funktion aufruft, übergib ein Tool mit einem `input_schema` und führe den Aufruf aus, wenn Claude einen `tool_use`-Block zurückgibt. [So funktioniert Tool-Nutzung](https://platform.claude.com/docs/de/agents-and-tools/tool-use/overview#how-tool-use-works) zeigt diesen Round Trip von Anfang bis Ende. Erfahre mehr über das [Definieren von Tools](https://platform.claude.com/docs/de/agents-and-tools/tool-use/define-tools) und das [Verarbeiten von Tool-Aufrufen](https://platform.claude.com/docs/de/agents-and-tools/tool-use/handle-tool-calls).

## So funktioniert Tool-Nutzung

Tools unterscheiden sich in erster Linie darin, wo der Code ausgeführt wird. **Client-Tools** (einschließlich benutzerdefinierter Tools und Tools mit von Anthropic definierten Schemas wie `bash` und `text_editor`) laufen in deiner Anwendung. Claude antwortet mit `stop_reason: "tool_use"` und einem oder mehreren `tool_use`-Blöcken. Dein Code führt die Operation aus und sendet ein `tool_result` zurück. **Server-Tools** (wie `web_search`, `web_fetch`, `code_execution` und `tool_search`) laufen auf der Infrastruktur von Anthropic: Du siehst die Ergebnisse direkt, ohne die Ausführung selbst zu übernehmen, es sei denn, Claude ruft das Tool in derselben Gruppe paralleler Tool-Aufrufe wie eines deiner Client-Tools auf (siehe [Stop-Reasons und Fallback](https://platform.claude.com/docs/de/build-with-claude/handling-stop-reasons#tool-use)).

Hier ist dieser Round Trip vollständig für ein Client-Tool. Die erste Anfrage definiert ein `get_weather`-Tool, und Claude beantwortet die Frage, indem es dieses aufruft: Die Antwort enthält einen `tool_use`-Block, dein Code führt die Abfrage aus, und eine zweite Anfrage sendet das Ergebnis in einem `tool_result`-Block zurück, sodass Claude mit der Antwort reagieren kann.

<CodeGroup>
  ```bash cURL
  # Claude antwortet mit einem tool_use-Block, der das Tool und seine Argumente nennt.
  TOOLS='[
    {
      "name": "get_weather",
      "description": "Get the current weather for a given location.",
      "input_schema": {
        "type": "object",
        "properties": {
          "location": {"type": "string", "description": "City and state, e.g. San Francisco, CA"}
        },
        "required": ["location"]
      }
    }
  ]'
  USER_MSG="What's the weather in San Francisco?"
  RESPONSE=$(curl -s https://api.anthropic.com/v1/messages \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d "$(jq -n --argjson tools "$TOOLS" --arg msg "$USER_MSG" '{
      model: "claude-opus-5-5",
      max_tokens: 1024,
      tools: $tools,
      # Fordere pro Turn höchstens einen Tool-Aufruf an.
      tool_choice: {type: "auto", disable_parallel_tool_use: true},
      messages: [{role: "user", content: $msg}]
    }')")
  TOOL_USE=$(echo "$RESPONSE" | jq '.content[] | select(.type == "tool_use")')
  echo "Claude called $(echo "$TOOL_USE" | jq -r '.name') with $(echo "$TOOL_USE" | jq -c '.input')"

  # Führe das Tool aus und sende das Ergebnis dann in einem tool_result-Block zurück.
  # Claude nutzt das Ergebnis, um die ursprüngliche Frage zu beantworten.
  WEATHER="15 degrees Celsius, partly cloudy"
  curl -s https://api.anthropic.com/v1/messages \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d "$(jq -n \
      --argjson tools "$TOOLS" \
      --arg msg "$USER_MSG" \
      --argjson assistant "$(echo "$RESPONSE" | jq '.content')" \
      --arg tool_use_id "$(echo "$TOOL_USE" | jq -r '.id')" \
      --arg weather "$WEATHER" \
      '{
        model: "claude-opus-5-5",
        max_tokens: 1024,
        tools: $tools,
        tool_choice: {type: "auto", disable_parallel_tool_use: true},
        messages: [
          {role: "user", content: $msg},
          {role: "assistant", content: $assistant},
          {role: "user", content: [
            {type: "tool_result", tool_use_id: $tool_use_id, content: $weather}
          ]}
        ]
      }')"
  ```

  ```bash CLI
  # ant liest den Request-Body als YAML von stdin; jq überträgt den Konversations-
  # zustand in den zweiten Request.
  USER_MSG="What's the weather in San Francisco?"
  MESSAGES=$(jq -n --arg msg "$USER_MSG" '[{role: "user", content: $msg}]')
  call_api() {
    {
      cat <<'YAML'
  model: claude-opus-5-5
  max_tokens: 1024
  # Fordere höchstens einen Tool-Aufruf pro Turn an.
  tool_choice: {type: auto, disable_parallel_tool_use: true}
  tools:
    - name: get_weather
      description: Get the current weather for a given location.
      input_schema:
        type: object
        properties:
          location: {type: string, description: "City and state, e.g. San Francisco, CA"}
        required: [location]
  YAML
      printf 'messages: %s\n' "$MESSAGES"
    } | ant messages create --format json
  }

  # Claude antwortet mit einem tool_use-Block, der das Tool und seine Argumente nennt.
  RESPONSE=$(call_api)
  TOOL_USE=$(jq '.content[] | select(.type == "tool_use")' <<<"$RESPONSE")
  echo "Claude called $(jq -r '.name' <<<"$TOOL_USE") with $(jq -c '.input' <<<"$TOOL_USE")"

  # Führe das Tool aus und sende das Ergebnis dann in einem tool_result-Block zurück.
  WEATHER="15 degrees Celsius, partly cloudy"
  MESSAGES=$(jq \
    --argjson assistant "$(jq '.content' <<<"$RESPONSE")" \
    --arg tool_use_id "$(jq -r '.id' <<<"$TOOL_USE")" \
    --arg weather "$WEATHER" \
    '. + [
      {role: "assistant", content: $assistant},
      {role: "user", content: [
        {type: "tool_result", tool_use_id: $tool_use_id, content: $weather}
      ]}
    ]' <<<"$MESSAGES")

  # Claude nutzt das Ergebnis, um die ursprüngliche Frage zu beantworten.
  call_api
  ```

  ```python Python
  client = anthropic.Anthropic()

  tools = [
      {
          "name": "get_weather",
          "description": "Get the current weather for a given location.",
          "input_schema": {
              "type": "object",
              "properties": {
                  "location": {
                      "type": "string",
                      "description": "City and state, e.g. San Francisco, CA",
                  }
              },
              "required": ["location"],
          },
      }
  ]
  messages = [{"role": "user", "content": "What's the weather in San Francisco?"}]

  # Claude antwortet mit einem tool_use-Block, der das Tool und seine Argumente nennt.
  response = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      tools=tools,
      # Fordere höchstens einen Tool-Aufruf pro Turn an.
      tool_choice={"type": "auto", "disable_parallel_tool_use": True},
      messages=messages,
  )
  tool_use = next(block for block in response.content if block.type == "tool_use")
  print(f"Claude called {tool_use.name} with {json.dumps(tool_use.input)}")

  # Führe das Tool aus und sende das Ergebnis dann in einem tool_result-Block zurück.
  weather = "15 degrees Celsius, partly cloudy"  # your weather lookup goes here
  messages += [
      {"role": "assistant", "content": response.content},
      {
          "role": "user",
          "content": [
              {"type": "tool_result", "tool_use_id": tool_use.id, "content": weather}
          ],
      },
  ]
  followup = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      tools=tools,
      tool_choice={"type": "auto", "disable_parallel_tool_use": True},
      messages=messages,
  )

  # Claude nutzt das Ergebnis, um die ursprüngliche Frage zu beantworten.
  final_text = next(block for block in followup.content if block.type == "text")
  print(final_text.text)
  ```

  ```typescript TypeScript
  const client = new Anthropic();

  const tools: Anthropic.Tool[] = [
    {
      name: "get_weather",
      description: "Get the current weather for a given location.",
      input_schema: {
        type: "object",
        properties: {
          location: { type: "string", description: "City and state, e.g. San Francisco, CA" }
        },
        required: ["location"]
      }
    }
  ];
  const messages: Anthropic.MessageParam[] = [
    { role: "user", content: "What's the weather in San Francisco?" }
  ];

  // Claude antwortet mit einem tool_use-Block, der das Tool und seine Argumente nennt.
  const response = await client.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    tools,
    // Fordere höchstens einen Tool-Aufruf pro Turn an.
    tool_choice: { type: "auto", disable_parallel_tool_use: true },
    messages
  });
  const toolUse = response.content.find(
    (block): block is Anthropic.ToolUseBlock => block.type === "tool_use"
  )!;
  console.log(`Claude called ${toolUse.name} with ${JSON.stringify(toolUse.input)}`);

  // Führe das Tool aus und sende das Ergebnis dann in einem tool_result-Block zurück.
  const weather = "15 degrees Celsius, partly cloudy"; // your weather lookup goes here
  messages.push(
    { role: "assistant", content: response.content },
    {
      role: "user",
      content: [{ type: "tool_result", tool_use_id: toolUse.id, content: weather }]
    }
  );
  const followup = await client.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    tools,
    tool_choice: { type: "auto", disable_parallel_tool_use: true },
    messages
  });

  // Claude nutzt das Ergebnis, um die ursprüngliche Frage zu beantworten.
  const finalText = followup.content.find(
    (block): block is Anthropic.TextBlock => block.type === "text"
  )!;
  console.log(finalText.text);
  ```

  ```csharp C#
  AnthropicClient client = new();

  List<ToolUnion> tools =
  [
      new ToolUnion(new Tool()
      {
          Name = "get_weather",
          Description = "Get the current weather for a given location.",
          InputSchema = new InputSchema()
          {
              Properties = new Dictionary<string, JsonElement>
              {
                  ["location"] = JsonSerializer.SerializeToElement(new
                  {
                      type = "string",
                      description = "City and state, e.g. San Francisco, CA",
                  }),
              },
              Required = ["location"],
          },
      }),
  ];

  // Fordere höchstens einen Tool-Aufruf pro Turn an.
  var toolChoice = new ToolChoice(new ToolChoiceAuto { DisableParallelToolUse = true });

  const string userPrompt = "What's the weather in San Francisco?";

  // Claude antwortet mit einem tool_use-Block, der das Tool und seine Argumente nennt.
  var response = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Tools = tools,
      ToolChoice = toolChoice,
      Messages = [new() { Role = Role.User, Content = userPrompt }],
  });
  ToolUseBlock? toolUse = null;
  foreach (var block in response.Content)
  {
      if (block.TryPickToolUse(out var picked))
      {
          toolUse = picked;
          break;
      }
  }
  Console.WriteLine($"Claude called {toolUse!.Name} with {JsonSerializer.Serialize(toolUse.Input)}");

  // Führe das Tool aus und sende das Ergebnis in einem tool_result-Block zurück.
  var weather = "15 degrees Celsius, partly cloudy";
  List<ContentBlockParam> toolResults =
  [
      new ContentBlockParam(new ToolResultBlockParam()
      {
          ToolUseID = toolUse.ID,
          Content = weather,
      }),
  ];
  var followup = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Tools = tools,
      ToolChoice = toolChoice,
      Messages =
      [
          new() { Role = Role.User, Content = userPrompt },
          new() { Role = Role.Assistant, Content = response.Content.Select(block => new ContentBlockParam(block.Json)).ToList() },
          new() { Role = Role.User, Content = new MessageParamContent(toolResults) },
      ],
  });

  // Claude nutzt das Ergebnis, um die ursprüngliche Frage zu beantworten.
  foreach (var block in followup.Content)
  {
      if (block.TryPickText(out var text))
      {
          Console.WriteLine(text.Text);
      }
  }
  ```

  ```go Go
  client := anthropic.NewClient()
  ctx := context.Background()

  tools := []anthropic.ToolUnionParam{
  	{OfTool: &anthropic.ToolParam{
  		Name:        "get_weather",
  		Description: anthropic.String("Get the current weather for a given location."),
  		InputSchema: anthropic.ToolInputSchemaParam{
  			Properties: map[string]any{
  				"location": map[string]any{
  					"type":        "string",
  					"description": "City and state, e.g. San Francisco, CA",
  				},
  			},
  			Required: []string{"location"},
  		},
  	}},
  }
  // Fordere höchstens einen Tool-Aufruf pro Turn an.
  toolChoice := anthropic.ToolChoiceUnionParam{
  	OfAuto: &anthropic.ToolChoiceAutoParam{DisableParallelToolUse: anthropic.Bool(true)},
  }
  messages := []anthropic.MessageParam{
  	anthropic.NewUserMessage(anthropic.NewTextBlock("What's the weather in San Francisco?")),
  }

  // Claude antwortet mit einem tool_use-Block, der das Tool und seine Argumente nennt.
  response, err := client.Messages.New(ctx, anthropic.MessageNewParams{
  	Model:      anthropic.ModelClaudeOpus5_5,
  	MaxTokens:  1024,
  	Tools:      tools,
  	ToolChoice: toolChoice,
  	Messages:   messages,
  })
  if err != nil {
  	log.Fatal(err)
  }
  var toolUse anthropic.ContentBlockUnion
  for _, block := range response.Content {
  	if block.Type == "tool_use" {
  		toolUse = block
  		break
  	}
  }
  fmt.Printf("Claude called %s with %s\n", toolUse.Name, string(toolUse.Input))

  // Führe das Tool aus und sende das Ergebnis dann in einem tool_result-Block zurück.
  weather := "15 degrees Celsius, partly cloudy"
  var assistantContent []anthropic.ContentBlockParamUnion
  for _, block := range response.Content {
  	assistantContent = append(assistantContent, block.ToParam())
  }
  messages = append(messages,
  	anthropic.NewAssistantMessage(assistantContent...),
  	anthropic.NewUserMessage(anthropic.NewToolResultBlock(toolUse.ID, weather, false)),
  )
  followup, err := client.Messages.New(ctx, anthropic.MessageNewParams{
  	Model:      anthropic.ModelClaudeOpus5_5,
  	MaxTokens:  1024,
  	Tools:      tools,
  	ToolChoice: toolChoice,
  	Messages:   messages,
  })
  if err != nil {
  	log.Fatal(err)
  }

  // Claude nutzt das Ergebnis, um die ursprüngliche Frage zu beantworten.
  for _, block := range followup.Content {
  	if block.Type == "text" {
  		fmt.Println(block.Text)
  	}
  }
  ```

  ```java Java
  import com.anthropic.core.JsonValue;
  import com.anthropic.models.messages.ContentBlockParam;
  // ...
  import com.anthropic.models.messages.Tool;
  import com.anthropic.models.messages.Tool.InputSchema;
  import com.anthropic.models.messages.ToolChoiceAuto;
  import com.anthropic.models.messages.ToolResultBlockParam;
  import com.anthropic.models.messages.ToolUseBlock;
  // ...

  void main() {
      AnthropicClient client = AnthropicOkHttpClient.fromEnv();

      Tool weatherTool = Tool.builder()
          .name("get_weather")
          .description("Get the current weather for a given location.")
          .inputSchema(InputSchema.builder()
              .properties(JsonValue.from(Map.of(
                  "location", Map.of(
                      "type", "string",
                      "description", "City and state, e.g. San Francisco, CA"
                  )
              )))
              .required(List.of("location"))
              .build())
          .build();

      // Fordere höchstens einen Tool-Aufruf pro Turn an.
      ToolChoiceAuto toolChoice = ToolChoiceAuto.builder()
          .disableParallelToolUse(true)
          .build();

      String userPrompt = "What's the weather in San Francisco?";

      // Claude antwortet mit einem tool_use-Block, der das Tool und seine Argumente nennt.
      Message response = client.messages().create(MessageCreateParams.builder()
          .model(Model.CLAUDE_OPUS_5_5)
          .maxTokens(1024L)
          .addTool(weatherTool)
          .toolChoice(toolChoice)
          .addUserMessage(userPrompt)
          .build());
      ToolUseBlock toolUse = response.content().stream()
          .flatMap(block -> block.toolUse().stream())
          .findFirst()
          .orElseThrow();
      IO.println("Claude called " + toolUse.name() + " with " + toolUse._input());

      // Führe das Tool aus und sende das Ergebnis dann in einem tool_result-Block zurück.
      String weather = "15 degrees Celsius, partly cloudy";
      Message followup = client.messages().create(MessageCreateParams.builder()
          .model(Model.CLAUDE_OPUS_5_5)
          .maxTokens(1024L)
          .addTool(weatherTool)
          .toolChoice(toolChoice)
          .addUserMessage(userPrompt)
          .addMessage(response)
          .addUserMessageOfBlockParams(List.of(ContentBlockParam.ofToolResult(
              ToolResultBlockParam.builder()
                  .toolUseId(toolUse.id())
                  .content(weather)
                  .build())))
          .build());

      // Claude nutzt das Ergebnis, um die ursprüngliche Frage zu beantworten.
      followup.content().stream()
          .flatMap(block -> block.text().stream())
          .forEach(textBlock -> IO.println(textBlock.text()));
  }
  ```

  ```php PHP
  use Anthropic\Messages\ToolChoiceAuto;

  $client = new Client();

  $tools = [
      [
          'name' => 'get_weather',
          'description' => 'Get the current weather for a given location.',
          'input_schema' => [
              'type' => 'object',
              'properties' => [
                  'location' => [
                      'type' => 'string',
                      'description' => 'City and state, e.g. San Francisco, CA',
                  ],
              ],
              'required' => ['location'],
          ],
      ],
  ];
  $userMessage = ['role' => 'user', 'content' => "What's the weather in San Francisco?"];

  // Fordere höchstens einen Tool-Aufruf pro Turn an.
  $toolChoice = ToolChoiceAuto::with(disableParallelToolUse: true);

  // Claude antwortet mit einem tool_use-Block, der das Tool und seine Argumente nennt.
  $response = $client->messages->create(
      model: 'claude-opus-5-5',
      maxTokens: 1024,
      tools: $tools,
      toolChoice: $toolChoice,
      messages: [$userMessage],
  );
  $toolUse = null;
  foreach ($response->content as $block) {
      if ($block->type === 'tool_use') {
          $toolUse = $block;
          break;
      }
  }
  printf("Claude called %s with %s\n", $toolUse->name, json_encode($toolUse->input));

  // Führe das Tool aus und sende das Ergebnis dann in einem tool_result-Block zurück.
  $weather = '15 degrees Celsius, partly cloudy';
  $followup = $client->messages->create(
      model: 'claude-opus-5-5',
      maxTokens: 1024,
      tools: $tools,
      toolChoice: $toolChoice,
      messages: [
          $userMessage,
          ['role' => 'assistant', 'content' => $response->content],
          [
              'role' => 'user',
              'content' => [
                  [
                      'type' => 'tool_result',
                      'tool_use_id' => $toolUse->id,
                      'content' => $weather,
                  ],
              ],
          ],
      ],
  );

  // Claude nutzt das Ergebnis, um die ursprüngliche Frage zu beantworten.
  foreach ($followup->content as $block) {
      if ($block->type === 'text') {
          echo $block->text, "\n";
      }
  }
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  tools = [
    {
      name: "get_weather",
      description: "Get the current weather for a given location.",
      input_schema: {
        type: "object",
        properties: {
          location: {type: "string", description: "City and state, e.g. San Francisco, CA"}
        },
        required: ["location"]
      }
    }
  ]
  messages = [{role: "user", content: "What's the weather in San Francisco?"}]

  # Claude antwortet mit einem tool_use-Block, der das Tool und seine Argumente nennt.
  response = client.messages.create(
    model: "claude-opus-5-5",
    max_tokens: 1024,
    tools: tools,
    # Fordere höchstens einen Tool-Aufruf pro Turn an.
    tool_choice: {type: "auto", disable_parallel_tool_use: true},
    messages: messages
  )
  tool_use = response.content.find { |block| block.type == :tool_use }
  puts "Claude called #{tool_use.name} with #{JSON.generate(tool_use.input)}"

  # Führe das Tool aus und sende das Ergebnis dann in einem tool_result-Block zurück.
  weather = "15 degrees Celsius, partly cloudy"
  messages += [
    {role: "assistant", content: response.content},
    {
      role: "user",
      content: [
        {type: "tool_result", tool_use_id: tool_use.id, content: weather}
      ]
    }
  ]
  followup = client.messages.create(
    model: "claude-opus-5-5",
    max_tokens: 1024,
    tools: tools,
    tool_choice: {type: "auto", disable_parallel_tool_use: true},
    messages: messages
  )

  # Claude nutzt das Ergebnis, um die ursprüngliche Frage zu beantworten.
  final_text = followup.content.find { |block| block.type == :text }
  puts final_text.text
  ```
</CodeGroup>

```text Output wrap
Claude called get_weather with {"location": "San Francisco, CA"}
The current weather in San Francisco is 15 degrees Celsius with partly cloudy skies.
```

[Tool-Aufrufe verarbeiten](https://platform.claude.com/docs/de/agents-and-tools/tool-use/handle-tool-calls) behandelt jeden Schritt im Detail, einschließlich der Formatierung von Ergebnissen und der Signalisierung von Fehlern; [Parallele Tool-Nutzung](https://platform.claude.com/docs/de/agents-and-tools/tool-use/parallel-tool-use) behandelt Antworten, die mehrere Tools gleichzeitig aufrufen. Wenn du diesen Round Trip nicht selbst schreiben möchtest, verwende den [Tool Runner](https://platform.claude.com/docs/de/agents-and-tools/tool-use/tool-runner): Das SDK führt deine Tools aus und sendet die Ergebnisse automatisch zurück.

Das vollständige konzeptionelle Modell einschließlich der agentischen Schleife und der Frage, wann welcher Ansatz zu wählen ist, findest du unter [So funktioniert Tool-Nutzung](https://platform.claude.com/docs/de/agents-and-tools/tool-use/how-tool-use-works).

Um dich mit „Model Context Protocol“-Servern, oder MCP-Servern, zu verbinden, siehe den [MCP-Connector](https://platform.claude.com/docs/de/agents-and-tools/mcp-connector). Um deinen eigenen MCP-Client zu erstellen, siehe den Model-Context-Protocol-Leitfaden zum [Erstellen eines MCP-Clients](https://modelcontextprotocol.io/docs/develop/build-client).

## Wann Claude Tools verwendet

Mit dem Standardwert für `tool_choice` von `{"type": "auto"}` entscheidet Claude in jedem Zug, ob ein Tool aufgerufen oder direkt geantwortet wird. Claude ruft ein Tool auf, wenn die Anfrage der beschriebenen Fähigkeit dieses Tools entspricht und die Antwort nicht bereits im Kontext vorhanden ist. Claude antwortet direkt bei stabilem Wissen, kreativen Aufgaben und Gesprächszügen.

Diese Grenze lässt sich über deinen System-Prompt steuern. Wenn Claude keine Tools aufruft, obwohl du es erwartest, erhöht eine leichte Anweisung wie `"Use the tools to investigate before responding."` die Tool-Nutzung. Eine stärkere Form wie `"Always call a tool first before responding."` geht noch weiter. Umgekehrt hält `"Use your judgment about whether to call a tool or respond directly."` das Auslöseverhalten konservativ.

Um einen Tool-Aufruf zu erzwingen, statt dich auf Prompting zu verlassen, setze [`tool_choice`](https://platform.claude.com/docs/de/agents-and-tools/tool-use/define-tools#forcing-tool-use).

<Tip>
  **Schema-Konformität mit strikter Tool-Nutzung garantieren**

  Füge `strict: true` zu deinen benutzerdefinierten Tool-Definitionen hinzu, um sicherzustellen, dass Claudes Tool-Aufrufe immer exakt deinem Schema entsprechen. Siehe [Strikte Tool-Nutzung](https://platform.claude.com/docs/de/agents-and-tools/tool-use/strict-tool-use).
</Tip>

Die Seite jedes Server-Tools beschreibt dessen eigene Auslösegrenze ausführlicher.

<Accordion title="Wenn erforderliche Parameter fehlen">
  Wenn der Prompt des Nutzers nicht genügend Informationen enthält, um alle erforderlichen Parameter eines Tools zu füllen, erkennt Claude Opus mit deutlich höherer Wahrscheinlichkeit, dass ein Parameter fehlt, und fragt danach. Claude Sonnet fragt möglicherweise nach, insbesondere wenn es aufgefordert wird, vor der Ausgabe einer Tool-Anfrage nachzudenken. Es kann aber auch einen plausiblen Wert ableiten.

  Wenn du beispielsweise bei einem `get_weather`-Tool, das einen `location`-Parameter erfordert, Claude fragst „Wie ist das Wetter?“, ohne einen Ort anzugeben, könnte Claude (insbesondere Claude Sonnet) Werte raten, die du nicht angegeben hast:

  ```json JSON
  {
    "type": "tool_use",
    "id": "toolu_01A09q90qw90lq917835lq9",
    "name": "get_weather",
    "input": { "location": "New York, NY", "unit": "fahrenheit" }
  }
  ```

  Dieses Verhalten ist nicht garantiert, insbesondere bei mehrdeutigeren Prompts und bei weniger leistungsfähigen Modellen.
</Accordion>

## Ein Tool auswählen

Für `type`-Strings, Versionen und Beta-Header siehe die [Tool-Referenz](https://platform.claude.com/docs/de/agents-and-tools/tool-use/tool-reference).

### Deine eigenen Tools

Bei Tools, die du definierst, schreibst du das Schema, und deine Anwendung führt jeden Aufruf aus.

<CardGroup cols={2}>
  <Card title="Tools definieren" icon="hammer" href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/define-tools">
    Lege Tool-Schemas fest, schreibe Beschreibungen und steuere, wann Claude deine Tools aufruft.
  </Card>

  <Card title="Tool-Aufrufe verarbeiten" icon="arrows-left-right" href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/handle-tool-calls">
    Parse `tool_use`-Blöcke, formatiere `tool_result`-Antworten und behandle Fehler.
  </Card>
</CardGroup>

### Client-Tools mit Anthropic-Schema

Anthropic veröffentlicht das Schema und trainiert Claude darauf. Deine Anwendung führt weiterhin jeden Aufruf aus und gibt das `tool_result` zurück.

<CardGroup cols={2}>
  <Card title="Memory-Tool" icon="brain" href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/memory-tool">
    Speichere und rufe Informationen über Gespräche hinweg in Dateien ab, die du kontrollierst.
  </Card>

  <Card title="Bash-Tool" icon="terminal" href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/bash-tool">
    Führe Shell-Befehle in einer persistenten Sitzung aus, die den Zustand beibehält.
  </Card>

  <Card title="Text-Editor-Tool" icon="edit" href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/text-editor-tool">
    Zeige Textdateien an und bearbeite sie, um Code zu debuggen, zu korrigieren und zu verbessern.
  </Card>

  <Card title="Computer-Use-Tool" icon="computer" href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/computer-use-tool">
    Erstelle Screenshots und steuere Maus und Tastatur in einer Desktop-Umgebung.
  </Card>

  <Card title="Browser-Use-Tool" icon="browser" href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/browser-use-tool">
    Navigiere, lies und interagiere mit Webseiten in deiner eigenen Browser-Umgebung.
  </Card>
</CardGroup>

### Server-Tools

Server-Tools laufen auf der Infrastruktur von Anthropic, ohne Handler-Code in deiner Anwendung. Siehe [Server-Tools](https://platform.claude.com/docs/de/agents-and-tools/tool-use/server-tools) für die gemeinsamen Mechanismen.

<CardGroup cols={2}>
  <Card title="Web-Search-Tool" icon="magnifying-glass" href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/web-search-tool">
    Durchsuche das Web nach Informationen jenseits des Wissensstichtags, mit zitierten Quellen.
  </Card>

  <Card title="Web-Fetch-Tool" icon="download" href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/web-fetch-tool">
    Rufe den vollständigen Inhalt angegebener Webseiten und PDF-Dokumente ab.
  </Card>

  <Card title="Code-Execution-Tool" icon="code" href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/code-execution-tool">
    Führe Python- und Bash-Code in einem Sandbox-Container aus, um Daten zu analysieren und Dateien zu erzeugen.
  </Card>

  <Card title="Advisor-Tool" icon="lightbulb" href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/advisor-tool">
    Lass ein schnelleres Executor-Modell während der Generierung ein intelligenteres Advisor-Modell konsultieren.
  </Card>

  <Card title="Tool-Search-Tool" icon="library" href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/tool-search-tool">
    Arbeite mit Tausenden von Tools, indem du sie bei Bedarf entdeckst und lädst.
  </Card>

  <Card title="MCP-Connector" icon="link" href="https://platform.claude.com/docs/de/agents-and-tools/mcp-connector">
    Verbinde dich über die Messages API mit entfernten MCP-Servern, ohne einen separaten MCP-Client.
  </Card>
</CardGroup>

<Note>
  [Claude Managed Agents](https://platform.claude.com/docs/de/managed-agents/overview) stellt ein integriertes Toolset bereit, das Claude innerhalb einer Sitzung autonom verwendet. Für dieses Toolset und die Managed-Agents-Methode zum Hinzufügen benutzerdefinierter Tools siehe die zugehörige Seite [Tools](https://platform.claude.com/docs/de/managed-agents/tools).
</Note>

## Preise

Anfragen mit „tool use“ (Tool-Nutzung) werden auf folgender Grundlage abgerechnet:

1. Die Gesamtzahl der an das Modell gesendeten Input-Token (einschließlich derer im Parameter `tools`)
2. Die Anzahl der generierten Output-Token
3. Bei serverseitigen Tools zusätzliche nutzungsbasierte Preise (zum Beispiel wird bei der Websuche pro durchgeführter Suche abgerechnet)

Clientseitige Tools werden genauso abgerechnet wie jede andere Claude-API-Anfrage, während bei serverseitigen Tools je nach ihrer spezifischen Nutzung zusätzliche Kosten anfallen können.

Die zusätzlichen Token durch Tool-Nutzung stammen aus:

* Dem Parameter `tools` in API-Anfragen (Tool-Namen, Beschreibungen und Schemas)
* `tool_use`-Inhaltsblöcken in API-Anfragen und -Antworten
* `tool_result`-Inhaltsblöcken in API-Anfragen

Wenn du `tools` verwendest, fügt die API außerdem automatisch einen speziellen „system prompt“ (System-Prompt) für das Modell hinzu, der die Tool-Nutzung ermöglicht. Die Anzahl der für jedes Modell erforderlichen Tool-Nutzungs-Token ist in der folgenden Tabelle aufgeführt (ohne die zuvor genannten zusätzlichen Token). Beachte, dass die Tabelle davon ausgeht, dass mindestens 1 Tool bereitgestellt wird. Wenn keine `tools` bereitgestellt werden, verbraucht eine Tool-Auswahl von `none` 0 zusätzliche System-Prompt-Token.

| Model                                                                                                                                | Tool use system prompt tokens: auto, none | Tool use system prompt tokens: any, tool |
| :----------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------- | :--------------------------------------- |
| Claude Opus 5.5                                                                                                                      | 286 tokens                                |                                          |
| Claude Opus 5                                                                                                                        | 286 tokens                                | 406 tokens                               |
| Claude Opus 4.8                                                                                                                      | 290 tokens                                | 410 tokens                               |
| Claude Opus 4.7                                                                                                                      | 675 tokens                                | 804 tokens                               |
| Claude Opus 4.6                                                                                                                      | 497 tokens                                | 589 tokens                               |
| Claude Opus 4.5                                                                                                                      | 496 tokens                                | 588 tokens                               |
| Claude Opus 4.1 ([retired, except on Bedrock and Google Cloud](https://platform.claude.com/docs/de/about-claude/model-deprecations)) | 313 tokens                                | 315 tokens                               |
| Claude Opus 4 ([retired, except on Google Cloud](https://platform.claude.com/docs/de/about-claude/model-deprecations))               | 313 tokens                                | 315 tokens                               |
| Claude Sonnet 5.5                                                                                                                    | 286 tokens                                |                                          |
| Claude Sonnet 5                                                                                                                      | 354 tokens                                | 474 tokens                               |
| Claude Sonnet 4.6                                                                                                                    | 497 tokens                                | 589 tokens                               |
| Claude Sonnet 4.5                                                                                                                    | 496 tokens                                | 588 tokens                               |
| Claude Sonnet 4 ([retired, except on Bedrock and Google Cloud](https://platform.claude.com/docs/de/about-claude/model-deprecations)) | 313 tokens                                | 315 tokens                               |
| Claude Haiku 5.5                                                                                                                     | 286 tokens                                | 406 tokens                               |
| Claude Haiku 4.5                                                                                                                     | 496 tokens                                | 588 tokens                               |
| Claude Haiku 3.5 ([retired, except on Google Cloud](https://platform.claude.com/docs/de/about-claude/model-deprecations))            | 264 tokens                                | 355 tokens                               |

* **auto, none:** The count when tool\_choice is auto or none.
* **any, tool:** The count when tool\_choice is any or tool.
* **Retired:** May still be available on other cloud platforms. See [Model deprecations](https://platform.claude.com/docs/de/about-claude/model-deprecations) for more.

Diese Token-Anzahlen werden zu deinen normalen Input- und Output-Token addiert, um die Gesamtkosten einer Anfrage zu berechnen.

Die aktuellen Preise pro Modell findest du in der Tabelle der [Modellübersicht](https://platform.claude.com/docs/de/models/overview#latest-models-comparison).

Wenn du einen Tool-Nutzungs-Prompt sendest, enthält die Antwort wie bei jeder anderen API-Anfrage sowohl die Anzahl der Input- als auch der Output-Token in den gemeldeten `usage`-Metriken.

Einige Server-Tools erheben zusätzlich zu den Token nutzungsbasierte Gebühren: Siehe [Web-Search-Tool](https://platform.claude.com/docs/de/agents-and-tools/tool-use/web-search-tool#usage-and-pricing) und [Code-Execution-Tool](https://platform.claude.com/docs/de/agents-and-tools/tool-use/code-execution-tool#usage-and-pricing) für deren Tarife.

## Nächste Schritte

<CardGroup cols={3}>
  <Card href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/how-tool-use-works" title="So funktioniert Tool-Nutzung" icon="compass">
    Verstehe die Tool-Nutzungsschleife, wo Tools ausgeführt werden und wann Tools statt Fließtext verwendet werden sollten.
  </Card>

  <Card href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/build-a-tool-using-agent" title="Tutorial: Einen Tool-nutzenden Agenten erstellen" icon="graduation-cap">
    Eine geführte Anleitung von einem einzelnen Tool-Aufruf bis zu einer produktionsreifen agentischen Schleife.
  </Card>

  <Card href="https://platform.claude.com/docs/de/agents-and-tools/tool-use/tool-reference" title="Tool-Referenz" icon="book">
    Verzeichnis der von Anthropic bereitgestellten Tools und Referenz für optionale Eigenschaften von Tool-Definitionen.
  </Card>
</CardGroup>
