Claude API ガイド
Anthropic Claude は Anthropic が開発した大規模言語モデルで、安全性と有用性で知られています。
インストール
- Python
- JavaScript
- curl
pip install anthropic
npm install @anthropic-ai/sdk
# curl は通常システムにあります。SDK のインストールは不要です
基本的な使い方
- Python
- JavaScript
- curl
import anthropic
client = anthropic.Anthropic(
api_key="your-api-key",
base_url="https://aisupermarket.work",
)
message = client.messages.create(
model="claude-opus-4-7",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, please introduce yourself"}
]
)
print(message.content[0].text)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: "your-api-key",
baseURL: "https://aisupermarket.work",
});
const message = await client.messages.create({
model: "claude-opus-4-7",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, please introduce yourself" }],
});
console.log(message.content[0].text);
curl https://aisupermarket.work/v1/messages \
-H "x-api-key: your-api-key" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-opus-4-7",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello, please introduce yourself"}]
}'
よく使うモデル
| モデル | 説明 |
|---|---|
claude-opus-4-7 | 最も強力で、複雑なタスク、コーディング、エージェントに適しています |
claude-opus-4-6 | 前世代の主力モデル |
claude-sonnet-4-6 | 多くの用途に適した速度と能力のバランス型モデル |