Nbility logoNbility Docs

Search documentation

Search guides and API reference content

POST /v1/messages accepts the Anthropic Messages format. Existing Anthropic SDK applications can preserve native structures such as system, content blocks, tool calls, and streaming events while changing only the Base URL and API key.

Basic request

curl https://api.nbility.ai/v1/messages \
  -H "x-api-key: $NBILITY_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 512,
    "messages": [
      {"role": "user", "content": "Explain API gateways in two sentences."}
    ]
  }'

Python SDK

import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ["NBILITY_API_KEY"],
    base_url="https://api.nbility.ai",
)

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=512,
    messages=[{"role": "user", "content": "Summarize this in two lines."}],
)
print(message.content[0].text)

Common fields

FieldRequiredDescription
modelyesClaude model ID from the live catalog
max_tokensyesMaximum output tokens
messagesyesArray of user and assistant messages
systemnoString or system content blocks; do not use system as a message role
streamnoReturns Anthropic-style streaming events
tools / tool_choicenoTool definitions and selection policy
thinkingnoExtended-thinking configuration, only when supported by the model and channel

Nbility preserves the Anthropic format where possible, but caching, extended thinking, tool details, beta headers, and newly introduced fields may vary by channel. If a native field is unsupported, use Chat Completions, or configure Nbility directly in Claude Code.