Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/antigmalabs_ante-preview.json
T

1 line
29 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"repo": "antigmalabs/ante-preview", "files": {"docs-site/docs/antix/concepts/routing.md": {"485f037514ac52cdb36b0a5d467b9d32424832b3": {"t": 1785746548.1169221, "n": 4532, "h": "0a40eb06fcbfed13", "c": "---\ntitle: \"Routing & BYOK\"\ndescription: \"Endpoints, multi-protocol SDK compatibility, and Bring Your Own Key semantics.\"\nsidebar_position: 1\n---\n\n# Routing & BYOK\n\nAntix is a multi-protocol gateway. It accepts requests in OpenAI, Anthropic, and Gemini shapes and normalizes streaming across upstream providers including Anthropic, Google Gemini, Alibaba Qwen, DeepSeek, Zai (GLM), xAI, and OpenAI.\n\n## Supported endpoints\n\n| Endpoint | Method | Protocol |\n|---|---|---|\n| `/v1/chat/completions` | POST | OpenAI Chat Completions |\n| `/v1/responses` | POST | OpenAI Responses API |\n| `/v1/messages` | POST | Anthropic Messages |\n| `/v1/messages/count_tokens` | POST | Anthropic token counter |\n| `/v1/models/{action}` | POST | Gemini native (`:generateContent`, `:streamGenerateContent`) |\n| `/v1beta/models/{action}` | POST | Gemini v1beta native path |\n| `/v1/models`, `/models` | GET | Public model catalog (no auth) |\n| `/v2/model/info` | GET | Catalog with pricing |\n\n`/v1/embeddings`, audio, images, files, fine-tuning, and the batch API are **not** supported.\n\n## Drop-in SDK compatibility\n\nPoint any OpenAI, Anthropic, or Gemini SDK at Antix by changing the base URL and swapping in your Virtual Key. The proxy translates provider-specific quirks and keeps SSE streaming predictable.\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n base_url=\"https://antix.antigma.ai/v1\",\n api_key=\"sk-antix-<your-key>\",\n)\n\nresponse = client.chat.completions.create(\n model=\"claude-sonnet-4-6\",\n messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n stream=True,\n)\n```\n\nA streaming pipeline normalizes SSE events across providers so token deltas, tool calls, and stop reasons arrive in a consistent shape regardless of upstream.\n\n### Claude Code\n\nClaude Code uses the Anthropic SDK internally, so redirecting it at Antix takes one environment variable:\n\n```bash\nexport ANTHROPIC_BASE_URL=\"https://antix.antigma.ai\"\n```\n\nThat's it — Claude Code's SDK reads both and routes all `/v1/messages` traffic to Antix, which passes it through to Anthropic with your platform key substituted.\n\n## Bring Your Own Key (BYOK)\n\nIf you have negotiated direct rates with a provider but still want Antix's observability and routing, use BYOK. Send your provider key in `Authorization` and declare the provider with `X-Antix-Provider`:\n\n```bash\ncurl -X POST https://antix.antigma.ai/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer YOUR_ALIBABA_DASHSCOPE_KEY\" \\\n -H \"X-Antix-Provider: alibaba\" \\\n -d '{\n \"model\": \"qwen-max\",\n \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]\n }'\n```\n\nBYOK traffic is not re-billed by Antix. It is still tracked for observability.\n\n### Supported providers\n\nAntix normalizes requests across these upstream providers. Route to any of them by model name (Antix infers the provider) or explicitly via `X-Antix-Provider`:\n\n| Provider | Notable models | Accepted `X-Antix-Provider` values | Notes |\n|---|---|---|---|\n| **Anthropic** | Claude Sonnet, Opus, Haiku | `anthropic` | Native `/v1/messages` support. |\n| **OpenAI** | GPT-5.x | `openai` | Native `/v1/chat/completions` and `/v1/responses` support. |\n| **Google Gemini** | Gemini 3.x | `google`, `gemini`, `google_ai_studio_gemini` | Native Gemini protocol at `/v1/models/{action}` and `/v1beta`. |\n| **xAI** | Grok | `xai`, `x-ai` | OpenAI-compatible upstream. |\n| **Alibaba Qwen** | `qwen3-max`, `qwen3-coder-plus`, `qwen3-coder-flash`, `qwq-plus`, `qwen-plus`, `qwen-max`, and more | `alibaba`, `qwen`, `dashscope` | Routed via DashScope. No distinctive key prefix — you **must** set `X-Antix-Provider` on BYOK calls. |\n| **DeepSeek** | `deepseek-chat` (V3), `deepseek-reasoner` (R1), `deepseek-v4-pro`, `deepseek-v4-flash` | `deepseek` | OpenAI-compatible upstream API. `deepseek-reasoner` returns a `reasoning_content` field alongside the final answer. |\n| **Zai (GLM)** | `glm-5.2`, `glm-5.1`, `glm-4.7` | `zai` | Zhipu AI's GLM model family, OpenAI-compatible upstream. No distinctive key prefix — you **must** set `X-Antix-Provider` on BYOK calls. |\n\n:::note Provider inference\nWhen the header is omitted, Antix infers the provider from the key prefix (e.g., `sk-ant-…` → Anthropic, `sk-…` → OpenAI). Some keys (like Alibaba/DashScope or Zai) may have no distinctive prefix — you **must** set `X-Antix-Provider` for those requests, otherwise they will fail upstream with `401 Unauthorized`.\n:::\n\nSee [Models API](/antix/concepts/models) to list exactly which models your gateway currently serves.\n"}, "ed5bc5390033dc28b138b80fe7660f50229084e8": {"t": 1785765521.4678807, "n": 4532, "h": "0a40eb06fcbfed13", "c": "---\ntitle: \"Routing & BYOK\"\ndescription: \"Endpoints, multi-protocol SDK compatibility, and Bring Your Own Key semantics.\"\nsidebar_position: 1\n---\n\n# Routing & BYOK\n\nAntix is a multi-protocol gateway. It accepts requests in OpenAI, Anthropic, and Gemini shapes and normalizes streaming across upstream providers including Anthropic, Google Gemini, Alibaba Qwen, DeepSeek, Zai (GLM), xAI, and OpenAI.\n\n## Supported endpoints\n\n| Endpoint | Method | Protocol |\n|---|---|---|\n| `/v1/chat/completions` | POST | OpenAI Chat Completions |\n| `/v1/responses` | POST | OpenAI Responses API |\n| `/v1/messages` | POST | Anthropic Messages |\n| `/v1/messages/count_tokens` | POST | Anthropic token counter |\n| `/v1/models/{action}` | POST | Gemini native (`:generateContent`, `:streamGenerateContent`) |\n| `/v1beta/models/{action}` | POST | Gemini v1beta native path |\n| `/v1/models`, `/models` | GET | Public model catalog (no auth) |\n| `/v2/model/info` | GET | Catalog with pricing |\n\n`/v1/embeddings`, audio, images, files, fine-tuning, and the batch API are **not** supported.\n\n## Drop-in SDK compatibility\n\nPoint any OpenAI, Anthropic, or Gemini SDK at Antix by changing the base URL and swapping in your Virtual Key. The proxy translates provider-specific quirks and keeps SSE streaming predictable.\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n base_url=\"https://antix.antigma.ai/v1\",\n api_key=\"sk-antix-<your-key>\",\n)\n\nresponse = client.chat.completions.create(\n model=\"claude-sonnet-4-6\",\n messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n stream=True,\n)\n```\n\nA streaming pipeline normalizes SSE events across providers so token deltas, tool calls, and stop reasons arrive in a consistent shape regardless of upstream.\n\n### Claude Code\n\nClaude Code uses the Anthropic SDK internally, so redirecting it at Antix takes one environment variable:\n\n```bash\nexport ANTHROPIC_BASE_URL=\"https://antix.antigma.ai\"\n```\n\nThat's it — Claude Code's SDK reads both and routes all `/v1/messages` traffic to Antix, which passes it through to Anthropic with your platform key substituted.\n\n## Bring Your Own Key (BYOK)\n\nIf you have negotiated direct rates with a provider but still want Antix's observability and routing, use BYOK. Send your provider key in `Authorization` and declare the provider with `X-Antix-Provider`:\n\n```bash\ncurl -X POST https://antix.antigma.ai/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer YOUR_ALIBABA_DASHSCOPE_KEY\" \\\n -H \"X-Antix-Provider: alibaba\" \\\n -d '{\n \"model\": \"qwen-max\",\n \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]\n }'\n```\n\nBYOK traffic is not re-billed by Antix. It is still tracked for observability.\n\n### Supported providers\n\nAntix normalizes requests across these upstream providers. Route to any of them by model name (Antix infers the provider) or explicitly via `X-Antix-Provider`:\n\n| Provider | Notable models | Accepted `X-Antix-Provider` values | Notes |\n|---|---|---|---|\n| **Anthropic** | Claude Sonnet, Opus, Haiku | `anthropic` | Native `/v1/messages` support. |\n| **OpenAI** | GPT-5.x | `openai` | Native `/v1/chat/completions` and `/v1/responses` support. |\n| **Google Gemini** | Gemini 3.x | `google`, `gemini`, `google_ai_studio_gemini` | Native Gemini protocol at `/v1/models/{action}` and `/v1beta`. |\n| **xAI** | Grok | `xai`, `x-ai` | OpenAI-compatible upstream. |\n| **Alibaba Qwen** | `qwen3-max`, `qwen3-coder-plus`, `qwen3-coder-flash`, `qwq-plus`, `qwen-plus`, `qwen-max`, and more | `alibaba`, `qwen`, `dashscope` | Routed via DashScope. No distinctive key prefix — you **must** set `X-Antix-Provider` on BYOK calls. |\n| **DeepSeek** | `deepseek-chat` (V3), `deepseek-reasoner` (R1), `deepseek-v4-pro`, `deepseek-v4-flash` | `deepseek` | OpenAI-compatible upstream API. `deepseek-reasoner` returns a `reasoning_content` field alongside the final answer. |\n| **Zai (GLM)** | `glm-5.2`, `glm-5.1`, `glm-4.7` | `zai` | Zhipu AI's GLM model family, OpenAI-compatible upstream. No distinctive key prefix — you **must** set `X-Antix-Provider` on BYOK calls. |\n\n:::note Provider inference\nWhen the header is omitted, Antix infers the provider from the key prefix (e.g., `sk-ant-…` → Anthropic, `sk-…` → OpenAI). Some keys (like Alibaba/DashScope or Zai) may have no distinctive prefix — you **must** set `X-Antix-Provider` for those requests, otherwise they will fail upstream with `401 Unauthorized`.\n:::\n\nSee [Models API](/antix/concepts/models) to list exactly which models your gateway currently serves.\n"}, "e153ed13c7b6ff40d5978ee3801a7c72d0ac4ce1": {"t": 1785765522.7181826, "n": 3287, "h": "bde36f118901ee73", "c": "---\ntitle: \"Routing & BYOK\"\ndescription: \"Endpoints, multi-protocol SDK compatibility, and Bring Your Own Key semantics.\"\nsidebar_position: 1\n---\n\n# Routing & BYOK\n\nAntix is a multi-protocol gateway. It accepts requests in OpenAI, Anthropic, and Gemini shapes and normalizes streaming across upstream providers including Anthropic, Google Gemini, Alibaba Qwen, xAI, and OpenAI.\n\n## Supported endpoints\n\n| Endpoint | Method | Protocol |\n|---|---|---|\n| `/v1/chat/completions` | POST | OpenAI Chat Completions |\n| `/v1/responses` | POST | OpenAI Responses API |\n| `/v1/messages` | POST | Anthropic Messages |\n| `/v1/messages/count_tokens` | POST | Anthropic token counter |\n| `/v1/models/{action}` | POST | Gemini native (`:generateContent`, `:streamGenerateContent`) |\n| `/v1beta/models/{action}` | POST | Gemini v1beta native path |\n| `/v1/models`, `/models` | GET | Public model catalog (no auth) |\n| `/v2/model/info` | GET | Catalog with pricing |\n\n`/v1/embeddings`, audio, images, files, fine-tuning, and the batch API are **not** supported.\n\n## Drop-in SDK compatibility\n\nPoint any OpenAI, Anthropic, or Gemini SDK at Antix by changing the base URL and swapping in your Virtual Key. The proxy translates provider-specific quirks and keeps SSE streaming predictable.\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n base_url=\"https://antix.antigma.ai/v1\",\n api_key=\"sk-antix-<your-key>\",\n)\n\nresponse = client.chat.completions.create(\n model=\"claude-sonnet-4-6\",\n messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n stream=True,\n)\n```\n\nA streaming pipeline normalizes SSE events across providers so token deltas, tool calls, and stop reasons arrive in a consistent shape regardless of upstream.\n\n### Claude Code\n\nClaude Code uses the Anthropic SDK internally, so redirecting it at Antix takes one environment variable:\n\n```bash\nexport ANTHROPIC_BASE_URL=\"https://antix.antigma.ai\"\n```\n\nThat's it — Claude Code's SDK reads both and routes all `/v1/messages` traffic to Antix, which passes it through to Anthropic with your platform key substituted.\n\n## Bring Your Own Key (BYOK)\n\nIf you have negotiated direct rates with a provider but still want Antix's observability and routing, use BYOK. Send your provider key in `Authorization` and declare the provider with `X-Antix-Provider`:\n\n```bash\ncurl -X POST https://antix.antigma.ai/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer YOUR_ALIBABA_DASHSCOPE_KEY\" \\\n -H \"X-Antix-Provider: alibaba\" \\\n -d '{\n \"model\": \"qwen-max\",\n \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]\n }'\n```\n\nBYOK traffic is not re-billed by Antix. It is still tracked for observability.\n\n### Accepted `X-Antix-Provider` values\n\n| Provider | Accepted values |\n|---|---|\n| OpenAI | `openai` |\n| Anthropic | `anthropic` |\n| Google Gemini | `google`, `gemini`, `google_ai_studio_gemini` |\n| xAI | `xai`, `x-ai` |\n| Alibaba / DashScope | `alibaba`, `qwen`, `dashscope` |\n\n:::note Provider inference\nWhen the header is omitted, Antix infers the provider from the key prefix (e.g., `sk-ant-…` → Anthropic, `sk-…` → OpenAI). Alibaba/DashScope keys have no distinctive prefix — you **must** set `X-Antix-Provider` for those requests, otherwise they will fail upstream with `401 Unauthorized`.\n:::\n"}, "f4b8d759b6080f1994ccf48f82c6c1f2e7219365": {"t": 1785765524.0007632, "n": 2934, "h": "e822848b112c603a", "c": "---\ntitle: \"Routing & BYOK\"\ndescription: \"Endpoints, multi-protocol SDK compatibility, and Bring Your Own Key semantics.\"\nsidebar_position: 1\n---\n\n# Routing & BYOK\n\nAntix is a multi-protocol gateway. It accepts requests in OpenAI, Anthropic, and Gemini shapes and normalizes streaming across upstream providers including Anthropic, Google Gemini, Alibaba Qwen, xAI, and OpenAI.\n\n## Supported endpoints\n\n| Endpoint | Method | Protocol |\n|---|---|---|\n| `/v1/chat/completions` | POST | OpenAI Chat Completions |\n| `/v1/responses` | POST | OpenAI Responses API |\n| `/v1/messages` | POST | Anthropic Messages |\n| `/v1/messages/count_tokens` | POST | Anthropic token counter |\n| `/v1/models/{action}` | POST | Gemini native (`:generateContent`, `:streamGenerateContent`) |\n| `/v1beta/models/{action}` | POST | Gemini v1beta native path |\n| `/v1/models`, `/models` | GET | Public model catalog (no auth) |\n| `/v2/model/info` | GET | Catalog with pricing |\n\n`/v1/embeddings`, audio, images, files, fine-tuning, and the batch API are **not** supported.\n\n## Drop-in SDK compatibility\n\nPoint any OpenAI, Anthropic, or Gemini SDK at Antix by changing the base URL and swapping in your Virtual Key. The proxy translates provider-specific quirks and keeps SSE streaming predictable.\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n base_url=\"https://antix.antigma.ai/v1\",\n api_key=\"sk-antix-<your-key>\",\n)\n\nresponse = client.chat.completions.create(\n model=\"claude-sonnet-4-6\",\n messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n stream=True,\n)\n```\n\nA streaming pipeline normalizes SSE events across providers so token deltas, tool calls, and stop reasons arrive in a consistent shape regardless of upstream.\n\n## Bring Your Own Key (BYOK)\n\nIf you have negotiated direct rates with a provider but still want Antix's observability and routing, use BYOK. Send your provider key in `Authorization` and declare the provider with `X-Antix-Provider`:\n\n```bash\ncurl -X POST https://antix.antigma.ai/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer YOUR_ALIBABA_DASHSCOPE_KEY\" \\\n -H \"X-Antix-Provider: alibaba\" \\\n -d '{\n \"model\": \"qwen-max\",\n \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]\n }'\n```\n\nBYOK traffic is not re-billed by Antix. It is still tracked for observability.\n\n### Accepted `X-Antix-Provider` values\n\n| Provider | Accepted values |\n|---|---|\n| OpenAI | `openai` |\n| Anthropic | `anthropic` |\n| Google Gemini | `google`, `gemini`, `google_ai_studio_gemini` |\n| xAI | `xai`, `x-ai` |\n| Alibaba / DashScope | `alibaba`, `qwen`, `dashscope` |\n\n:::note Provider inference\nWhen the header is omitted, Antix infers the provider from the key prefix (e.g., `sk-ant-…` → Anthropic, `sk-…` → OpenAI). Alibaba/DashScope keys have no distinctive prefix — you **must** set `X-Antix-Provider` for those requests, otherwise they will fail upstream with `401 Unauthorized`.\n:::\n"}, "5b2e6eb53f6410981f51472557a2c94f1f91fd7e": {"t": 1785765525.2715085, "n": 2939, "h": "ef8784f4717b3670", "c": "---\ntitle: \"Routing & BYOK\"\ndescription: \"Endpoints, multi-protocol SDK compatibility, and Bring Your Own Key semantics.\"\nsidebar_position: 1\n---\n\n# Routing & BYOK\n\nAntix is a multi-protocol gateway. It accepts requests in OpenAI, Anthropic, and Gemini shapes and normalizes streaming across upstream providers including Anthropic, Google Gemini, Alibaba Qwen, xAI, and OpenAI.\n\n## Supported endpoints\n\n| Endpoint | Method | Protocol |\n|---|---|---|\n| `/v1/chat/completions` | POST | OpenAI Chat Completions |\n| `/v1/responses` | POST | OpenAI Responses API |\n| `/v1/messages` | POST | Anthropic Messages |\n| `/v1/messages/count_tokens` | POST | Anthropic token counter |\n| `/v1/models/{action}` | POST | Gemini native (`:generateContent`, `:streamGenerateContent`) |\n| `/v1beta/models/{action}` | POST | Gemini v1beta native path |\n| `/v1/models`, `/models` | GET | Public model catalog (no auth) |\n| `/v2/model/info` | GET | Catalog with pricing |\n\n`/v1/embeddings`, audio, images, files, fine-tuning, and the batch API are **not** supported.\n\n## Drop-in SDK compatibility\n\nPoint any OpenAI, Anthropic, or Gemini SDK at Antix by changing the base URL and swapping in your Virtual Key. The proxy translates provider-specific quirks and keeps SSE streaming predictable.\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n base_url=\"https://antix.antigma.ai/v1\",\n api_key=\"sk-antix-<your-key>\",\n)\n\nresponse = client.chat.completions.create(\n model=\"claude-sonnet-4-6\",\n messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n stream=True,\n)\n```\n\nA Rust streaming pipeline normalizes SSE events across providers so token deltas, tool calls, and stop reasons arrive in a consistent shape regardless of upstream.\n\n## Bring Your Own Key (BYOK)\n\nIf you have negotiated direct rates with a provider but still want Antix's observability and routing, use BYOK. Send your provider key in `Authorization` and declare the provider with `X-Antix-Provider`:\n\n```bash\ncurl -X POST https://antix.antigma.ai/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer YOUR_ALIBABA_DASHSCOPE_KEY\" \\\n -H \"X-Antix-Provider: alibaba\" \\\n -d '{\n \"model\": \"qwen-max\",\n \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]\n }'\n```\n\nBYOK traffic is not re-billed by Antix. It is still tracked for observability.\n\n### Accepted `X-Antix-Provider` values\n\n| Provider | Accepted values |\n|---|---|\n| OpenAI | `openai` |\n| Anthropic | `anthropic` |\n| Google Gemini | `google`, `gemini`, `google_ai_studio_gemini` |\n| xAI | `xai`, `x-ai` |\n| Alibaba / DashScope | `alibaba`, `qwen`, `dashscope` |\n\n:::note Provider inference\nWhen the header is omitted, Antix infers the provider from the key prefix (e.g., `sk-ant-…` → Anthropic, `sk-…` → OpenAI). Alibaba/DashScope keys have no distinctive prefix — you **must** set `X-Antix-Provider` for those requests, otherwise they will fail upstream with `401 Unauthorized`.\n:::\n"}}, "docs-site/i18n/zh-Hans/docusaurus-plugin-content-docs/current/antix/concepts/routing.md": {"485f037514ac52cdb36b0a5d467b9d32424832b3": {"t": 1785746549.66998, "n": 3492, "h": "096d9efa5499347d", "c": "---\ntitle: \"路由与 BYOK\"\ndescription: \"端点、多协议 SDK 兼容性以及自带密钥(Bring Your Own Key)语义。\"\nsidebar_position: 1\n---\n\n# 路由与 BYOK {#routing--byok}\n\nAntix 是一个多协议网关。它接受 OpenAI、Anthropic 和 Gemini 数据结构的请求,并将跨越上游提供商的流式传输规范化,包括 Anthropic、Google Gemini、Alibaba Qwen、DeepSeek、Zai (GLM)、xAI 和 OpenAI。\n\n## 支持的端点 {#supported-endpoints}\n\n| 端点 | 方法 | 协议 |\n|---|---|---|\n| `/v1/chat/completions` | POST | OpenAI Chat Completions |\n| `/v1/responses` | POST | OpenAI Responses API |\n| `/v1/messages` | POST | Anthropic Messages |\n| `/v1/messages/count_tokens` | POST | Anthropic token counter |\n| `/v1/models/{action}` | POST | Gemini 原生(`:generateContent`, `:streamGenerateContent`) |\n| `/v1beta/models/{action}` | POST | Gemini v1beta 原生路径 |\n| `/v1/models`, `/models` | GET | 公开模型目录(无身份验证) |\n| `/v2/model/info` | GET | 包含定价的目录 |\n\n**不**支持 `/v1/embeddings`、音频、图像、文件、微调(fine-tuning)和批处理(batch)API。\n\n## 即插即用的 SDK 兼容性 {#drop-in-sdk-compatibility}\n\n通过更改基地址(base URL)并换上您的虚拟密钥,将任何 OpenAI、Anthropic 或 Gemini SDK 指向 Antix。代理会转换特定于提供商的特性,并保持 SSE 流的传输可预测。\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n base_url=\"https://antix.antigma.ai/v1\",\n api_key=\"sk-antix-<your-key>\",\n)\n\nresponse = client.chat.completions.create(\n model=\"claude-sonnet-4-6\",\n messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n stream=True,\n)\n```\n\n流式传输管道将跨提供商的 SSE 事件标准化,因此无论上游情况如何,代币增量、工具调用和停止原因都将以一致的数据结构到达。\n\n### Claude Code {#claude-code}\n\nClaude Code 内部使用 Anthropic SDK,因此将其重定向到 Antix 只需要一个环境变量:\n\n```bash\nexport ANTHROPIC_BASE_URL=\"https://antix.antigma.ai\"\n```\n\n就是这样——Claude Code 的 SDK 会读取这两个配置,并将所有的 `/v1/messages` 流量路由到 Antix,Antix 在替换您的平台密钥后将其原样传递给 Anthropic。\n\n## 自带密钥(Bring Your Own Key, BYOK) {#bring-your-own-key-byok}\n\n如果您已经与提供商协商了直接费率,但仍然想要 Antix 的可观测性和路由功能,请使用 BYOK。在 `Authorization` 中发送您的提供商密钥,并通过 `X-Antix-Provider` 声明提供商:\n\n```bash\ncurl -X POST https://antix.antigma.ai/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer YOUR_ALIBABA_DASHSCOPE_KEY\" \\\n -H \"X-Antix-Provider: alibaba\" \\\n -d '{\n \"model\": \"qwen-max\",\n \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]\n }'\n```\n\nAntix 不会对 BYOK 流量重新计费。为了可观测性,它仍会被追踪记录。\n\n### 支持的提供商 {#supported-providers}\n\nAntix 在这些上游提供商之间将请求标准化。您可以通过模型名称(Antix 会推断提供商)或通过 `X-Antix-Provider` 明确地路由到其中的任何一个:\n\n| 提供商 | 显著的模型 | 可接受的 `X-Antix-Provider` 值 | 备注 |\n|---|---|---|---|\n| **Anthropic** | Claude Sonnet, Opus, Haiku | `anthropic` | 原生 `/v1/messages` 支持。 |\n| **OpenAI** | GPT-5.x | `openai` | 原生 `/v1/chat/completions` 和 `/v1/responses` 支持。 |\n| **Google Gemini** | Gemini 3.x | `google`, `gemini`, `google_ai_studio_gemini` | `/v1/models/{action}` 和 `/v1beta` 的原生 Gemini 协议。 |\n| **xAI** | Grok | `xai`, `x-ai` | 兼容 OpenAI 的上游。 |\n| **Alibaba Qwen** | `qwen3-max`, `qwen3-coder-plus`, `qwen3-coder-flash`, `qwq-plus`, `qwen-plus`, `qwen-max`, 等等 | `alibaba`, `qwen`, `dashscope` | 通过 DashScope 路由。没有独特的密钥前缀——您**必须**在 BYOK 调用中设置 `X-Antix-Provider`。 |\n| **DeepSeek** | `deepseek-chat` (V3), `deepseek-reasoner` (R1), `deepseek-v4-pro`, `deepseek-v4-flash` | `deepseek` | 兼容 OpenAI 的上游 API。`deepseek-reasoner` 会在最终答案旁返回 `reasoning_content` 字段。 |\n| **Zai (GLM)** | `glm-5.2`, `glm-5.1`, `glm-4.7` | `zai` | 智谱 AI 的 GLM 模型系列,兼容 OpenAI 的上游。没有独特的密钥前缀——您**必须**在 BYOK 调用中设置 `X-Antix-Provider`。 |\n\n:::note 提供商推断\n当标头被省略时,Antix 会从密钥前缀推断提供商(例如,`sk-ant-…` → Anthropic,`sk-…` → OpenAI)。某些密钥(如 Alibaba/DashScope 或 Zai)可能没有明显的前缀——您**必须**为这些请求设置 `X-Antix-Provider`,否则它们在上游将因 `401 Unauthorized` 失败。\n:::\n\n请参阅[模型 API](/antix/concepts/models)以准确列出您的网关目前提供服务的模型。\n"}, "f2861ee4088de1e56a31265242f7d190cb336a35": {"t": 1785765521.1335819, "n": 3492, "h": "096d9efa5499347d", "c": "---\ntitle: \"路由与 BYOK\"\ndescription: \"端点、多协议 SDK 兼容性以及自带密钥(Bring Your Own Key)语义。\"\nsidebar_position: 1\n---\n\n# 路由与 BYOK {#routing--byok}\n\nAntix 是一个多协议网关。它接受 OpenAI、Anthropic 和 Gemini 数据结构的请求,并将跨越上游提供商的流式传输规范化,包括 Anthropic、Google Gemini、Alibaba Qwen、DeepSeek、Zai (GLM)、xAI 和 OpenAI。\n\n## 支持的端点 {#supported-endpoints}\n\n| 端点 | 方法 | 协议 |\n|---|---|---|\n| `/v1/chat/completions` | POST | OpenAI Chat Completions |\n| `/v1/responses` | POST | OpenAI Responses API |\n| `/v1/messages` | POST | Anthropic Messages |\n| `/v1/messages/count_tokens` | POST | Anthropic token counter |\n| `/v1/models/{action}` | POST | Gemini 原生(`:generateContent`, `:streamGenerateContent`) |\n| `/v1beta/models/{action}` | POST | Gemini v1beta 原生路径 |\n| `/v1/models`, `/models` | GET | 公开模型目录(无身份验证) |\n| `/v2/model/info` | GET | 包含定价的目录 |\n\n**不**支持 `/v1/embeddings`、音频、图像、文件、微调(fine-tuning)和批处理(batch)API。\n\n## 即插即用的 SDK 兼容性 {#drop-in-sdk-compatibility}\n\n通过更改基地址(base URL)并换上您的虚拟密钥,将任何 OpenAI、Anthropic 或 Gemini SDK 指向 Antix。代理会转换特定于提供商的特性,并保持 SSE 流的传输可预测。\n\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n base_url=\"https://antix.antigma.ai/v1\",\n api_key=\"sk-antix-<your-key>\",\n)\n\nresponse = client.chat.completions.create(\n model=\"claude-sonnet-4-6\",\n messages=[{\"role\": \"user\", \"content\": \"Hello!\"}],\n stream=True,\n)\n```\n\n流式传输管道将跨提供商的 SSE 事件标准化,因此无论上游情况如何,代币增量、工具调用和停止原因都将以一致的数据结构到达。\n\n### Claude Code {#claude-code}\n\nClaude Code 内部使用 Anthropic SDK,因此将其重定向到 Antix 只需要一个环境变量:\n\n```bash\nexport ANTHROPIC_BASE_URL=\"https://antix.antigma.ai\"\n```\n\n就是这样——Claude Code 的 SDK 会读取这两个配置,并将所有的 `/v1/messages` 流量路由到 Antix,Antix 在替换您的平台密钥后将其原样传递给 Anthropic。\n\n## 自带密钥(Bring Your Own Key, BYOK) {#bring-your-own-key-byok}\n\n如果您已经与提供商协商了直接费率,但仍然想要 Antix 的可观测性和路由功能,请使用 BYOK。在 `Authorization` 中发送您的提供商密钥,并通过 `X-Antix-Provider` 声明提供商:\n\n```bash\ncurl -X POST https://antix.antigma.ai/v1/chat/completions \\\n -H \"Content-Type: application/json\" \\\n -H \"Authorization: Bearer YOUR_ALIBABA_DASHSCOPE_KEY\" \\\n -H \"X-Antix-Provider: alibaba\" \\\n -d '{\n \"model\": \"qwen-max\",\n \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]\n }'\n```\n\nAntix 不会对 BYOK 流量重新计费。为了可观测性,它仍会被追踪记录。\n\n### 支持的提供商 {#supported-providers}\n\nAntix 在这些上游提供商之间将请求标准化。您可以通过模型名称(Antix 会推断提供商)或通过 `X-Antix-Provider` 明确地路由到其中的任何一个:\n\n| 提供商 | 显著的模型 | 可接受的 `X-Antix-Provider` 值 | 备注 |\n|---|---|---|---|\n| **Anthropic** | Claude Sonnet, Opus, Haiku | `anthropic` | 原生 `/v1/messages` 支持。 |\n| **OpenAI** | GPT-5.x | `openai` | 原生 `/v1/chat/completions` 和 `/v1/responses` 支持。 |\n| **Google Gemini** | Gemini 3.x | `google`, `gemini`, `google_ai_studio_gemini` | `/v1/models/{action}` 和 `/v1beta` 的原生 Gemini 协议。 |\n| **xAI** | Grok | `xai`, `x-ai` | 兼容 OpenAI 的上游。 |\n| **Alibaba Qwen** | `qwen3-max`, `qwen3-coder-plus`, `qwen3-coder-flash`, `qwq-plus`, `qwen-plus`, `qwen-max`, 等等 | `alibaba`, `qwen`, `dashscope` | 通过 DashScope 路由。没有独特的密钥前缀——您**必须**在 BYOK 调用中设置 `X-Antix-Provider`。 |\n| **DeepSeek** | `deepseek-chat` (V3), `deepseek-reasoner` (R1), `deepseek-v4-pro`, `deepseek-v4-flash` | `deepseek` | 兼容 OpenAI 的上游 API。`deepseek-reasoner` 会在最终答案旁返回 `reasoning_content` 字段。 |\n| **Zai (GLM)** | `glm-5.2`, `glm-5.1`, `glm-4.7` | `zai` | 智谱 AI 的 GLM 模型系列,兼容 OpenAI 的上游。没有独特的密钥前缀——您**必须**在 BYOK 调用中设置 `X-Antix-Provider`。 |\n\n:::note 提供商推断\n当标头被省略时,Antix 会从密钥前缀推断提供商(例如,`sk-ant-…` → Anthropic,`sk-…` → OpenAI)。某些密钥(如 Alibaba/DashScope 或 Zai)可能没有明显的前缀——您**必须**为这些请求设置 `X-Antix-Provider`,否则它们在上游将因 `401 Unauthorized` 失败。\n:::\n\n请参阅[模型 API](/antix/concepts/models)以准确列出您的网关目前提供服务的模型。\n"}}}}