2.3 KiB
2.3 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
anyclaude is a proxy wrapper for Claude Code that enables using alternative LLM providers (OpenAI, Google, xAI, Azure) through the Anthropic API format. It intercepts Anthropic API calls and translates them to/from the Vercel AI SDK format for the specified provider.
Architecture
The proxy works by:
- Spawning a local HTTP server that mimics the Anthropic API
- Intercepting
/v1/messagesrequests containing<provider>/<model>format - Converting Anthropic message format to AI SDK format
- Routing to the appropriate provider (OpenAI, Google, xAI, Azure)
- Converting responses back to Anthropic format
- Setting
ANTHROPIC_BASE_URLto point Claude Code at the proxy
Key components:
src/main.ts: Entry point that sets up providers and spawns Claude with proxysrc/anthropic-proxy.ts: HTTP server that handles request/response translationsrc/convert-anthropic-messages.ts: Bidirectional message format conversionsrc/convert-to-anthropic-stream.ts: Stream response conversionsrc/json-schema.ts: Schema adaptation for different providers
Development Commands
# Install dependencies
bun install
# Build the project (creates dist/main.js with shebang)
bun run build
# Run the built binary
bun run ./dist/main.js
# The build command:
# 1. Compiles TypeScript to CommonJS for Node.js compatibility
# 2. Adds Node shebang for CLI execution
Testing
Test the proxy manually:
# Run in proxy-only mode to get the URL
PROXY_ONLY=true bun run src/main.ts
# Test with a provider
OPENAI_API_KEY=your-key bun run src/main.ts --model openai/gpt-5-mini
Environment Variables
Required for each provider:
OPENAI_API_KEY+ optionalOPENAI_API_URLfor OpenAI/OpenRouterGOOGLE_API_KEY+ optionalGOOGLE_API_URLfor GoogleXAI_API_KEY+ optionalXAI_API_URLfor xAIAZURE_API_KEY+ optionalAZURE_API_URLfor AzureANTHROPIC_API_KEY+ optionalANTHROPIC_API_URLfor Anthropic passthrough
Special modes:
-
PROXY_ONLY=true: Run proxy server without spawning Claude Code -
ANYCLAUDE_DEBUG=1|2: Enable debug logging (1=basic, 2=verbose) -
OpenAI's gpt-5 was released in August 2025