[Docs] Add Anthropic-compatible API documentation (#28522)
Co-authored-by: zijiexia <37504505+zijiexia@users.noreply.github.com> Co-authored-by: Zijie Xia <zijie.xia@radixark.ai> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
zijiexia
Zijie Xia
Claude Opus 4.8
parent
be774d0acd
commit
018d0c21dc
@@ -201,3 +201,27 @@ Tool calls: [
|
||||
### 3.3 HiCache (Hierarchical KV Caching)
|
||||
|
||||
For long-context, prefix-heavy workloads, enable hierarchical KV caching to spill cold KV blocks to host memory (toggle the **Hierarchical KV Cache** card in the [Playground above](#playground)). Useful given GLM-5.2's 1M-token window; pair `--hicache-ratio` with a write policy that matches your reuse pattern.
|
||||
|
||||
### 3.4 Claude Code Integration
|
||||
|
||||
GLM-5.2's strong reasoning + tool-calling makes it a good backend for [Claude Code](https://code.claude.com/docs/en/overview), Anthropic's agentic CLI. SGLang exposes the Anthropic-compatible `/v1/messages` endpoint on every server, so Claude Code can talk to a GLM-5.2 server with only environment variables — no code change. Launch the server with `--reasoning-parser glm45 --tool-call-parser glm47` (any recipe from the Deployment panel above works), then:
|
||||
|
||||
```bash Command
|
||||
export ANTHROPIC_BASE_URL="http://127.0.0.1:30000"
|
||||
export ANTHROPIC_AUTH_TOKEN="dummy"
|
||||
export API_TIMEOUT_MS="3000000"
|
||||
export CLAUDE_CODE_AUTO_COMPACT_WINDOW="1000000"
|
||||
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
|
||||
export CLAUDE_CODE_ATTRIBUTION_HEADER=0
|
||||
export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-5.2[1m]"
|
||||
export ANTHROPIC_DEFAULT_SONNET_MODEL="glm-5.2[1m]"
|
||||
export ANTHROPIC_DEFAULT_OPUS_MODEL="glm-5.2[1m]"
|
||||
claude
|
||||
```
|
||||
|
||||
Two of these matter specifically for GLM-5.2:
|
||||
|
||||
- **`CLAUDE_CODE_ATTRIBUTION_HEADER=0`** — Claude Code prepends a per-request attribution block to the system prompt. GLM-5.2's chat template renders `tools` **before** `system`, so that per-request hash is the first token to diverge between turns and the radix prefix cache re-prefills the whole system + history every turn. This env removes the block and restores prefix-cache reuse.
|
||||
- **`glm-5.2[1m]`** as the model name — the `[1m]` suffix is the client-side hint that enables Claude Code's 1M-context beta, matching GLM-5.2's 1,048,576-token window. Without it, context is capped well below 1M. SGLang does not validate the `model` field, so any name is accepted server-side.
|
||||
|
||||
For the full setup (streaming, tool-use, count_tokens, persisting env in `~/.claude/settings.json`, troubleshooting), see [Anthropic-Compatible API](../../../docs/basic_usage/anthropic_api).
|
||||
|
||||
Reference in New Issue
Block a user