Skip to main content

CLI

Code AI provides a command-line interface built with Typer. Run codeai --help for the full option list.

Installation

Via pip

pip install codeai

From source

git clone https://github.com/datalayer/codeai.git
cd codeai
pip install -e .

Quick install

curl -fsSL https://raw.githubusercontent.com/datalayer/codeai/main/install.sh | bash

Interactive Mode

Launch without arguments to start an interactive session with a background codeai server:

codeai

The TUX (Terminal UX) displays a welcome panel and accepts free-form queries or slash commands. Type / to see the autocomplete menu.

Agent Selection

When started without --agentspec-id, Code AI lists all available agent specs and lets you pick one interactively:

$ codeai

Available Agent Specs:

1. ● crawler
Search and crawl web resources
2. ● data-acquisition
Acquire and process datasets
3. ● simple
General-purpose assistant

Choose an agent spec [1-3]: 2

Selected: data-acquisition

You can also type the spec ID directly instead of a number.

To skip the picker, pass --agentspec-id (or -a):

# Specific agent
codeai --agentspec-id crawler

# Short form
codeai -a data-acquisition

# With codemode disabled
codeai --agentspec-id data-acquisition --no-codemode
tip

Make sure the required environment variables for the agent's MCP servers and skills are set before launching. Check the agent spec in the agentspecs repository.

Slash Commands

CommandShortcutDescription
/helpEsc HShow available commands
/statusEsc SModel, tokens, and connectivity
/contextEsc XVisualize context usage grid
/clearEsc CClear conversation history
/toolsEsc TList available tools
/mcp-serversEsc MList MCP servers
/skillsEsc KList available skills
/codemode-toggleEsc OToggle codemode on/off
/agentsEsc AList agents on the server
/tools-lastEsc LShow tool calls from last response
/context-exportEsc EExport context to CSV
/exitEsc QExit Code AI
# Show banner with Matrix rain animation
codeai --banner

# Show banner with Matrix rain and black hole animation
codeai --banner-all

# Easter egg commands (/rain, /about, /gif)
codeai --eggs

Single-Query Mode

Pass a query as arguments for one-shot execution:

codeai "What is Python?"

codeai -a crawler "Search for AI trends"

codeai --agentspec-id data-acquisition "Fetch the latest dataset"

The CLI starts the agent server, sends the query, prints the response, and exits.

Connect to a Remote Server

Use codeai connect to attach to an already-running codeai server:

# AG-UI (HTTP/SSE) — default
codeai connect http://localhost:8000/api/v1/ag-ui/my-agent/

# ACP (WebSocket)
codeai connect ws://localhost:8000/api/v1/acp/ws/my-agent -t acp

# Remote server
codeai connect https://agent.datalayer.ai/api/v1/ag-ui/codeai-agent/

List Remote Agents

codeai agents
codeai agents --server https://agents.datalayer.ai

Options Reference

OptionShortDefaultDescription
--agentspec-id-a(interactive picker)Agent spec ID to start
--port-p8000Server port (finds free port if taken)
--banner-boffShow Matrix rain animation
--banner-all-BoffShow Matrix rain + black hole animations
--debug-doffVerbose logging
--no-codemodeoffDisable codemode
--eggsoffEnable Easter egg slash commands
--version-vShow version info

Programmatic Usage

Import the Pydantic AI agent directly for custom tooling:

from codeai.cli import agent

@agent.tool()
def my_custom_tool(data: str) -> str:
"""Custom tool description."""
return f"Processed: {data}"

agent.to_cli_sync()

Or launch the TUX programmatically:

import asyncio
from codeai.tux import run_tux

asyncio.run(run_tux(
agent_url="http://127.0.0.1:8000/api/v1/ag-ui/codeai/",
server_url="http://127.0.0.1:8000",
agent_id="codeai",
))