Using BeatAPI in Gemini CLI

Using BeatAPI in Gemini CLI

Gemini CLI is a terminal client for the Gemini models. It speaks the native Gemini protocol — POST /v1beta/models/{model}:generateContent — which BeatAPI serves directly, so redirecting it is a base-URL change with no translation layer in between.

The base URL has to speak the native Gemini protocol. An OpenAI-compatible endpoint will not work here, because the CLI addresses models as {base}/v1beta/models/{model}:{action} rather than /chat/completions. https://api.beatapi.io is the native address; use it exactly, with no path suffix.

Prerequisites

  1. Node.js and npm — v16 or newer.
  2. A BeatAPI API key — create one in Dashboard → API Keys.

Step 1: Install Gemini CLI

$npm install -g @google/gemini-cli

Confirm the install:

$gemini --version

If the command is not found, restart the terminal or check your npm global PATH.

Step 2: Point it at BeatAPI

Two variables do the whole job.

$echo 'export GEMINI_API_KEY="<BEATAPI_API_KEY>"' >> ~/.zshrc
$echo 'export GEMINI_BASE_URL="https://api.beatapi.io"' >> ~/.zshrc
$source ~/.zshrc

One terminal only

$export GEMINI_API_KEY="<BEATAPI_API_KEY>"
$export GEMINI_BASE_URL="https://api.beatapi.io"
$gemini

From a .env file

$# .env
$GEMINI_API_KEY=<BEATAPI_API_KEY>
$GEMINI_BASE_URL=https://api.beatapi.io

Add .env to .gitignore so the key is never committed.

Verify the values landed

$echo $GEMINI_API_KEY
$echo $GEMINI_BASE_URL

Step 3: Use it

Interactive session:

$gemini

One-shot prompt:

$gemini "Summarise the architecture of this repository"

Pick a model explicitly:

$gemini --model gemini-3.1-pro-preview

Name the model explicitly rather than relying on whatever default the CLI ships with. A default that is not on your account produces a not_found, and pinning it also stops a CLI upgrade from silently moving you onto a different rate.

Models

Model IDChoose it for
gemini-3.1-pro-previewThe strongest tier — hard reasoning and long analysis
gemini-3.7-flashThe current fast tier for everyday work and high volume
gemini-3.6-flashThe previous fast generation, kept for pinned integrations

Rates are on the pricing page; the Gemini API page documents the request shape.

Calling the same models from code

The Gemini-compatible endpoint is one of four formats BeatAPI serves, so you are not restricted to the native shape once you leave the CLI.

1from openai import OpenAI
2
3client = OpenAI(
4 api_key="<BEATAPI_API_KEY>",
5 base_url="https://api.beatapi.io/v1",
6)
7
8response = client.chat.completions.create(
9 model="gemini-3.7-flash",
10 messages=[{"role": "user", "content": "Explain this stack trace"}],
11)
12
13print(response.choices[0].message.content)
$curl https://api.beatapi.io/v1/chat/completions \
> -H "Authorization: Bearer <BEATAPI_API_KEY>" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "gemini-3.7-flash",
> "messages": [{"role": "user", "content": "Explain this stack trace"}]
> }'

FAQ

Authentication errors

  1. Confirm both variables are set in the terminal you launched gemini from:

    $echo $GEMINI_API_KEY
    $echo $GEMINI_BASE_URL
  2. Confirm the key is active in Dashboard → API Keys.

404 on every request

GEMINI_BASE_URL must be https://api.beatapi.io — no /v1, no /v1beta, no trailing slash. The CLI appends the rest of the path itself; adding it yourself produces /v1/v1beta/models/..., which does not exist.

The model list is empty

Name the model with --model instead of picking from a list. The account’s models are also available from GET /v1/models and on the pricing page.

402 insufficient_credits

The balance is exhausted. Add credits from the dashboard.

429 rate_limit_exceeded

The key exceeded its request rate. Honour Retry-After. The per-minute allowance rises with lifetime top-ups and is shown on the dashboard.

Connection failures

Check general connectivity, then re-check GEMINI_BASE_URL for a typo. Behind a corporate proxy, allow api.beatapi.io.

Support

Open a support ticket from the dashboard and include the request_id from the failing response.