Skip to content

Curl / SDK Examples (Anthropic-Compatible API) ​

Want to call it directly from your own programs or scripts? The NextHub API is fully compatible with the official Anthropic format, so migration costs nothing.

Curl Command-Line Example ​

bash
curl https://api.nexthub.cc/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: your ApiKey" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-opus-5-5",
    "max_tokens": 1024,
    "messages": [
      { "role": "user", "content": "Hello, introduce yourself" }
    ]
  }'

Python SDK Example ​

python
import anthropic

client = anthropic.Anthropic(
    api_key="your NextHub ApiKey",
    base_url="https://api.nexthub.cc",
)

message = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}]
)
print(message.content)

Node.js SDK Example ​

javascript
import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic({
  apiKey: 'your NextHub ApiKey',
  baseURL: 'https://api.nexthub.cc',
});

const message = await client.messages.create({
  model: 'claude-opus-5-5',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(message.content);

Seamless Migration

Replace https://api.anthropic.com from the official documentation with https://api.nexthub.cc, keep every other parameter unchanged, and everything just works.

NextHub · Direct connections to OpenAI / Anthropic via official account pools — reliable, secure, and worry-free.