Guides
Anthropic compatibility
What is identical, what differs, and how to point an Anthropic-shaped client at Stac.
Stac also implements Anthropic's Messages API, so Claude-native tools and the
anthropic SDK work against your stack without translating requests to the
OpenAI shape.
const client = new Anthropic({
- baseURL: "https://api.anthropic.com",
- apiKey: process.env.ANTHROPIC_API_KEY,
+ baseURL: "https://api.trystac.com",
+ apiKey: process.env.STAC_API_KEY,
});Building against the OpenAI shape instead? See OpenAI compatibility — same underlying model, different request/response format.
Supported
| Feature | Status |
|---|---|
POST /v1/messages | Full |
POST /v1/messages/count_tokens | Full |
| Streaming (SSE, Anthropic event format) | Full |
| Tool use | Full |
| Image content blocks | Model-dependent — check capabilities on GET /v1/models |
x-api-key and Authorization: Bearer auth | Both accepted |
Prompt caching (cache_control) | Accepted, no effect — there's no per-token meter for it to save you money against |
Differences that matter
modelis always ignored. Your stack has exactly one model assigned; any value you send is replaced with it — required in the request body only because the Anthropic format expects the field.max_tokensis clamped, not just required. Requests are floored at 8000 and capped at 16000 — see Messages.systemreplaces your stack's configuration, the same rule as chat completions: send nosystemto keep your stack's configured prompt and knowledge base; send one (non-empty) to override both for that request. See Core concepts.- Rate limiting is per key, not per tier. See Errors & rate limits.
Unknown parameters are ignored rather than rejected, so a newer SDK version stays compatible with an older gateway.
CLI tools
Claude Code
Claude Code assumes a 200k context window and only discovers your plan's real
limit when a call gets rejected — set CLAUDE_CODE_AUTO_COMPACT_WINDOW so it
compacts proactively instead:
export ANTHROPIC_BASE_URL="https://api.trystac.com"
export ANTHROPIC_AUTH_TOKEN="your-stac-api-key"
export ANTHROPIC_API_KEY=""
export ANTHROPIC_MODEL="your-stack-model"
export ANTHROPIC_DEFAULT_SONNET_MODEL="$ANTHROPIC_MODEL"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="$ANTHROPIC_MODEL"
export ANTHROPIC_DEFAULT_OPUS_MODEL="$ANTHROPIC_MODEL"
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=104000
claudecurl "$ANTHROPIC_BASE_URL/v1/messages" \
-H "x-api-key: $ANTHROPIC_AUTH_TOKEN" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "your-stack-model",
"max_tokens": 1024,
"messages": [{ "role": "user", "content": "Hello" }]
}'{
"env": {
"ANTHROPIC_BASE_URL": "https://api.trystac.com",
"ANTHROPIC_AUTH_TOKEN": "your-stac-api-key",
"ANTHROPIC_API_KEY": "",
"ANTHROPIC_MODEL": "your-stack-model",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "your-stack-model",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "your-stack-model",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "your-stack-model",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "104000"
}
}Bash exports last only for the current shell session — good for trying
Stac quickly. Curl confirms your key and base URL actually work before
you point Claude Code at them. For a setup that survives new terminals, use
the JSON tab in ~/.claude/settings.json (your user config, not the
project's .claude/settings.json, which is usually committed to git) —
values must be strings there, and there's no variable interpolation, so the
model name is repeated across the four model fields.
104000 matches a 131072-token window, leaving room for two things: the
response itself, and one large turn after Claude Code decides to compact. That
second reserve matters — the decision is made from the previous turn's
context, and a single 60 KB file read is ~18k tokens, enough to blow past the
limit before the next request is even sent. Adjust it if your plan's window
(visible via GET /v1/models) is different. If
context still overflows, use /clear rather than /compact — /compact
resends the whole conversation, which is exactly what no longer fits.
Whichever method you use, exporting these as global shell variables (in
~/.zshrc or ~/.bashrc) repoints every Anthropic-shaped tool on the
machine at your stack, not just Claude Code.

