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.

client.tsdiff
  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,
  });

Supported

FeatureStatus
POST /v1/messagesFull
POST /v1/messages/count_tokensFull
Streaming (SSE, Anthropic event format)Full
Tool useFull
Image content blocksModel-dependent — check capabilities on GET /v1/models
x-api-key and Authorization: Bearer authBoth accepted
Prompt caching (cache_control)Accepted, no effect — there's no per-token meter for it to save you money against

Differences that matter

  • model is 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_tokens is clamped, not just required. Requests are floored at 8000 and capped at 16000 — see Messages.
  • system replaces your stack's configuration, the same rule as chat completions: send no system to 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.

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:

bash
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
claude

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.