Replace three separate AI clients with this single open-source adapter
GitHub RepoImpressions656

Replace three separate AI clients with this single open-source adapter

@githubprojectsPost Author

Project Description

View on GitHub

One Adapter to Rule Them All: Simplifying AI Client Chaos

If you've built anything with AI lately, you know the drill. You start with the OpenAI client, then maybe you need Anthropic's Claude for a specific task, and suddenly you're adding another library for Google's Gemini. Your code becomes a mess of different import statements, method names, and response formats. It's a headache.

What if you could talk to all of them through a single, consistent interface? That's exactly what gcli2api does. It's an open-source adapter that turns their command-line interfaces into a unified Python API, letting you replace three separate clients with one clean abstraction.

What It Does

In simple terms, gcli2api is a Python adapter that sits on top of the official command-line tools (CLIs) for OpenAI, Anthropic, and Google AI. Instead of installing and learning three different Python SDKs with their own quirks, you use this adapter to call their underlying CLIs. It handles the translation, so you write code once and can send prompts to any of the supported models.

You instantiate a single client, and whether you're targeting gpt-4, claude-3-opus, or gemini-pro, the method to call is the same. The adapter manages the process of converting your Python call into the correct CLI command, executing it, and parsing the response back into a consistent format for your application.

Why It's Cool

The clever part isn't just the unification—it's the how. By leveraging the existing, often more stable and feature-complete CLIs, this adapter can be more robust and avoid the lag that sometimes happens when Python SDKs play catch-up with new model releases. The CLIs are usually the first to be updated by the providers.

This approach is particularly useful for developers who:

  • Are building tools that need model agnosticism (e.g., a chatbot that lets users choose their backend).
  • Prefer the simplicity of a single interface for prototyping and testing different models side-by-side.
  • Want to avoid bloating their project with multiple large SDK dependencies.
  • Operate in environments where using a system-level CLI tool is more feasible or secure than a full Python package.

It turns the complexity of multiple AI providers into a simple, dependency-light facade pattern.

How to Try It

Getting started is straightforward. First, you need the official CLI tools installed and configured (with your API keys). Then, it's a pip install away.

# 1. Ensure you have the providers' CLIs set up (e.g., `pip install openai anthropic google-generativeai`)
# 2. Install the adapter
pip install gcli2api

# 3. Use it in your code
from gcli2api import get_client

client = get_client("openai")  # or "anthropic" / "google"
response = client.chat_completions_create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Explain quantum computing simply."}]
)
print(response)

For detailed setup on each CLI and full usage examples, the GitHub repository is the best place to look. The README is clear and will get you up and running in minutes.

Final Thoughts

gcli2api is a pragmatic, no-nonsense solution to a very real problem. It might not be for every production scenario—if you need deep, low-level SDK control, stick with the official clients. But for simplifying development, reducing cognitive load, and quickly swapping between AI backends, it's a brilliantly useful tool. It feels like the "Adapter" pattern from the Gang of Four book, plucked right out and applied perfectly to the modern AI stack. Next time I start a new project where I'm unsure which model I'll stick with, this adapter will be my first install.


@githubprojects

Back to Projects
Project ID: c81903f9-3273-4e3f-af79-9749681f4f82Last updated: April 7, 2026 at 05:46 AM