Skip to main content

Introduction

Gemini CLI is Google’s official command-line tool that lets developers interact with Gemini AI models from the terminal. After configuring APIMart API, you can use APIMart’s advanced models—GPT, Claude, and Gemini—in Gemini CLI.

Prerequisites

Before you start:
  1. Node.js and npm installed
    Download and install from the Node.js website (v16 or higher recommended)
  2. APIMart API key
    Sign in to the APIMart Console and copy your API key (starts with sk-)
Tip: If you don’t have an APIMart account yet, register at APIMart first and create an API key.

Step 1: Install Gemini CLI

1.1 Global install

Install Gemini CLI globally with npm:

1.2 Verify installation

Check that the CLI is available:
If a version number is printed, installation succeeded.
Tip: If the command is not found, restart your terminal or check your npm global PATH configuration.

Step 2: Configure APIMart API

2.1 Temporary environment variables

For testing or one-off use; values are cleared when you close the terminal. Windows (PowerShell):
macOS/Linux (Bash):
Persist configuration so new shells pick it up automatically. Windows (PowerShell):
  1. Run PowerShell as Administrator
  2. Set user-level environment variables:
  1. Restart PowerShell, or reload variables:
macOS/Linux (Bash):
  1. Edit your shell rc file:
  1. Append:
  1. Reload:

2.3 Using a .env file

Create .env in your project:
Load variables before running Gemini: macOS/Linux:
Windows (PowerShell):
Important: - Replace sk-xxxxxxxxxxxx with your real key from the APIMart Console - Set GEMINI_BASE_URL to https://api.apimart.ai/v1 so Gemini CLI talks to APIMart - Add .env to .gitignore so keys are not committed

2.4 Verify configuration

macOS/Linux:
Windows (PowerShell):
If the values look correct, configuration succeeded.

Step 3: Use Gemini CLI

3.1 Basic chat

Interactive session:
One-off prompt:

3.2 Choose a model

Or:

3.3 Read prompts from a file

Or pipe:

3.4 Save output to a file

Step 4: Call APIMart from your code

4.1 Python SDK

4.2 JavaScript / TypeScript

4.3 cURL

Step 5: Pick a model

APIMart supports many models; choose by task and budget. Gemini GPT Claude
Quick picks: - 🚀 Google-style stack: gemini-2.0-flash-exp, gemini-2.5-pro - 💡 Coding: claude-sonnet-4-5-20250929, gpt-5 - 💰 Cost: gpt-4o-mini, claude-haiku-4-5-20251001 - ⚡ Speed: gemini-2.0-flash-exp, gpt-4o-mini

Advanced features

Multimodal (images)

With a multimodal model such as Gemini 2.0 Flash:

Streaming

Stream tokens as they arrive:

Tuning parameters

Shape randomness and length:

FAQ

Q1: “Invalid API key” or auth errors

  1. Key format
    • Must start with sk-
    • No extra spaces when pasting
  2. Environment variables
  3. Key status

Q2: How do I verify the API setup?

Q3: Which languages are supported?

Any language that can send HTTP requests works with APIMart:
  • Python — OpenAI SDK recommended
  • JavaScript / TypeScript — Node or browser
  • Java — HTTP client
  • Go — stdlib or libraries
  • PHP — cURL or Guzzle
  • Ruby — HTTP gems
  • C# / .NETHttpClient
  • SwiftURLSession
  • Others — anything with HTTP

Q4: Where can I see usage and billing?

In the APIMart Console:
  • 📊 Live call stats
  • 💰 Cost and invoices
  • 📈 Usage trends
  • 🔍 Request logs
  • ⚙️ API key management

Q5: Common API errors

Best practices

1. Retries and backoff

2. Cost control

3. System prompts

Features

With Google AI Studio and APIMart you get:
  • 🤖 Many models — GPT, Claude, Gemini, and more
  • 🌍 OpenAI-compatible — familiar request / response shape
  • Performance — low latency, high concurrency
  • 💰 Clear pricing — pay as you go
  • 📊 Observability — monitor calls in real time
  • 🔒 Security — enterprise-oriented safeguards
  • 🚀 Fast integration — simple HTTP / SDK calls
  • 📚 Docs — guides and examples

Support


Get started with APIMart

Create an account, grab an API key, and use multiple AI models from Google AI Studio workflows and beyond.