Article illustration 1

For developers building AI-powered applications, managing multiple model APIs has become a nightmare of incompatible formats, rate limits, and redundant configurations. Enter AIClient2API—a Node.js-powered proxy that acts as a universal adapter, transforming APIs from giants like Google Gemini, Anthropic Claude, and OpenAI into a standardized OpenAI-compatible endpoint. Born from the need to simplify toolchains, this open-source project doesn’t just bridge protocols; it reimagines interoperability with surgical precision.

Why This Matters: Beyond Convenience

AI’s rapid evolution has birthed a tower of Babel: Gemini speaks in application/json dialects Claude doesn’t understand, while OpenAI’s chat completions demand bespoke clients. Teams waste cycles wrestling inconsistencies instead of innovating. AIClient2API cuts through this by:
- Eliminating Vendor Lock-in: Switch between Gemini, Claude Sonnet 4 (via Kiro API), or OpenAI with a config tweak—no client changes needed.
- Breaking Barriers: Uses Google’s CLI OAuth to bypass Gemini’s free-tier quotas and unlocks Claude via Kiro’s API without subscriptions.
- Centralizing Control: Log every prompt to files for compliance or training data, and inject system-level instructions globally.

"This isn’t just a proxy—it’s a force multiplier for developers," notes an AI engineer testing the tool. "Suddenly, my LobeChat plugins work with Gemini’s multimodal inputs as smoothly as OpenAI."

The Architecture: Strategy Patterns in Action

Under the hood, AIClient2API leverages clean abstractions to handle protocol chaos:

// Simplified core flow
1. Request → HTTP Server → Auth Validation
2. Protocol Detection (OpenAI/Gemini/Claude via endpoint/headers)
3. Format Conversion → Target Provider (Adapter Pattern)
4. AI Service Call → Response Conversion
5. Stream or Structured Reply

Key design pillars:
- Adapter Pattern: Each provider (Gemini, OpenAI, etc.) implements a unified ApiServiceAdapter interface.
- Strategy Pattern: Dedicated handlers (e.g., GeminiStrategy) manage protocol-specific quirks like Gemini’s tool_calls → OpenAI function conversions.
- Factory Pattern: Dynamically spawns adapters, caching instances via Singleton for efficiency.

The result? Flawless translation between protocols:

Star history reflects traction among developers tired of API fragmentation.

Game-Changing Features

  • Multimodal Mastery: Process images, documents, and audio through a single /v1/chat/completions call.
  • Streaming Support: Real-time token streaming for ChatGPT-like experiences with any backend.
  • Config-Driven Flexibility: Define providers, auth keys, and logging (console/file) in config.json. Use SYSTEM_PROMPT_MODE to overwrite or append global instructions.
  • Health Checks: /health endpoint for monitoring uptime and config status.

Getting Started: Zero-Friction Deployment

  1. Install: npm install with Node.js ≥20
  2. Configure: Set your MODEL_PROVIDER (e.g., gemini-cli-oauth) and keys in config.json
  3. Run: node src/api-server.js
  4. Integrate: Point any OpenAI client (e.g., VS Code extensions) to localhost:3000

Sample call for Gemini via OpenAI format:

curl http://localhost:3000/v1/chat/completions \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{
    "model": "gemini-2.5-flash",
    "messages": [
      {"role": "user", "content": "Describe this image",
       "image_url": {"url": "data:image/jpeg;base64,..."}
      }
    ]
  }'

The Bigger Picture: A Foundation for Innovation

AIClient2API transcends convenience—it’s a toolkit for democratizing AI. Developers can now:
- Build Provider-Agnostic Apps: Support emerging models like Kimi K2 or GLM-4.5 without rewrites.
- Audit & Optimize: Capture prompt/response logs to refine AI interactions.
- Extend Easily: Add new providers by implementing the adapter interface; contributors are already exploring Mistral and Llama.cpp integrations.

As AI ecosystems fracture further, tools like this don’t just connect APIs—they unify the future of intelligent applications, letting engineers focus on creating value, not parsing JSON dialects.


Source: GitHub Repository | License: GPLv3