claude-code-api-request

Implements server-side HTTP endpoints for a Claude Code compatible Anthropic API gateway.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building a gateway that accepts requests from Claude Code requires matching the Anthropic HTTP contract exactly—paths, headers, body fields, error formats, and retry semantics—otherwise the client fails or retries unpredictably. This Skill provides the complete request-handling specification so you can implement a compatible server without reverse-engineering the protocol. ## Core Features & Use Cases - Endpoint Contract: Defines required endpoints including POST /v1/messages, /v1/messages/count_tokens, the Files API (upload, list, download), and GET /v1/models. - Header and Body Handling: Specifies how to parse Authorization, x-api-key, anthropic-version, anthropic-beta, and body fields like thinking, tools, tool_choice, betas, and context_management with lenient validation. - Error and Retry Semantics: Prescribes Anthropic-style error JSON and status codes (400, 401, 429, 529) so Claude Code applies correct retry behavior. - Use Case: You are building an OpenAI-compatible proxy that also needs to serve Claude Code clients; use this Skill to implement the /v1/messages endpoint with correct streaming/non-streaming branching and count_tokens support. ## Quick Start Implement the /v1/messages endpoint for my gateway following the Claude Code HTTP contract, including header parsing, body validation, and Anthropic-style error responses.

Frequently Asked Questions about claude-code-api-request

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

FAQPage Schema
How do I implement a /v1/messages endpoint compatible with Claude Code?

Accept POST requests with model, messages, max_tokens, and optional fields like system, tools, thinking, and stream. Branch on the stream flag: return SSE events when true, or a complete Anthropic message JSON with id, content, stop_reason, and usage when false.

What headers does a Claude Code gateway need to accept?

Accept both Authorization: Bearer tokens and x-api-key for authentication, plus anthropic-version, anthropic-beta, x-app, User-Agent, X-Claude-Code-Session-Id, and x-client-request-id. None are strictly required, but all should be parsed or recorded without rejecting the request.

How should a gateway handle unknown fields in Anthropic API requests?

Ignore or pass through unknown body fields rather than rejecting them. Only return 400 when genuinely required fields are missing or invalid, since Claude Code may send fields like betas, context_management, output_config, or speed that your gateway does not use.

Does the Anthropic Files API require multipart upload support?

Yes, POST /v1/files accepts multipart form data with a file field and purpose=user_data, returning at least id, filename, and size_bytes. You also need GET /v1/files for listing and GET /v1/files/{file_id}/content for binary download.

Which HTTP status codes trigger retries in Claude Code?

Claude Code treats 408, 409, 429, 5xx, and 529 as retryable errors, and 429 responses may include a retry-after header. Return 400 only for genuinely invalid fields and 401/403 for authentication or permission failures.

How do I implement /v1/messages/count_tokens without a tokenizer?

Return a JSON object with a numeric input_tokens field using a stable estimation if no exact tokenizer is available. The response must contain a number type, and the request accepts the same subset of fields as /v1/messages.