claude-code-llm-gateway

Implement an Anthropic-compatible LLM gateway server for Claude Code integration.

4|1|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/ZipperCode/lingma2api --skill claude-code-llm-gateway-zippercode
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: claude-code-llm-gateway
Source: https://github.com/ZipperCode/lingma2api/tree/main/.claude/skills/claude-code-llm-gateway
Command: npx skills add https://github.com/ZipperCode/lingma2api --skill claude-code-llm-gateway-zippercode

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building a server-side gateway that Claude Code can connect to via ANTHROPIC_BASE_URL requires reproducing the Anthropic Messages API contract, including SSE streaming, tool round-trips, and error semantics, which is error-prone without a precise specification. ## Core Features & Use Cases - Messages API Implementation: Guides implementation of POST /v1/messages with streaming and non-streaming responses, system prompts, tools, thinking, and beta headers. - SSE Streaming & Tool Round-Trips: Defines the exact Anthropic raw SSE event sequence and the tool_use/tool_result conversation cycle. - Supporting Endpoints: Covers count_tokens, Files API (upload, list, download), and GET /v1/models with Anthropic-compatible response shapes. - Use Case: You want Claude Code to route requests through your own proxy backed by a non-Anthropic upstream model; this Skill walks you through implementing each endpoint, converting upstream responses into Anthropic content blocks and SSE events, and validating with acceptance test cases. ## Quick Start Ask the AI to implement a Claude Code compatible /v1/messages endpoint with SSE streaming following this gateway specification.

Frequently Asked Questions about claude-code-llm-gateway

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build an Anthropic-compatible API gateway for Claude Code?

Implement POST /v1/messages with stream:true and stream:false support, returning Anthropic message JSON or raw SSE event sequences. Claude Code connects by setting ANTHROPIC_BASE_URL to your gateway, which then routes requests to your upstream model.

How to implement SSE streaming for the Anthropic Messages API?

Return Content-Type text/event-stream and emit events in order: message_start, content_block_start, content_block_delta, content_block_stop, message_delta, and message_stop. Even if your upstream model is non-streaming, you must synthesize these events.

Does the gateway support tool_use and tool_result round-trips?

Yes. When the model needs a tool, return stop_reason tool_use with a tool_use content block; Claude Code sends the result back as a tool_result block in the next user message. The gateway must preserve this conversation structure.

Can I use a non-Anthropic upstream model behind the gateway?

Yes. The gateway is responsible for converting OpenAI or custom upstream responses into Anthropic content blocks and SSE events. Unknown request fields like context_management or speed should be ignored or passed through rather than rejected.

What error format does Claude Code expect from a gateway?

Return Anthropic-style JSON with type error and an error object containing type and message. Use 429 or 529 for retryable rate limiting, 401 for authentication errors, and 5xx for retryable server errors.

Which endpoints are required versus optional for Claude Code?

P0 endpoints are POST /v1/messages, SSE streaming, and tool round-trips. P1 covers count_tokens and the Files API; P2 is GET /v1/models. OAuth, bootstrap, and session ingress endpoints are explicitly out of scope.