claude-code-api-conversation

Implements server-side Anthropic messages and content-block compatibility for a Claude Code gateway.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building an OpenAI-compatible or Anthropic-compatible gateway that accepts Claude Code traffic requires handling many message shapes: string or array content, tool_use/tool_result pairing, images, documents, thinking blocks, and cache_control extensions. This Skill guides the implementation of tolerant server-side parsing for the /v1/messages endpoint so requests do not fail on recoverable structural variations. ## Core Features & Use Cases - Content Block Compatibility: Parse and forward text, tool_use, tool_result, image, document, thinking, redacted_thinking, server_tool_use, and cache_edits blocks in both user and assistant messages. - Tolerant Tool Pairing: Match tool_result.tool_use_id with tool_use.id, and degrade gracefully on orphaned tool_results or missing results instead of returning 500 errors. - System Prompt Handling: Accept system as a string or an array of text blocks, ignoring cache_control when prompt caching is unsupported while preserving the text. - Use Case: You are building a proxy that forwards Claude Code requests to an upstream model. Use this Skill to implement request validation that ignores unknown extension fields, converts unsupported media to explicit 400 errors or text placeholders, and keeps tool-call chains intact for the upstream model. ## Quick Start Use this Skill to implement tolerant /v1/messages request parsing for my Claude Code gateway, including tool_use and tool_result pairing and graceful handling of unknown fields.

Frequently Asked Questions about claude-code-api-conversation

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

FAQPage Schema
How do I handle Anthropic messages content blocks in a gateway?

Accept both string content and content block arrays for user and assistant messages. Parse text, tool_use, tool_result, image, document, and thinking blocks, forwarding supported types upstream and ignoring or converting unsupported ones rather than rejecting the request.

How to match tool_result with tool_use in Anthropic API requests?

Match tool_result.tool_use_id against the id of a prior assistant tool_use block and pass the pair to the upstream model as a tool result. Orphaned tool_results should be ignored or converted to text, and missing results should not block the request.

Does the Anthropic messages endpoint accept system as an array?

Yes, system can be a string or an array of text blocks that may carry cache_control metadata. Gateways without prompt caching should ignore cache_control but preserve the text content of each block.

What image and document formats does Claude Code send?

Images arrive as base64 sources with media_type such as image/png, image/jpeg, image/gif, or image/webp, and documents typically use application/pdf. If the upstream model lacks media support, return a clear 400 or substitute a text placeholder instead of silently dropping content.

Why should a gateway ignore unknown fields in Claude Code requests?

Claude Code attaches extension fields for caching, tool search, advisors, and callers that external gateways do not implement. Ignoring unknown fields keeps requests working across client versions; only return 400 when a request truly cannot be converted.