{"name":"claude-code-proxy: Use Anthropic Clients with OpenAI and Gemini Models","description":"`claude-code-proxy` is a powerful proxy server that allows developers to use Anthropic clients, such as Claude Code, with various backend models including OpenAI, Gemini, or even Anthropic's own models. It provides seamless translation of API requests and responses, offering flexibility and control over your AI model choices. This tool is ideal for integrating different LLM providers without modifying existing Anthropic client code.","github":"https://github.com/1rgs/claude-code-proxy","url":"https://osrepos.com/repo/1rgs-claude-code-proxy","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/1rgs-claude-code-proxy","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/1rgs-claude-code-proxy.md","json":"https://osrepos.com/repo/1rgs-claude-code-proxy.json","topics":["Python","AI","LLM","Proxy","Anthropic","OpenAI","Gemini","API"],"keywords":["Python","AI","LLM","Proxy","Anthropic","OpenAI","Gemini","API"],"stars":null,"summary":"`claude-code-proxy` is a powerful proxy server that allows developers to use Anthropic clients, such as Claude Code, with various backend models including OpenAI, Gemini, or even Anthropic's own models. It provides seamless translation of API requests and responses, offering flexibility and control over your AI model choices. This tool is ideal for integrating different LLM providers without modifying existing Anthropic client code.","content":"## Introduction\n\n`claude-code-proxy` is an innovative proxy server designed to bridge the gap between Anthropic clients and various large language models (LLMs). This Python-based tool allows you to seamlessly use Anthropic clients, such as Claude Code, with powerful backends like OpenAI, Google Gemini, or even directly with Anthropic's own models, all powered by LiteLLM. It acts as a transparent intermediary, translating API requests and responses to ensure compatibility across different LLM providers.\n\n## Installation\n\nGetting `claude-code-proxy` up and running is straightforward, whether you prefer installing from source or using Docker.\n\n### Prerequisites\n\n*   An OpenAI API key.\n*   A Google AI Studio (Gemini) API key (if you plan to use Google as a provider).\n*   [uv](https://github.com/astral-sh/uv) installed, a fast Python package installer.\n\n### From Source\n\n1.  **Clone the repository:**\n    bash\n    git clone https://github.com/1rgs/claude-code-proxy.git\n    cd claude-code-proxy\n    \n\n2.  **Install uv** (if not already installed):\n    bash\n    curl -LsSf https://astral.sh/uv/install.sh | sh\n    \n    *`uv` will manage dependencies when the server runs.*\n\n3.  **Configure Environment Variables:**\n    Copy the example environment file and edit `.env` with your API keys and model preferences.\n    bash\n    cp .env.example .env\n    \n    Key variables to configure include:\n    *   `ANTHROPIC_API_KEY`: (Optional) For proxying to Anthropic models.\n    *   `OPENAI_API_KEY`: Your OpenAI API key.\n    *   `GEMINI_API_KEY`: Your Google AI Studio (Gemini) API key.\n    *   `PREFERRED_PROVIDER`: Set to `openai` (default), `google`, or `anthropic`.\n    *   `BIG_MODEL`: Model for `sonnet` requests (e.g., `gpt-4o`, `gemini-2.5-pro-preview-03-25`).\n    *   `SMALL_MODEL`: Model for `haiku` requests (e.g., `gpt-4o-mini`, `gemini-2.0-flash`).\n\n4.  **Run the server:**\n    bash\n    uv run uvicorn server:app --host 0.0.0.0 --port 8082 --reload\n    \n    *The `--reload` flag is optional, useful for development.*\n\n### Docker\n\nFor a containerized setup, first download the example environment file and configure it:\nbash\ncurl -O .env https://raw.githubusercontent.com/1rgs/claude-code-proxy/refs/heads/main/.env.example\n\nThen, use Docker Compose (recommended) or a direct Docker command.\n\n**With Docker Compose:**\nCreate a `docker-compose.yml` file:\nyml\nservices:\n  proxy:\n    image: ghcr.io/1rgs/claude-code-proxy:latest\n    restart: unless-stopped\n    env_file: .env\n    ports:\n      - 8082:8082\n\n\n**With a Docker command:**\nbash\ndocker run -d --env-file .env -p 8082:8082 ghcr.io/1rgs/claude-code-proxy:latest\n\n\n## Examples\n\nOnce the proxy server is running, integrating it with your Anthropic clients is simple.\n\n### Using with Claude Code\n\n1.  **Install Claude Code** (if you haven't already):\n    bash\n    npm install -g @anthropic-ai/claude-code\n    \n\n2.  **Connect to your proxy:**\n    Set the `ANTHROPIC_BASE_URL` environment variable to point to your proxy server.\n    bash\n    ANTHROPIC_BASE_URL=http://localhost:8082 claude\n    \n    Your Claude Code client will now route requests through `claude-code-proxy`, utilizing your configured backend models.\n\n### Customizing Model Mapping\n\n`claude-code-proxy` offers extensive control over how Anthropic models (`haiku`, `sonnet`) are mapped to your chosen backend LLMs. This is configured via environment variables in your `.env` file.\n\n**Example 1: Default (Use OpenAI)**\ndotenv\nOPENAI_API_KEY=\"your-openai-key\"\n# GEMINI_API_KEY=\"your-google-key\" # Needed for fallback if PREFERRED_PROVIDER=google\n# PREFERRED_PROVIDER=\"openai\" # Optional, it's the default\n# BIG_MODEL=\"gpt-4.1\" # Optional, it's the default\n# SMALL_MODEL=\"gpt-4.1-mini\" # Optional, it's the default\n\n\n**Example 2: Prefer Google**\ndotenv\nGEMINI_API_KEY=\"your-google-key\"\nOPENAI_API_KEY=\"your-openai-key\" # Needed for fallback\nPREFERRED_PROVIDER=\"google\"\n# BIG_MODEL=\"gemini-2.5-pro-preview-03-25\" # Optional, it's the default for Google pref\n# SMALL_MODEL=\"gemini-2.0-flash\" # Optional, it's the default for Google pref\n\n\n**Example 3: Use Direct Anthropic (\"Just an Anthropic Proxy\" Mode)**\nThis mode allows you to use the proxy infrastructure while still using actual Anthropic models.\ndotenv\nANTHROPIC_API_KEY=\"sk-ant-...\"\nPREFERRED_PROVIDER=\"anthropic\"\n# BIG_MODEL and SMALL_MODEL are ignored in this mode\n\n\n**Example 4: Use Specific OpenAI Models**\ndotenv\nOPENAI_API_KEY=\"your-openai-key\"\nPREFERRED_PROVIDER=\"openai\"\nBIG_MODEL=\"gpt-4o\" # Example specific model for sonnet\nSMALL_MODEL=\"gpt-4o-mini\" # Example specific model for haiku\n\n\n## Why Use claude-code-proxy?\n\n`claude-code-proxy` provides several compelling advantages for developers working with LLMs:\n\n*   **Unmatched Flexibility**: Easily switch between OpenAI, Gemini, or Anthropic models without altering your client-side code. This allows you to experiment with different providers or leverage specific model strengths.\n*   **Cost Optimization**: By mapping Anthropic models to potentially more cost-effective alternatives like `gpt-4o-mini` or `gemini-2.0-flash`, you can significantly reduce API expenses.\n*   **Seamless Integration**: Maintain your existing Anthropic client workflows, such as those with Claude Code, while benefiting from a wider array of backend LLMs.\n*   **Centralized Control**: The proxy acts as a single point of entry, which can be extended for logging, monitoring, rate limiting, or other middleware functionalities.\n\n## Links\n\n*   **GitHub Repository**: [https://github.com/1rgs/claude-code-proxy](https://github.com/1rgs/claude-code-proxy){:target=\"_blank\"}","metrics":{"detailViews":82,"githubClicks":18},"dates":{"published":null,"modified":"2025-10-12T15:46:56.000Z"}}