Capabilities
Native protocols
Use Anthropic Messages and Gemini request shapes without converting them to OpenAI-compatible JSON.
On this page
This page is for developers who already use the Anthropic Messages or Google Gemini protocol and want to keep that request shape.
Anthropic Messages#
Use the base URL https://api.clssai.com without /v1, then call POST /v1/messages; POST /anthropic/v1/messages is an equivalent path. Authenticate with x-api-key or Bearer and always send the required anthropic-version: 2023-06-01 header. The gateway supplies metadata.user_id only when missing and removes a beta query parameter. Send optional beta declarations through the standard Anthropic header instead.
Anthropic routes use Anthropic-native model names such as the verified claude-haiku-4-5. The gateway also maps a few dotted aliases (claude-opus-4.8 resolves to claude-opus-4-8), but coverage is partial: claude-haiku-4.5 returns 404, and OpenAI-compatible IDs such as anthropic/claude-haiku-4.5 are never valid here. Send the hyphenated native name from public GET /anthropic/v1/models and confirm it in the response model field.
curl https://api.clssai.com/v1/messages \
-H "x-api-key: $CLSSAI_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"claude-haiku-4-5","max_tokens":128,"messages":[{"role":"user","content":"Reply with OK."}]}'The Anthropic SDK appends /v1/messages, so its base_url must not contain /v1.
import os
from anthropic import Anthropic
client = Anthropic(
base_url="https://api.clssai.com",
api_key=os.environ["CLSSAI_API_KEY"],
)
message = client.messages.create(
model="claude-haiku-4-5",
max_tokens=128,
messages=[{"role": "user", "content": "Reply with OK."}],
)
print(message.content[0].text)Prompt caching#
The gateway passes cache_control through unchanged and does not rewrite it. In a verified claude-haiku-4-5 request, the first response reported cache_creation_input_tokens: 4812 and cache_read_input_tokens: 0. The next three consecutive requests kept the same system prefix and changed only the user message; all three reported cache_read_input_tokens: 4812.
Upstream models impose a minimum cacheable prefix length. The Haiku tier has a 2048-token minimum; a shorter prefix does not create a cache entry. This threshold is set by the upstream model, not by the gateway.
Count tokens#
POST /v1/messages/count_tokens uses a dedicated upstream credential. These calls are not billed and are not written to request logs. The anthropic-version header is required here too.
curl https://api.clssai.com/v1/messages/count_tokens \
-H "x-api-key: $CLSSAI_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"claude-haiku-4-5","messages":[{"role":"user","content":"Count this input."}]}'Google Gemini#
Use the base URL https://api.clssai.com/v1beta. The gateway forwards Gemini request bodies without rewriting them. Send the key with the standard x-goog-api-key header or a ?key= query parameter. Bearer authentication is not accepted. Gemini routes use Google-native model names; gemini-3.1-flash-lite has been verified. List current names with public GET /v1beta/models.
curl https://api.clssai.com/v1beta/models/gemini-3.1-flash-lite:generateContent \
-H "x-goog-api-key: $CLSSAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents":[{"parts":[{"text":"Reply with OK."}]}]}'import os
import requests
response = requests.post(
"https://api.clssai.com/v1beta/models/gemini-3.1-flash-lite:generateContent",
headers={"x-goog-api-key": os.environ["CLSSAI_API_KEY"], "Content-Type": "application/json"},
json={"contents": [{"parts": [{"text": "Reply with OK."}]}]},
timeout=120,
)
response.raise_for_status()
print(response.json())const response = await fetch(
"https://api.clssai.com/v1beta/models/gemini-3.1-flash-lite:generateContent",
{
method: "POST",
headers: { "x-goog-api-key": process.env.CLSSAI_API_KEY, "Content-Type": "application/json" },
body: JSON.stringify({ contents: [{ parts: [{ text: "Reply with OK." }] }] }),
},
);
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());Common mistakes#
- Do not add
/v1to the Anthropic SDKbase_url; the SDK adds it. - Do not omit the required
anthropic-version: 2023-06-01header. - Do include
/v1in an OpenAI SDK base URL. - Authenticate Gemini with
x-goog-api-keyor?key=, not a Bearer token. - Use
GET /anthropic/v1/modelsorGET /v1beta/modelsand send the protocol's native model name. Do not reuse an OpenAI-compatibleauthor/modelID. - Run SDK and fetch calls on a server; a browser call exposes the key to every visitor.
- Check empty OpenAI-compatible streaming
choicesarrays and usecf-rayto trace inference.
Find answers to common questions or diagnose a failed request.
Frequently asked questions →Troubleshoot errors →