AnyAgent

Gemini CLI

Use the Gemini CLI through AnyAgent: what you can ask for, how it behaves, and the flags underneath.

The gemini-cli adapter drives the Gemini CLI over its ACP endpoint, detected as the gemini binary on PATH; import geminiCli from anyagent-js/gemini-cli.

What you can ask for

model rides the endpoint's own flag; readOnly, systemPrompt, and schema are provided by AnyAgent. effort, mcp, and resume are undeclared and throw. models() lists the documented vocabulary — aliases (pro, flash) and full ids — as a probed hint. authStatus() is a heuristic over ~/.gemini/oauth_creds.json, GEMINI_API_KEY/GOOGLE_API_KEY, and ~/.gemini/settings.json; a selected auth type with no visible key answers "unknown", since keys can live in the OS keychain. The full grid is on the support matrix.

Good to know

Pin a model. Automatic routing can spend minutes self-investigating a trivial prompt, so never leave model unset expecting a sane default.

  • A session always starts fresh: reattaching is broken upstream, so agent.session({ resume }) throws.
  • Token usage arrives on the endpoint's own _meta.quota channel and lands on usage.inputTokens/outputTokens; per-model attribution stays on the result raw.

Under the hood

Every session launches gemini --acp --skip-trust and talks the Agent Client Protocol to it; the prompt travels as a content block. Run options map onto the endpoint like this:

OptionWhat it becomes
model-m <name> on the endpoint's argv, in the Gemini CLI's own vocabulary
cwdthe cwd of the new session
readOnly: truea denial of every permission request for a tool that could change the machine

On this page