Learning resourcesReviewed · Pydantic

Pydantic AI CLI guide: clai

This guide shows developers how to use clai, the command-line tool that comes with the Pydantic AI Python library, to chat with AI language models and their own Pydantic AI agents in a terminal or browser; a model provider must be configured and costs are not stated. It covers installation, model selection, custom Python agents, conversation history and connections to external tools through MCP.

Researched 15 Nov 2026

In short.

The Pydantic AI CLI guide helps developers chat with language models and their own agents through a terminal or browser, but requires provider configuration and leaves costs unspecified. It provides concrete installation commands, Python entry points and browser options. Its MCP configuration warning is significant: configuration files can start programs and access environment variables. Runtime behavior, compatibility, performance and answer quality are not assessed.

Researched and written by an AI model and checked by a second AI model. How it works

The scope is the complete captured page at [https://pydantic.dev/docs/ai/integrations/cli/index.md], including installation, terminal options, MCP configuration and its trust warning, custom agents, supplied message history, browser options, and the documentation-index and query-parameter notices. Linked pages, package metadata, repository code, provider terms and external model catalogs are excluded. No commands or code were executed. Installation, network behavior, model availability, security controls, performance and output quality remain unverified.

The overview

Identity

This is Pydantic AI's documentation for clai, pronounced clay. It explains a command-line chat interface and a browser chat interface served through uvicorn. The resource is a usage guide rather than a complete reference for Pydantic AI or its model providers. Source: [https://pydantic.dev/docs/ai/integrations/cli/index.md].

Assessment

The guide provides concrete starting points for terminal chat and an interface for existing Pydantic AI agents. Installation commands, provider configuration, agent references and browser options make it useful as a practical reference. It does not establish installation success, operational reliability, model quality or suitability for public deployment.

Users

Terminal users can follow the basic path without defining a Python agent, provided they can install a command-line tool and configure their chosen provider. Python developers get more control by loading an existing Agent instance, supplying conversation history or opening the interface from application code. Beginners unfamiliar with environment variables, imports or asynchronous Python will need background beyond this page.

Capabilities

The terminal supports interactive conversations and a single positional prompt for one-shot use. Responses stream by default, with tool calls displayed as they run; --no-stream prints only the final answer. Interactive commands cover exiting, displaying the previous response as Markdown, multiline input, copying the previous response and viewing cumulative usage.

The browser interface supports selectable models and native tools, custom agents, system instructions and an alternative HTML source. With a custom agent, additional instructions supplement its existing instructions. Repeated -m options add model choices; the agent's configured model remains the default when --agent is supplied.

Using it

Requirements

The documented installation routes use uvx, uv tool install or pip. Provider configuration is required; the OpenAI example uses the OPENAI_API_KEY environment variable. A custom agent must be an Agent instance in an importable Python module, referenced as module:variable.

Minimum Python versions, supported operating systems, dependency versions and hardware requirements are not stated. The page does not establish an offline or local-model setup.

Mechanism

The interface accepts a model identifier in provider:model format or loads a configured Pydantic AI Agent through --agent. Agent.to_cli_sync() and the asynchronous Agent.to_cli() expose the same terminal interface from Python.

Both Python methods accept message_history to supply previous exchanges. The example represents those exchanges with ModelRequest and ModelResponse objects containing user-prompt and text parts. This demonstrates supplying conversation context; it does not establish automatic storage or restoration between sessions.

MCP connections use a JSON configuration containing mcpServers entries. The examples include a subprocess-based server and an HTTP server URL. MCP provides access to external tools; the actual capabilities depend on the configured servers.

Setup

The shortest documented launch command is uvx clai. Persistent installation options are uv tool install clai and pip install clai, followed by clai. Configure the relevant provider environment variable before starting a conversation. Use --model to select a model and clai --list-models to inspect the CLI's available model list.

The documented browser command is clai web -m openai:gpt-6.1-sol. Its default address is [http://127.0.0.1:7932/]. Host and port are configurable, and --allowed-host adds hostnames the server will answer. The full option list is available through clai web --help.

Example

The custom-agent example creates an Agent in custom_agent.py with an OpenAI model and instructions to respond in Italian. The command clai --agent custom_agent:agent "What's the weather today?" then runs that agent once, in one-shot mode, with the supplied prompt.

This illustrates loading a Python-defined agent and its instructions. No weather tool is configured in the example, so the weather prompt does not demonstrate access to current weather. The example has not been executed, and no response or successful result is established.

Assessment & evidence

Limitations

The page explicitly treats MCP configuration files as trusted input. They can name executables to launch and expand variable references against the full process environment. Someone able to write the configuration can therefore arrange command execution and access environment variables; only a configuration under the user's control should be supplied.

The memory native tool cannot be enabled through -t memory. It must be configured as MemoryTool on an agent supplied through --agent. Supported combinations of providers and other native tools are not detailed on this page.

Authentication, TLS, multiuser isolation and conversation persistence for the browser server are not described. The browser example also names my_agent.py but invokes my_module:my_agent; the module reference needs to match the actual importable module.

Reasoning

The documented interfaces suggest a useful fit for developers who already have Pydantic AI agents and want a chat front end: they can reference an existing instance or call its CLI methods directly. Users seeking basic model chat have a shorter standalone-command path. This fit assessment follows from the documented interfaces; it does not establish reliability, better answers or a productivity gain.

Alternatives

Within clai, interactive terminal mode suits an ongoing conversation, a positional prompt suits a single request, and web mode supplies a browser interface. The Python methods offer another entry point when an application already owns the Agent instance.

The page names Claude Desktop, Claude Code and Cursor to explain the shared MCP configuration shape. That compatibility statement does not establish feature parity. No comparative evidence supports ranking clai against those products or other chat tools.

Evidence

The source is the complete Command Line Interface documentation page at [https://pydantic.dev/docs/ai/integrations/cli/index.md], captured on 2026-11-15.

The text establishes documented commands, options, examples and the MCP trust warning. It supplies no execution receipts, benchmarks, installation results or observed model responses. Linked documentation and underlying implementation are outside the available evidence.

Access & freshness

Costs

The page provides no software price, subscription terms, provider rates or worked cost example. Total cost is unknown. Charges for the chosen provider and any connected services require separate confirmation.

The /usage command reports cumulative turns, input and output tokens, requests and tool calls. Adding --json returns a single-line JSON object. These usage counts do not establish monetary cost.

Rights

The page does not state licenses for the documentation, examples or software, so reuse and redistribution permissions are unknown from this source. Provider terms, rights in generated output and the retention of prompts or conversation data are also unspecified.

Freshness

The supplied snapshot was captured on 2026-11-15 at 14:21:07.578 UTC. The page states no release version or last-updated date, so that timestamp establishes the age of the captured copy rather than the age of each feature.

The examples name openai:gpt-6.1-sol and anthropic:claude-sonnet-5-5. Their current availability, account access and compatibility are not independently established. The documented --version and --list-models options provide ways for users to inspect their installed environment.

Actions

Start with the documented terminal path, configure the intended provider and confirm its model access and pricing. For an existing agent, use its actual importable module and variable name. Choose the synchronous or asynchronous Python entry point to match the surrounding application.

Add MCP connections only from a configuration you control. For browser use, confirm the needed native-tool support and access controls before making the server available beyond its default local address. Treat the provided commands as documentation examples; successful operation remains unverified.

Evidence for this report

selected-page.txtselected · checked 2026-11-15