Pi supports a headless RPC mode for integration with IDEs and other tools.
Start Pi in RPC mode:
pi --mode rpcCommunication is via JSON Lines over stdin/stdout. Each line must be a valid JSON object.
{
"id": "req-1",
"type": "command_name",
"param": "value"
}{
"id": "req-1",
"type": "response",
"command": "command_name",
"success": true,
"data": { ... },
"error": "Error message if success is false"
}{
"type": "event_name",
"data": "..."
}- prompt: Send a user message.
- Params:
message(string),images(optional array),streamingBehavior("steer" or "follow-up").
- Params:
- steer: Interrupt current generation and steer.
- Params:
message.
- Params:
- follow_up: Queue a message to follow current turn.
- Params:
message.
- Params:
- abort: Stop generation.
- new_session: Start fresh.
- Params:
parentSession(optional path).
- Params:
- switch_session: Load session file.
- Params:
sessionPath.
- Params:
- set_session_name: Rename session.
- Params:
name.
- Params:
- export_html: Export conversation.
- Params:
outputPath.
- Params:
- compact: Trigger context compaction.
- Params:
customInstructions(optional),reserveTokens(optional),keepRecentTokens(optional).
- Params:
- fork: Fork from a message.
- Params:
entryId.
- Params:
- get_state: Get current model, settings, token usage.
- get_messages: Get conversation history.
- get_available_models: List models.
- set_model: Change model.
- Params:
provider,modelId.
- Params:
- set_thinking_level: Set thinking budget.
- Params:
level("off", "low", etc.).
- Params:
- set_steering_mode: "one-at-a-time" or "all".
- set_follow_up_mode: "one-at-a-time" or "all".
- extension_ui_response: Reply to a pending extension UI request.
- Params:
requestId(preferred) or legacy aliasid, plus one of:confirmed(boolean) forconfirmvalue(string/boolean depending on method) forselect/input/editorcancelled(true) to cancel
- Params:
agent_start: Agent started working.text_delta: Assistant text output chunk.thinking_delta: Assistant thinking output chunk.tool_execution_start: Tool execution started.tool_execution_update: Streaming tool output.tool_execution_end: Tool execution finished.extension_ui_request: Extension requested host UI interaction (confirm/select/input/editor/notify/etc.).agent_end: Turn complete.auto_retry_start/auto_retry_end: Transient error retries.auto_compaction_start/auto_compaction_end: Auto-compaction status.extension_error: Extension event dispatch/runtime error.