> ## Documentation Index
> Fetch the complete documentation index at: https://docs.capsule.new/llms.txt
> Use this file to discover all available pages before exploring further.

# Build AI Apps In Python

> Capsule is a framework and hosted runtime for shipping AI apps with chat, pages, state, integrations, tasks, and auth.

Capsule turns one Python app definition into a hosted AI product.

You write the app. Capsule deploys it as a hosted product where each app user gets an isolated, sandboxed runtime. Inside that runtime, your agents can use Python packages, container-local files, mounted filesystems, secrets, integrations, tasks, pages, and chat together.

<CardGroup cols={2}>
  <Card title="Chat Apps" icon="message" href="/features/chat-and-sessions">
    Build assistants with persistent session history, streaming replies, uploads, integration prompts, and user identity.
  </Card>

  <Card title="Pages And UI" icon="layout-dashboard" href="/features/pages">
    Add dashboards, tables, settings, task boards, workflow screens, or custom React pages to the same app.
  </Card>

  <Card title="State And Data" icon="table" href="/features/collections">
    Store queryable records in collections, keep lightweight session state, and expose data handlers to pages.
  </Card>

  <Card title="Runtime And Deploy" icon="rocket" href="/build/deploy-an-app">
    Deploy one app definition into sandboxed per-user runtimes with packages, filesystems, tasks, schedules, and secrets.
  </Card>
</CardGroup>

## prod setup

Capsule is a serverless runtime for agent apps. You do not provision containers yourself; Capsule creates the isolated runtime your app needs when users chat, open pages, start workflows, or run scheduled work.

Create an agent app from a template:

```bash theme={null}
capsule create my-app --template quickstart
cd my-app
uv sync
```

Add any required secrets printed by the template:

```bash theme={null}
capsule secret create ANTHROPIC_API_KEY=sk-ant-...
```

Deploy the same package entry point:

```bash theme={null}
capsule deploy app.py:app
```

The deployed app gets a hosted URL, app-scoped sign-in, and the same chat handlers, pages, workflows, tasks, schedules, collections, secrets, and filesystems declared in Python. Each signed-in app user gets their own runtime context, so agents can work with files and long-running state without sharing another user's sandbox.

## templates

Start with the product shape closest to what you want to ship.

* `quickstart` for a chat app grounded in packaged context files with BAML.
* `media-studio` for fal.ai image generation displayed directly in chat.
* `browser-agent` for visible browser workflows and agent-assisted browsing.
* `background-agent` for scheduled or on-demand agent loops with a results page.

## learn by building

Start with the shortest path, then add one product surface at a time.

* [Quickstart](/quickstart) gets a working app on screen.
* [First Chat App](/build/first-chat-app) teaches the message loop.
* [Add Data And State](/build/add-data-and-state) introduces session data and collections.
* [Add Pages](/build/add-pages) turns the app into a product surface.
* [Connect Services](/build/connect-services) adds integrations, secrets, and filesystems.
* [Background Work](/build/background-work) adds tasks and schedules.
* [Deploy An App](/build/deploy-an-app) ships the app.

## feature pages

Use these when you know the feature you need.

* [Chat And Sessions](/features/chat-and-sessions)
* [Pages](/features/pages)
* [Collections](/features/collections)
* [Integrations](/features/integrations)
* [Tasks And Schedules](/features/tasks-and-schedules)
* [Channels](/features/channels)
* [Workflows](/features/workflows)
* [Pricing And Payments](/features/pricing-and-payments)
* [CLI Reference](/reference/cli)

## examples

Capsule includes examples you can copy from in project templates and example apps:

* `quickstart` for a BAML-backed assistant with packaged context
* `media-studio` for generated media in chat
* `browser-agent` for browser workflows
* `background-agent` for scheduled agent loops
