Gemini CLI SDK: Programmatic Access to the Gemini Agent
Gemini CLI v0.30.0 introduces the initial bootstrap of @google/gemini-cli-sdk, a new package that exposes the CLI's core agent capabilities as a programmable TypeScript API. Developers can now instantiate a GeminiCliAgent directly in their Node.js applications, send prompts via a streaming interface, and register custom tools β without spawning a CLI subprocess or parsing stdout. The SDK ships with SessionContext support, dynamic system instructions, and Zod-validated tool definitions, laying the groundwork for embedding Gemini's agentic engine into CI pipelines, internal developer platforms, and custom automation workflows.
Sources & Mentions
4 external resources covering this update
Gemini CLI Gets a Formal SDK for Programmatic Use
For the first time, developers can embed the Gemini CLI's reasoning and tool-execution engine directly into their own TypeScript applications. Gemini CLI v0.30.0 ships the initial bootstrap of @google/gemini-cli-sdk β a new npm package that exposes the CLI's core agent as a public API, rather than a terminal tool that must be shelled out to.
Why This Matters
Until now, any developer who wanted to incorporate Gemini CLI capabilities into a custom automation script or internal platform had to spawn a subprocess, pipe text to stdin, and scrape stdout for results. This approach was fragile, untyped, and completely divorced from the structured event model used internally by the CLI. GitHub issue #15539, "Create a Formal SDK for Programmatic Use," accumulated significant community interest β and v0.30.0 delivers the first official response to that demand.
What the SDK Exposes
The centerpiece of the new package is the GeminiCliAgent class. Developers instantiate it with a configuration object β specifying a working directory, custom instructions, and authentication settings β and then interact with the agent through a stream-based messaging API. The sendStream() method accepts a prompt string and an AbortSignal, and returns an async stream of response chunks, mirroring the real-time output behavior of the interactive CLI.
Tool registration is handled through a declarative system built on Zod schema validation. The Tool, SdkTool, and ToolDefinition interfaces allow developers to define custom tools that plug into the CLI's existing tool execution pipeline. This means third-party tools defined in SDK-based applications follow the same permission, approval, and policy rules as built-in CLI tools.
The SDK also introduces SessionContext support, allowing callers to maintain conversational state across multiple prompts. Dynamic system instructions β configurable per-session β give developers fine-grained control over the agent's behavior without modifying global settings.
Authentication
Authentication in the SDK follows the same environment-variable-based flow used by the CLI itself, with fallback to Application Default Credentials (ADC) for Google Cloud environments. This means the SDK is immediately usable in both local development contexts and Cloud Run or Vertex AI deployment pipelines without additional configuration.
Current Status
The v0.30.0 SDK is explicitly an initial bootstrap β the API surface is minimal and will expand in subsequent releases. It ships alongside three foundational implementation PRs covering the base package structure, SessionContext, and dynamic system instructions. Custom skill support was also included in this first drop, giving SDK consumers access to the same skill system that powers the interactive CLI.
Bug Fixes and Minor Changes
Beyond the SDK, v0.30.0 continues iterating on core stability with fixes including improved headless mode detection, MCP server initialization race condition resolution, and MCP transport GEMINI_CLI=1 environment variable propagation for stdio servers.