AI News Daily한국어
← AI tool tips
Open source✓ Confirmed in official docsAdded Nov 27

How to call Gemini models from Claude Code and Codex with the gemini-api CLI

gemini-api is an experimental command-line tool from Google. It lets agents with shell access, such as Claude Code or Codex, call the Gemini API with a single command. The agent picks what it needs: image or speech generation, PDF and video analysis, transcription, or a managed agent running in the background.

  1. Install it and set your API key. Create the key in Google AI Studio.
curl -fsSL https://raw.githubusercontent.com/google-gemini/gemini-api-cli/main/scripts/install.sh | bash
export GEMINI_API_KEY="YOUR_API_KEY"
  1. To store the key in your OS keychain, use gemini-api configure --api-key "YOUR_API_KEY"; check which key is active with gemini-api whoami. Verify the setup first with --dry-run, which makes no network call.
gemini-api generate "Hello from my agent" --dry-run
  1. Paste the instruction block from the README into your project's CLAUDE.md or AGENTS.md. It tells the agent to pick commands with --help/--usage and preview calls with --dry-run before running them.
You have access to gemini-api through the shell.
Use it to call Gemini models, generate or edit media, analyze files, or launch managed agents.
1. Inspect --help or --usage to choose a command, and --schema when building a --body JSON payload.
2. Preview API calls with --dry-run (or --dry-run --output-format json).
3. For discrete JSON output or --jq filtering on streaming commands (generate, agent run, agent status --stream), pass --stream=false --output-format json (--background on agent run returns a single interaction without streaming unless --stream is passed).
4. Capture returned file paths (from media commands) and interaction IDs (from agent/model runs) to continue multi-step tasks.
  1. Then prompt as usual. Ask for "a mascot image made with Gemini, saved in the assets folder" and the agent runs gemini-api image "…" --out ./assets/.

The tool is still experimental, and calls are billed to your own Gemini API key. The latest release is v0.5.0 (November 20). On November 26 the main branch gained gemini-api install-skill --agent claude-code, which writes the usage skill into Claude Code's or Codex's skills folder, but it is not in a release yet. Files uploaded through the Files API are kept for 48 hours.

Get notified when a new tip lands

Tip alerts only go out in the app. Install it and turn notifications on.

Get the app

All tips →