You can interact with AI Chat directly from your terminal using the PW CLI. The CLI provides an interactive TUI chat session with markdown rendering and streaming responses, as well as commands for managing chats, providers, and models.
Before using AI Chat from the CLI, ensure:
pw auth login).Before starting a chat, you can see which models are available to you:
pw ai models lsThis displays a table of all models across your configured providers. Each model is identified by a human-friendly identifier in the format owner:provider-name/model-name (for example, me:my-azure-provider/gpt-4o).
To start an interactive chat session, run:
pw ai chats newThis opens a full-screen interactive TUI. If no model is specified, an interactive model picker is displayed so you can choose from your available models. You can also specify a model directly to skip the picker:
pw ai chats new me:my-azure-provider/gpt-4oTo send a single prompt and print the response without entering the interactive TUI, use the --prompt flag. A model argument is required in non-interactive mode:
pw ai chats new -p "What is the capital of France?" me:my-azure-provider/gpt-4oBy default, non-interactive chats are not saved. To persist the conversation, add the --save flag:
pw ai chats new -p "Summarize TCP vs UDP" --save me:my-azure-provider/gpt-4oTo continue a previous conversation:
pw ai chats resume <id>The model is automatically detected from the conversation history. You can override it with the --model flag:
pw ai chats resume -m me:my-azure-provider/gpt-4o abc-123You can also send a single prompt to an existing chat:
pw ai chats resume -p "Summarize our conversation" abc-123pw ai chats lsLists your recent chats in a table, sorted with the most recent at the bottom. Use --limit and --offset for pagination, and -o json for JSON output.
pw ai chats get <id>Displays the full message history of a chat. Use -o json for JSON output.
pw ai chats delete <id>The CLI also provides commands for managing AI Chat providers:
# List all providers
pw ai providers ls
# Get details of a specific provider
pw ai providers get my-provider
# List models available for a provider
pw ai providers models my-provider
# Create a custom provider
pw ai providers create --name my-provider --csp custom --endpoint https://api.example.com --api-key sk-xxx
# Create an Azure provider
pw ai providers create --name my-azure --csp azure --region eastus --model gpt-4 --group my-group --network my-network
# Delete a provider
pw ai providers delete my-providerOnce the TUI starts, you can type messages and press Enter to send them. Responses stream in real time with markdown formatting.
pw ai chats new me:my-azure-provider/gpt-4o> Explain the difference between TCP and UDP in two sentences.
TCP is a connection-oriented protocol that guarantees reliable, ordered
delivery of data through acknowledgments and retransmissions. UDP is a
connectionless protocol that sends data without establishing a connection
or guaranteeing delivery, making it faster but less reliable.
pw ai chats new -p "List three sorting algorithms" me:my-provider/gpt-4o# List your chats to find the ID
pw ai chats ls
# Resume the conversation
pw ai chats resume abc-123