Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Claude Code Llm Gateway

ASecurity

Use when implementing a server-side Anthropic-compatible LLM gateway for Claude Code, including /v1/messages, SSE streaming, count_tokens, files, models, tool_use/tool_result, beta headers, and gateway error compatibility.

4 stars
0 votes
0 copies
0 views
Added 9/20/2026
ai-agentsapi

Works with

claude codecliapi

Security Analysis

A100/100

Scanned 9/20/2026

Install to Claude Code

$npx -y skills add ZipperCode/lingma2api --skill claude-code-llm-gateway --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Claude Code Llm Gateway?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Claude Code Llm Gateway
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/zippercode-claude-code-llm-gateway/badge)](https://www.skillsdirectory.com/skills/zippercode-claude-code-llm-gateway)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: claude-code-llm-gateway
description: Use when implementing a server-side Anthropic-compatible LLM gateway for Claude Code, including /v1/messages, SSE streaming, count_tokens, files, models, tool_use/tool_result, beta headers, and gateway error compatibility.
---

# Claude Code 大模型请求网关

## 目标

根据本 skill,实现一个 Claude Code 可通过 `ANTHROPIC_BASE_URL` 接入的大模型请求网关。你的任务是写服务端接口,不是复刻 Claude Code 源码里的 SDK 调用函数。

优先实现 Anthropic Messages API 兼容面。不要把 Claude.ai OAuth、bootstrap、Remote/CCR session、session ingress、team memory sync 当成这个网关的必需接口。

## 接口优先级

| 优先级 | 接口 | 用途 | 最小要求 |
|---|---|---|---|
| P0 | `POST /v1/messages` | 主模型完成请求 | 支持 `stream:true/false`、messages、system、tools、thinking、betas |
| P0 | SSE event stream | 流式输出 | 输出 Anthropic raw SSE 事件序列 |
| P0 | tool round-trip | 工具调用回合 | 返回 `tool_use`,接收下一轮 `tool_result` |
| P1 | `POST /v1/messages/count_tokens` | 上下文估算 | 返回 `{ "input_tokens": number }` |
| P1 | `POST /v1/files` | 文件上传 | multipart,返回 file metadata |
| P1 | `GET /v1/files` | 文件列表 | 支持 `after_created_at`、`after_id` 分页 |
| P1 | `GET /v1/files/{file_id}/content` | 文件下载 | 返回二进制内容 |
| P2 | `GET /v1/models` | 模型能力/校验 | 返回 Anthropic models list 兼容结构 |

完整字段合同见 `references/gateway-interface-contract.md`。实现单个子协议时再读取对应专题 skill:

- `claude-code-api-request`:`/v1/messages`、`count_tokens`、`files`、`models` 的 HTTP 合同。
- `claude-code-api-streaming`:SSE 事件与非流式 fallback。
- `claude-code-api-tools`:`tools`、`tool_use`、`tool_result`、工具参数分片。
- `claude-code-api-conversation`:`messages`、content blocks、配对校验。
- `claude-code-api-compaction`:`context_management`、`cache_edits` 兼容处理。

## 实现顺序

1. 实现认证与公共头解析:接受 `Authorization: Bearer ...`、`x-api-key`、`anthropic-version`、`anthropic-beta`、`x-app`、`User-Agent`、`X-Claude-Code-Session-Id`、`x-client-request-id`。未知 `x-*` 头应透传或忽略,不要报错。
2. 实现 `POST /v1/messages` 非流式:校验基础 body,路由到你的上游模型,返回完整 assistant message。
3. 实现 `POST /v1/messages` 流式:返回 `text/event-stream`,按 Anthropic raw event 顺序输出。
4. 实现工具回合:当模型需要工具时返回 `stop_reason:"tool_use"` 和 `tool_use` block;客户端下一轮会把结果以 `tool_result` block 放在 user message 里。
5. 实现 `count_tokens`:优先真实统计;做不到时返回稳定估算,但字段必须是 `input_tokens`。
6. 实现 Files API:用于 Claude Code 持久化或引用大文件;没有文件能力时返回明确 404/403,不要让 `/v1/messages` 失败。
7. 实现 `GET /v1/models`:没有动态模型能力时返回静态列表。

## 兼容规则

- `stream:true` 是主路径。即使网关内部调用非流式模型,也要能合成 SSE 事件。
- `stream:false` 是 fallback 和后台任务路径,必须能返回完整 JSON。
- 请求体中的未知扩展字段默认忽略或透传:`anthropic_beta`、`anti_distillation`、`anthropic_internal`、`context_management`、`output_config`、`speed`。
- `thinking.budget_tokens` 必须严格小于 `max_tokens`;无法支持 thinking 时可以忽略字段,但不要因为字段存在直接 400。
- 支持 prompt cache 字段的透传:`cache_control`、`cache_reference`、`cache_edits`。不支持真实缓存时按普通内容处理。
- 返回错误时使用 Anthropic 风格 JSON,并设置可重试语义:429/529/5xx 可重试,401/403 通常不可重试,408/409 可重试。

## 验收用例

实现完成后至少用这些请求验证:

1. `POST /v1/messages` + `stream:true`,只返回 text。
2. `POST /v1/messages` + `stream:false`,返回完整 assistant message。
3. `POST /v1/messages` 带 `tools`,返回 `tool_use`;下一轮带 `tool_result`,返回最终 text。
4. `POST /v1/messages/count_tokens`,返回 `input_tokens`。
5. `POST /v1/files` 上传后,通过 `GET /v1/files` 和 `GET /v1/files/{id}/content` 取回。
6. `GET /v1/models` 返回至少一个 Claude Code 可选模型。

Attribution

ZipperCodeZipperCode
View sourceMore from ZipperCode →
SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Related Skills

Caveman

Ultra-compressed communication mode. Cuts token usage ~75% by speaking like caveman while keeping full technical accuracy. Supports intensity levels: lite, full (default), ultra, wenyan-lite, wenyan-full, wenyan-ultra. Use when user says "caveman mode", "talk like caveman", "use caveman", "less tokens", "be brief", or invokes /caveman. Also auto-triggers when token efficiency is requested.

1023331 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

686011 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3331 votes

catchup

Recovers prior coding-agent session context by running `catchup <agent> --since-compact`, which extracts a clean summary of a previous Codex, Claude Code, Antigravity, OpenCode, or Pi Agent session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", or asks to recover/summarize a previous session before continuing. Do NOT use for the current conversation, git history, or any non-agent log.

611 votes

math-skill

A comprehensive mathematical reasoning skill for AI assistants — handles arithmetic to research-level problems with rigorous step-by-step reasoning, systematic verification, and transparent uncertainty handling

381 votes
View all in ai-agents →