Vercel Labs Releases AI CLI for Terminal-Based Model Generation
Vercel Labs has introduced the AI CLI, a command-line tool allowing developers to generate text, images, and videos directly from the terminal via the Vercel AI Gateway.
Vercel's AI CLI integrates AI models directly into the terminal environment via the AI Gateway.
- Vercel Labs released
ai-cli, a terminal tool for generating text, images, and video using AI models. - The CLI integrates with the Vercel AI Gateway, allowing access to hundreds of models via a single API key.
- It features agent-native capabilities, making it readily usable by autonomous coding tools like Claude Code.
- Inline media previews are supported in compatible terminals using WebAssembly for H.264 video decoding.
The Vercel AI CLI (ai-cli), maintained by Vercel Labs, is an open-source command-line interface designed to generate text, images, and video directly from the terminal. Built on top of the Vercel AI SDK and Vercel AI Gateway, the tool provides a unified access point to multiple artificial intelligence models using a single configuration and standard terminal commands.
Installation and Configuration
The package is distributed via npm and can be installed globally using standard Node.js package managers. To function, the CLI requires an API key from the Vercel AI Gateway, an infrastructure component that routes and caches requests to various model providers. Users generate a key in their Vercel dashboard and expose it to the command-line interface via the AI_GATEWAY_API_KEY environment variable.
This centralized setup allows developers to access a wide catalog of models—spanning providers like OpenAI, OpenRouter, and fal.ai—without managing separate API keys, billing accounts, or rate limits for each individual service. By relying on the Vercel AI Gateway, the CLI abstracts away the nuances of provider-specific API payloads. Whether a user requests an image from an OpenAI model or a specialized model hosted on fal.ai, the CLI syntax remains uniform.
Core Commands and Output Handling
The CLI operates primarily through explicit generation commands: ai text, ai image, and ai video. When executing text generation, the CLI streams the model's text response directly to standard output (stdout), allowing the output to be read in real-time. Media generation commands require processing time and output binary data. By default, if no output path is provided, the CLI assigns an 8-character random ID or an API response ID for the filename.
Users specify explicit output destinations using the -o flag. The CLI also supports a --timeout flag to manage long-running requests across large media files, and a --seed flag for reproducible image generations. The Gateway integration handles the translation of these parameters, such as automatically forwarding aspect ratio settings to Google language-image models.
Standard Input and Output Integration
The CLI leverages standard input/output piping, adhering to core Unix principles. Users can pipe text files, source code, or system logs directly into the ai text command to summarize data, format JSON, or analyze specific errors. For instance, developers can pipe a failed build log into the CLI to receive an explanation of the failure from a language model. This native shell integration embeds LLM capabilities directly into existing command-line workflows, CI/CD pipelines, and shell scripts without requiring standalone applications.
Inline Terminal Previews
A feature of the ai-cli is its support for rendering media directly within the terminal interface. When executed in terminal emulators that support the Kitty graphics protocol—such as Kitty, Ghostty, WezTerm, Warp, and iTerm2—generated images and videos are displayed inline automatically.
For video outputs, the CLI generates a visual preview by extracting and decoding an H.264 keyframe from the midpoint of the generated video file. This decoding process is handled by openh264 compiled to WebAssembly (Wasm), ensuring cross-platform compatibility without requiring users to install native dependencies. Users can disable this visual output using the --no-preview flag or force it on in undetected environments using the AI_CLI_PREVIEW=1 environment variable.
Agent-Native Design and Exit Codes
The Vercel AI CLI is categorized as an agent-native tool, built to support autonomous AI coding assistants. Tools like Claude Code can incorporate the CLI via specific skill installations, enabling the agent to write terminal commands that generate necessary assets without pausing to prompt the developer. When operating in non-interactive contexts, agents are instructed to use the -o flag to save media to the disk and the --json flag to read the resulting file paths, avoiding the disruption of printing raw binary data to stdout.
To support script automation, the CLI utilizes standard exit codes. An exit code of 0 indicates success, 1 indicates that all generation attempts failed, and 2 signifies a partial failure. This latter code is particularly relevant when executing parallel batch jobs across multiple models, enabling scripts to handle cases where some models succeed while others time out.
Enjoyed this?
Get more posts like this delivered to your inbox.