Ví dụ gọi Curl / SDK (giao diện tương thích Anthropic)
Muốn gọi trực tiếp trong chương trình hoặc script của riêng mình? Giao diện NextHub hoàn toàn tương thích với định dạng chính thức của Anthropic, chi phí di chuyển bằng không.
Ví dụ dòng lệnh Curl
bash
curl https://api.nexthub.cc/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: ApiKey của bạn" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 1024,
"messages": [
{ "role": "user", "content": "Xin chào, hãy giới thiệu về bản thân bạn" }
]
}'Ví dụ Python SDK
python
import anthropic
client = anthropic.Anthropic(
api_key="NextHub ApiKey của bạn",
base_url="https://api.nexthub.cc",
)
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Xin chào!"}]
)
print(message.content)Ví dụ Node.js SDK
javascript
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
apiKey: 'NextHub ApiKey của bạn',
baseURL: 'https://api.nexthub.cc',
});
const message = await client.messages.create({
model: 'claude-opus-5-5',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Xin chào!' }],
});
console.log(message.content);Di chuyển liền mạch
Chỉ cần thay https://api.anthropic.com trong tài liệu chính thức bằng https://api.nexthub.cc, các tham số khác giữ nguyên từng chữ là sử dụng bình thường.