Nbility logoNbility Docs

Search documentation

Search guides and API reference content

POST /v1/messages — Native Anthropic Claude API format

Endpoint

POST /v1/messages

Overview

This endpoint accepts the native Anthropic Claude Messages API format. Use this if you're already using the Anthropic SDK or want to use Claude-specific features like extended thinking.

Authentication

x-api-key: YOUR_API_KEY
anthropic-version: 2023-06-01

Request Body

NameTypeRequiredDefaultDescription
modelstringyesClaude model, e.g. "claude-opus-4-5", "claude-sonnet-4-5"
max_tokensintegeryesMaximum tokens to generate
messagesarrayyesArray of message objects (role + content)
systemstring | arraynoSystem prompt (string or content block array)
streambooleannofalseEnable streaming
temperaturenumbernoSampling temperature (0–1)
top_pnumbernoNucleus sampling threshold
top_kintegernoTop-K sampling
thinkingobjectnoEnable extended thinking: {"type":"enabled","budget_tokens":10000}

Example

cURL

curl https://api.nbility.dev/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Explain the theory of relativity briefly."}
    ]
  }'

Python

import anthropic

client = anthropic.Anthropic(
    api_key="YOUR_API_KEY",
    base_url="https://api.nbility.dev"
)

message = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Explain the theory of relativity briefly."}
    ]
)
print(message.content[0].text)

Response

{
  "id": "msg_abc123",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "The theory of relativity..."
    }
  ],
  "model": "claude-sonnet-4-5",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 15,
    "output_tokens": 120
  }
}

Note You can also use Claude models via the standard /v1/chat/completions endpoint using Authorization: Bearer authentication — no format conversion needed.