# Export app

Compile a workflow into a standalone, readable FastAPI project with endpoints, OpenAPI, tests, Docker assets and the AgenticMind runtime vendored in.

Source: https://glamorous-boar.cloudvent.net/export-app/

---

**Export app** turns a saved revision into a standalone FastAPI project that runs without the AgenticMind server. It is readable, tested, reproducible and never contains secret values.

## Export

1. Save the project.
2. Click **Export app** in the toolbar. The preview lists the endpoints, requirements, warnings and checks.
3. Download the ZIP.

<CodeBlock language="bash" filename="terminal" showCopy={true}>

```
unzip my-project.zip && cd my-project
cp .env.example .env          # add OPENROUTER_API_KEY=... and APP_API_KEYS=<a long random key>
uv sync
uv run uvicorn app.main:app --port 8080
# or: docker compose up --build
```

</CodeBlock>

Open `http://localhost:8080/docs` for the interactive OpenAPI docs.

<CodeBlock language="bash" filename="terminal" showCopy={true}>

```
curl -X POST http://localhost:8080/answer \
  -H "X-API-Key: $APP_API_KEY" -H "Content-Type: application/json" \
  -d '{"question": "What is the hotel limit per night?"}'
```

</CodeBlock>

## How the API is derived from the graph

- Each **Output key** becomes `POST /<key>` (Output nodes sharing a key on alternative branches share an endpoint), plus `POST /run` when there are several.
- Each endpoint's **request fields** are the Manual Inputs among its run-target ancestors (typed from `value_type`, with defaults and `required`).
- **Response fields** are typed from the port feeding each Output.
- Every endpoint's plan is compiled at export time **and** at app start-up, so an invalid graph fails early.

### Customising endpoints

Add `metadata.api.endpoints` to the IR (Export IR, edit, Import IR):

<CodeBlock language="json" filename="IR metadata" showCopy={true}>

```
{"api": {"endpoints": [
  {"name": "ask", "path": "/v1/ask", "outputs": ["answer"], "auth": "api_key",
   "rate_limit_per_minute": 30, "summary": "Answer a question about the handbook"}
]}}
```

</CodeBlock>

`outputs` takes Output node IDs or keys; `auth` is `api_key` or `none`. Problems are reported as `API_ENDPOINT_INVALID` or `API_UNKNOWN_OUTPUT`.

## What is inside

<FileTree title="Exported project">

```
my-project/
  agenticmind.yaml
  architecture/
    graph.json
    schemas/
  openapi.json
  app/
    main.py
    runtime.py
    endpoints.py
    api/
      routes.py
      models.py
      security.py
  tests/
  examples/
  data/
  vendor/
  pyproject.toml
  requirements.txt
  Dockerfile
  compose.yaml
  .env.example
  README.md
```

</FileTree>

| Path | Contents |
|---|---|
| `agenticmind.yaml` | Build manifest: IR hash, compiler version and checks, node types/versions/packages, endpoints, requirements |
| `architecture/graph.json` | The canonical IR (re-import it into AgenticMind) |
| `architecture/schemas/` | Request/response JSON Schemas per endpoint |
| `openapi.json` | OpenAPI 3.1 contract |
| `app/main.py` | FastAPI app factory, `/healthz`, `/docs` |
| `app/api/` | One route per endpoint, Pydantic request/response models (unknown fields rejected), API-key auth and rate limit |
| `app/runtime.py` | Loads `graph.json` and runs it with the vendored runtime |
| `tests/` | Contract tests: health, OpenAPI, unknown-field rejection, auth required, and real runs for endpoints that need no keys or network |
| `data/` | Uploaded files the graph references |
| `vendor/` | The pinned AgenticMind runtime and exactly the node packages the graph uses |
| `pyproject.toml`, `requirements.txt` | uv project with path sources; pinned third-party versions and only the extras the graph needs |

## Security defaults

- `X-API-Key` checked against `APP_API_KEYS` (constant-time). **Without keys, protected endpoints answer 503** (fail closed).
- A per-process rate limit.
- Secrets read from the environment by name; `.env.example` lists names only.
- Generated code is formatted and linted with ruff.

## Reproducible

No timestamps in generated files; the ZIP has sorted entries with fixed dates and modes, so the same IR gives byte-identical output.

## Limits

- Human-approval pauses answer `409` (durable approvals need the AgenticMind server).
- Memory is in-process; rate limits are per process.
- No triggers, streaming or image uploads in exported apps yet.
- Graphs using third-party node packages cannot be exported yet.

Ready to run it somewhere? See the [Deployment Center](/deployment/).
