Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 1.98 KB

File metadata and controls

55 lines (39 loc) · 1.98 KB
title Gemini CLI
description Call Google Gemini via the @google/gemini-cli npm package in OpenSandbox.

Gemini CLI Example

Call Google Gemini via the @google/gemini-cli npm package in OpenSandbox.

Start OpenSandbox server [local]

Pre-pull the code-interpreter image (includes Node.js):

docker pull sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/code-interpreter:v1.1.0

# use docker hub
# docker pull opensandbox/code-interpreter:v1.1.0

Start the local OpenSandbox server, logs will be visible in the terminal:

uv pip install opensandbox-server
opensandbox-server init-config ~/.sandbox.toml --example docker
opensandbox-server

Create and Access the Gemini Sandbox

# Install OpenSandbox package
uv pip install opensandbox

# Run the example (requires SANDBOX_DOMAIN / SANDBOX_API_KEY / GEMINI_API_KEY)
uv run python examples/gemini-cli/main.py

The script installs the Gemini CLI (npm install -g @google/gemini-cli@latest) at runtime (Node.js is already in the code-interpreter image), then sends a simple request gemini "Compute 1+1=?.". Auth is passed via GEMINI_API_KEY; you can override endpoint/model with GEMINI_BASE_URL / GEMINI_MODEL.

Environment Variables

Variable Default Description
SANDBOX_DOMAIN localhost:8080 Sandbox service address
SANDBOX_API_KEY (optional for local) API key if your server requires authentication
SANDBOX_IMAGE sandbox-registry.cn-zhangjiakou.cr.aliyuncs.com/opensandbox/code-interpreter:v1.1.0 Sandbox image to use
GEMINI_API_KEY (required) Your Google Gemini API key
GEMINI_BASE_URL (optional) Gemini API endpoint (e.g., proxy)
GEMINI_MODEL gemini-2.5-flash Model to use

References