gemini-for-claude-code  by coffeegrind123

Proxy for using Gemini models with Claude Code

Created 4 months ago
309 stars

Top 86.9% on SourcePulse

GitHubView on GitHub
Project Summary

This Python server acts as a proxy, enabling users of the Claude Code CLI to leverage Google's Gemini models. It translates API requests and responses between Anthropic's format and Gemini's format via LiteLLM, facilitating seamless integration for developers needing advanced LLM capabilities with their existing Claude Code workflows.

How It Works

The server receives requests from the Claude Code CLI, which are formatted for Anthropic's API. It then translates these requests, including model aliases and tool definitions, into a format compatible with LiteLLM. LiteLLM forwards the request to the specified Gemini model. The Gemini response is then translated back into the Anthropic format before being sent to the Claude Code client. This approach allows for robust tool use and streaming support, with advanced error handling for malformed chunks and API instability.

Quick Start & Requirements

  • Install: Clone the repository, create a virtual environment, and run pip install -r requirements.txt.
  • Prerequisites: A Google Gemini API key, Python 3.8+, and the Claude Code CLI (npm install -g @anthropic-ai/claude-code).
  • Configuration: Set GEMINI_API_KEY in a .env file. Model mappings (e.g., BIG_MODEL, SMALL_MODEL) can also be customized.
  • Run: Execute python server.py or uvicorn server:app --host 0.0.0.0 --port 8082 --reload for development.
  • Usage: Set ANTHROPIC_BASE_URL=http://localhost:8082 when running Claude Code.
  • Docs: Official Gemini CLI

Highlighted Details

  • Claude Code Compatibility: Directly use the Claude Code CLI with Gemini models.
  • Tool Use Translation: Handles function calling translation between Claude Code and Gemini formats.
  • Streaming Resilience: Features malformed chunk recovery, smart retries, and fallback to non-streaming modes.
  • Diagnostic Endpoints: Includes /health and /test-connection for troubleshooting.

Maintenance & Community

Contributions, issues, and feature requests are welcome on the GitHub repository. The project is inspired by and builds upon the work of @1rgs.

Licensing & Compatibility

The repository does not explicitly state a license in the README. Compatibility for commercial use or closed-source linking would require clarification of the license.

Limitations & Caveats

The README notes that the CLAUDE.MD file is "crucial" for optimal performance and that Gemini might "fuck up" without it, suggesting potential fragility in Gemini's understanding of Claude Code's directives. The license is not specified, which could be a barrier for some users.

Health Check
Last Commit

2 months ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
14 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.