Prerequisites
- Gemini CLI installed — follow the official installation guide if needed
- An A2Agent API key — sign up at a2agent.me/register to get one
Setup
Set the required environment variables
Export your A2Agent key and the A2Agent OpenAI-compatible base URL before running the CLI:
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.Run Gemini CLI with an A2Agent model
Pass the If the CLI returns a response, your connection to A2Agent is working correctly.Recommended models for coding tasks:
--model flag to select the model you want to use:| Model | Best for |
|---|---|
deepseek-v4-pro | Complex refactoring and architecture |
glm-5.1 | General-purpose coding assistance |
kimi-k2.7-code | Code generation and debugging |
minimax-m2.5 | Long-context code analysis |
Persist the configuration
To make A2Agent the default backend for every Gemini CLI session, add the variables to your shell profile:~/.bashrc or ~/.zshrc
Troubleshooting
401 Unauthorized
401 Unauthorized
Connection refused or could not resolve host
Connection refused or could not resolve host
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.Model not found
Model not found
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.Environment variables not recognised after editing shell profile
Environment variables not recognised after editing shell profile
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.