> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apigo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude 도구 호출 예

> Claude Messages API에 대한 도구 호출 예입니다.

## 권장 엔드포인트

* [클로드 /v1/messages](/ko/api-reference/endpoints/claude/text)

## 최소한의 요청

```json theme={null}
{
  "model": "claude-sonnet-4-20250514",
  "max_tokens": 1024,
  "tools": [
    {
      "name": "get_weather",
      "description": "Fetch weather",
      "input_schema": {
        "type": "object",
        "properties": {
          "city": { "type": "string" }
        },
        "required": ["city"]
      }
    }
  ],
  "messages": [
    {
      "role": "user",
      "content": [{ "type": "text", "text": "Get today's Shanghai weather." }]
    }
  ]
}
```

## cURL 예

```bash theme={null}
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-sonnet-4-20250514",
    "max_tokens": 1024,
    "tools": [
      {
        "name": "get_weather",
        "description": "Fetch weather",
        "input_schema": {
          "type": "object",
          "properties": {
            "city": { "type": "string" }
          },
          "required": ["city"]
        }
      }
    ],
    "messages": [
      {
        "role": "user",
        "content": [{ "type": "text", "text": "Get today's Shanghai weather." }]
      }
    ]
  }'
```

## 파이썬 예제

```python theme={null}
from anthropic import Anthropic

client = Anthropic(api_key="<ANTHROPIC_API_KEY>")

response = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    tools=[
        {
            "name": "get_weather",
            "description": "Fetch weather",
            "input_schema": {
                "type": "object",
                "properties": {
                    "city": {"type": "string"},
                },
                "required": ["city"],
            },
        }
    ],
    messages=[
        {
            "role": "user",
            "content": [{"type": "text", "text": "Get today's Shanghai weather."}],
        }
    ],
)

print(response.content[0].text)
```

## Node.js 예

```js theme={null}
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY,
});

const response = await client.messages.create({
  model: "claude-sonnet-4-20250514",
  max_tokens: 1024,
  tools: [
    {
      name: "get_weather",
      description: "Fetch weather",
      input_schema: {
        type: "object",
        properties: {
          city: { type: "string" }
        },
        required: ["city"]
      }
    }
  ],
  messages: [
    {
      role: "user",
      content: [{ type: "text", text: "Get today's Shanghai weather." }]
    }
  ]
});

console.log(response.content[0].text);
```

## 모범 사례

* 도구 결과를 `tool_result` 블록으로 다시 보내기
* 도구 호출 전에 반환된 보조 블록을 보존합니다.
* 명확한 도구 설명은 영리한 이름 지정보다 매개변수 안정성을 향상시킵니다.
