Other Clients & Protocols

Anthropic compatible

The Messages endpoint, for the Anthropic SDK and Claude models.

For the official Anthropic SDK and clients using the Messages API, including Claude Code. The key’s group must support the Anthropic protocol.

Endpoint and authentication

YOUR_API_KEY in the examples is a placeholder and will not work as copied. Sign in to pick one of your keys and fill it into every example on this page.

Sign in to fill in key
SDK base_url
https://api.keyvia.cc

Root URL, without /v1

Messages
POST https://api.keyvia.cc/v1/messages

Three request headers are required:x-api-key: YOUR_API_KEY, anthropic-version: 2023-06-01, Content-Type: application/json. Alternatively, use Authorization: Bearer authentication.

The official SDK appends this path to base_url: /v1/messages. Use the root URL in the SDK and the full path for direct HTTP requests.

Minimal request

The reply is in content[0].text, max_tokens is required.

curl
curl https://api.keyvia.cc/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 256,
    "messages": [{ "role": "user", "content": "Reply only: Hello" }]
  }'
Python · pip install anthropic
import anthropic

client = anthropic.Anthropic(api_key="YOUR_API_KEY", base_url="https://api.keyvia.cc")
msg = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=256,
    messages=[{"role": "user", "content": "Reply only: Hello"}],
)
print(msg.content[0].text)
Node.js · npm install @anthropic-ai/sdk
import Anthropic from '@anthropic-ai/sdk'

const client = new Anthropic({ apiKey: 'YOUR_API_KEY', baseURL: 'https://api.keyvia.cc' })
const msg = await client.messages.create({
  model: 'claude-sonnet-5-5',
  max_tokens: 256,
  messages: [{ role: 'user', content: 'Reply only: Hello' }],
})
console.log(msg.content[0].text)

Streaming

Add this to the request body: "stream": true to receive SSE events. The SDK provides a messages.stream() helper:

Python
import anthropic

client = anthropic.Anthropic(api_key="YOUR_API_KEY", base_url="https://api.keyvia.cc")
with client.messages.stream(
    model="claude-sonnet-5-5",
    max_tokens=512,
    messages=[{"role": "user", "content": "Introduce yourself in one sentence"}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

System prompts and conversations

Put the system prompt in the top-level system field, not in messages. Append user and assistant messages alternately. Prompt caching and tool parameters are passed through to the upstream API.

Request body
{
  "model": "claude-sonnet-5-5",
  "max_tokens": 512,
  "system": "You are a concise coding assistant.",
  "messages": [
    {
      "role": "user",
      "content": "Write a Python function that checks whether a number is prime"
    },
    {
      "role": "assistant",
      "content": "def is_prime(n): ..."
    },
    {
      "role": "user",
      "content": "Add type annotations"
    }
  ]
}

See available models in the Model catalog; for failed requests, see Error codes.

KeyVia Logo
KeyVia

One API for full-power Claude, GPT, Gemini and other leading AI models at ultra-low prices.

© 2026 KeyVia. All rights reserved.