> ## 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 Messages API に基づいて構築された基本的なチャットの例。

## 推奨エンドポイント

* [クロード /v1/messages](/ja/api-reference/endpoints/claude/text)

## 最低限のお願い

```json theme={null}
{
  "model": "claude-sonnet-4-20250514",
  "max_tokens": 1024,
  "system": "You are a concise assistant.",
  "messages": [
    {
      "role": "user",
      "content": [{ "type": "text", "text": "Summarize ApiGo in three sentences." }]
    }
  ]
}
```

## 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,
    "system": "You are a concise assistant.",
    "messages": [
      {
        "role": "user",
        "content": [{ "type": "text", "text": "Summarize ApiGo in three sentences." }]
      }
    ]
  }'
```

## Python の例

```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,
    system="You are a concise assistant.",
    messages=[
        {
            "role": "user",
            "content": [{"type": "text", "text": "Summarize ApiGo in three sentences."}],
        }
    ],
)

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,
  system: "You are a concise assistant.",
  messages: [
    {
      role: "user",
      content: [{ type: "text", text: "Summarize ApiGo in three sentences." }]
    }
  ]
});

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

## ベストプラクティス

* `system` は `messages` の一部ではなくトップレベルです
* 純粋なテキストチャットでもクロードのブロック構造を維持する
* 誤って切り捨てられるのを避けるために、`max_tokens` を明示的に設定します。
