Skip to main content
Google’s Gemini CLI supports OpenAI-compatible API backends, which means you can point it at A2Agent and start using models like DeepSeek, Kimi, or GLM through the exact same CLI interface you already know. All it takes is setting two environment variables.

Prerequisites

Setup

1

Set the required environment variables

Export your A2Agent key and the A2Agent OpenAI-compatible base URL before running the CLI:
export OPENAI_API_KEY="YOUR_A2AGENT_KEY"
export OPENAI_BASE_URL="https://api.a2agent.me/v1"
When Gemini CLI operates in OpenAI-compatible mode, it uses OPENAI_API_KEY as the Authorization: Bearer token in each request. Set this variable to your A2Agent key — not a Google AI Studio key.
2

Run Gemini CLI with an A2Agent model

Pass the --model flag to select the model you want to use:
gemini --model deepseek-v4-pro "explain this code"
If the CLI returns a response, your connection to A2Agent is working correctly.Recommended models for coding tasks:
ModelBest for
deepseek-v4-proComplex refactoring and architecture
glm-5.1General-purpose coding assistance
kimi-k2.7-codeCode generation and debugging
minimax-m2.5Long-context code analysis
For the best coding experience, try deepseek-v4-pro or kimi-k2.7-code — both are optimised for code generation, debugging, and technical explanations.

Persist the configuration

To make A2Agent the default backend for every Gemini CLI session, add the variables to your shell profile:
~/.bashrc or ~/.zshrc
export OPENAI_API_KEY="YOUR_A2AGENT_KEY"
export OPENAI_BASE_URL="https://api.a2agent.me/v1"
Reload your profile to apply the change immediately:
source ~/.bashrc   # or source ~/.zshrc

Troubleshooting

Gemini CLI is reaching A2Agent but your credentials are being rejected. Confirm that OPENAI_API_KEY contains your full A2Agent key with no extra spaces, quotes, or newline characters. Run echo $OPENAI_API_KEY to check the value in your current shell.
Verify that OPENAI_BASE_URL is set to exactly https://api.a2agent.me/v1 — including the /v1 path and no trailing slash. Run echo $OPENAI_BASE_URL to confirm.
The model name you pass with --model must match an A2Agent model ID exactly — for example, deepseek-v4-pro, kimi-k2.7-code, glm-5.1, or minimax-m2.5. Check the A2Agent model list for all available IDs.
Run source ~/.bashrc (or source ~/.zshrc) in your current terminal after editing the profile, or open a new terminal session for the changes to take effect.