Skip to main content

A local-first chat UI for Pydantic AI agents

Project description

Pydantic Chat

A local-first chat UI for your Pydantic AI agents.

uvx pydantic-chat <module>:<agent variable>

# e.g. uvx pydantic-chat src.my_agent:agent

What is it?

Pydantic Chat provides a beautiful web interface for interacting with your Pydantic AI agents. Your agent runs locally on your machine, and the chat UI can be accessed either via localhost or through a secure remote URL.

Installation

# Install with uv (recommended)
uv tool install pydantic-chat

# Or install in development mode
cd agent
uv pip install -e ".[cli]"

Requirements

You need to have an API key from at least one supported LLM provider:

# Anthropic (Claude)
export ANTHROPIC_API_KEY="your-key-here"

# OpenAI (GPT)
export OPENAI_API_KEY="your-key-here"

# Google (Gemini)
export GOOGLE_API_KEY="your-key-here"

# Mistral
export MISTRAL_API_KEY="your-key-here"

# Groq
export GROQ_API_KEY="your-key-here"

Recommended: Add your API key to a .env file:

# .env
ANTHROPIC_API_KEY="your-key-here"

Then source it before running:

source .env && pydantic-chat your_module:agent

Usage

# Basic usage
pydantic-chat module.path:agent_variable

# Example
pydantic-chat chatbot.agent:agent

# Localhost-only mode (skip remote registration)
pydantic-chat --localhost chatbot.agent:agent

# Custom port
pydantic-chat --port 8000 chatbot.agent:agent

How It Works

  1. Local Server: Your agent runs on your machine with a FastAPI server
  2. Remote Access (Optional): On first run, you'll be prompted to choose a project slug (e.g., my-project)
  3. Two URLs: Access your chat via:
    • Local: http://127.0.0.1:PORT
    • Remote: https://your-project.pydantic.work/ (if registered)

Your agent code and data never leave your machine. The remote URL just provides the frontend.

Example Agent

# src/my_agent.py
from pydantic_ai import Agent

agent = Agent(
    'anthropic:claude-sonnet-4-0',
    instructions="You are a helpful assistant."
)

@agent.tool_plain
def get_current_time() -> str:
    """Get the current time."""
    from datetime import datetime
    return datetime.now().strftime("%I:%M %p")

Run it:

export ANTHROPIC_API_KEY="your-key-here"
pydantic-chat src.my_agent:agent

Configuration

On first run, Pydantic Chat creates .pydantic-chat/config.json in your project directory with your slug, token, and port. This folder is automatically added to .gitignore.

Patterns

Multiple Projects

Each project directory gets its own config, so you can run multiple agents with different slugs:

cd project-a && pydantic-chat agent:agent  # -> project-a.pydantic.work
cd project-b && pydantic-chat agent:agent  # -> project-b.pydantic.work

Environment Files

Keep your API keys in a .env file at the project root:

# .env
ANTHROPIC_API_KEY="sk-ant-..."
OPENAI_API_KEY="sk-..."

# AVOID committing credentials to your repository
echo -e "\n.env" >> .gitignore

Troubleshooting

No API keys found: Export at least one supported API key before running.

Failed to load agent: Check that your module path is correct (module.path:variable_name).

Registration failed: The server will automatically fall back to localhost mode. Use --localhost to skip registration entirely.

Slug already taken: Choose a different slug when prompted. Slugs are globally unique.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_work-0.1.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_work-0.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_work-0.1.0.tar.gz.

File metadata

  • Download URL: pydantic_work-0.1.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.12

File hashes

Hashes for pydantic_work-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d313fc740a341353a496b26c0f9fd78b55c9b26d3d6a610f5be73bf4204a8916
MD5 8d39ca054cd8df7e9b84d29928571f44
BLAKE2b-256 fa7d67d87bebca1d954cff68c605579e9c608e66e4cc0b7f03642b0b2fca2c5d

See more details on using hashes here.

File details

Details for the file pydantic_work-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_work-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5a6cc66e5532cfb85bfb6a17939ce013940bec9f166e5057c21b6c082d5f1be
MD5 4686648127babddaf47e4d1243555c74
BLAKE2b-256 5a7e86c7ad220320e6bac7728abe2021589658e965451b7d1868a70cbaeaa049

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page