User Guide
Developer Tools

Gemini CLI Usage Guide

Forward Gemini CLI native requests to Magick API via environment variables and set the default model

Gemini CLI uses the native Gemini protocol. When connecting to Magick API, the key is to configure the Gemini CLI gateway address, API Key, and default model in environment variables.

Currently, it is recommended to connect Gemini CLI directly via environment variables, and usually no additional configuration file editing is required.

Mac/Linux

export GOOGLE_GEMINI_BASE_URL="https://api.magickapi.com"
export GEMINI_API_KEY="API key generated from the dashboard"
export GEMINI_MODEL="gemini-3.1-pro-preview"

Windows CMD

set GOOGLE_GEMINI_BASE_URL=https://api.magickapi.com
set GEMINI_API_KEY=API key generated from the dashboard
set GEMINI_MODEL=gemini-3.1-pro-preview

PowerShell

$env:GOOGLE_GEMINI_BASE_URL="https://api.magickapi.com"
$env:GEMINI_API_KEY="API key generated from the dashboard"
$env:GEMINI_MODEL="gemini-3.1-pro-preview"

Starting Gemini CLI

After executing the above three commands, navigate to your project directory and simply run:

gemini

Notes

  • GEMINI_API_KEY should be filled with the API key generated from the Magick API dashboard
  • GOOGLE_GEMINI_BASE_URL is fixed to https://api.magickapi.com
  • GEMINI_MODEL can serve as the default model for Gemini CLI; the example value provided here is gemini-3.1-pro-preview
  • If you need to view the request path and request body format of the Gemini native API, you can continue to refer to "General Models / Gemini Native Format"

Last updated on

On this page