Skip to main content
The Session API lets you send HTTP requests directly to your running Pipecat Cloud agents. This enables real-time control and data exchange with active sessions, such as updating conversation context, triggering actions, or retrieving session state.

How It Works

Your bot runs inside a FastAPI server managed by the Pipecat Cloud base image. When you define custom endpoints using the app object from pipecatcloud_system, they become reachable through the Session API. Requests are proxied through Pipecat Cloud to the specific bot instance handling your session:
Diagram of the deployment architecture of Session
API
To use the Session API:
1

Start a session

Start a session with your agent and capture the sessionId from the response.
2

Define endpoints in your bot

Add custom routes to the app object from pipecatcloud_system in your bot.py.
3

Send requests to your session

Make HTTP requests to the session endpoint. Pipecat Cloud routes them to the bot instance for that session.

Endpoint Format

Supported Methods

GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD

Authentication

Include your Pipecat Cloud public API key in the Authorization header:

Setting Up Your Bot

Define endpoints in your bot.py using the app object from pipecatcloud_system. This is the same FastAPI application that serves your bot, so your custom routes run alongside the built-in ones.
Requires base image version 0.1.2 or later.

Connecting Endpoints to Your Pipeline

Most Session API use cases require your endpoint to interact with the running pipeline. The pattern is:
  1. Store a reference to your PipelineWorker in a module-level variable
  2. Access it from your endpoint handler to queue frames into the pipeline
Since Pipecat Cloud runs one session per pod, a single module-level variable works well. You don’t need to key by session ID.

Examples

Update Conversation Context

Use LLMMessagesAppendFrame to add messages to the LLM’s conversation context from an HTTP request. Setting run_llm=True tells the pipeline to immediately send the updated context to the LLM for a response.
Call the endpoint:

Trigger the Bot to Speak

Use TTSSpeakFrame to make the bot say something on demand:
Call the endpoint:

Get Session Status

Endpoints don’t have to interact with the pipeline. You can also use them to expose any state your bot tracks:

Important Notes

  • Startup latency: If you call the Session API before your bot finishes initializing, the request may take longer while waiting for the bot to become available.
  • Session scope: Each request is routed to the specific bot instance identified by session_id. Different sessions are separate pods and don’t share state.
  • Error handling: If a session has ended or the session ID is invalid, you’ll receive an error response.
  • Reserved paths: The base image uses /bot, /ws, /api/offer, /whatsapp, /readyz, and /livez. Don’t define endpoints at these paths.

Getting Help

If you have questions about the Session API, reach out on Discord.