Claude Messages
The native endpoint uses POST /v1/messages, x-api-key, and anthropic-version. Its body and response differ from OpenAI Chat Completions.
curl
bash
# Claude native authentication uses x-api-key, not Authorization: Bearer.
curl https://sprelaytoken.com/v1/messages \
-H "x-api-key: $SPRELAY_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 what an API relay does."}
]
}'anthropic-version selects the protocol version. max_tokens is required and caps output length. JSON cannot contain comments, so preserve all quotes, commas, and brackets.
Python SDK
python
# Import the Anthropic SDK and read the key from the environment.
import os
from anthropic import Anthropic
# The Claude SDK appends /v1/messages to the root URL.
client = Anthropic(
api_key=os.environ["SPRELAY_API_KEY"],
base_url="https://sprelaytoken.com",
)
# max_tokens is required by the Messages API.
message = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=512,
messages=[
{"role": "user", "content": "Explain what an API relay does."}
],
)
# A plain-text response is stored in the first content block.
print(message.content[0].text)JavaScript SDK
javascript
// Import the Anthropic SDK after installing @anthropic-ai/sdk.
import Anthropic from '@anthropic-ai/sdk'
const client = new Anthropic({
apiKey: process.env.SPRELAY_API_KEY,
baseURL: 'https://sprelaytoken.com',
})
// The SDK builds the native /v1/messages request.
const message = await client.messages.create({
model: 'claude-sonnet-4-6',
max_tokens: 512,
messages: [{ role: 'user', content: 'Explain what an API relay does.' }],
})
// content is an array of typed blocks; inspect each type in production.
console.log(message.content)Claude system instructions normally use the top-level system field, not a system role inside messages. The response uses content blocks instead of OpenAI choices.
