# Deploy to production

Deploy OrchaJS agents with your existing npm run build and production environment keys.

Source: https://orcha.sh/docs/tutorial/production
Markdown: https://orcha.sh/docs/tutorial/production.mdx

Your production workflow does not need a separate Orcha build configuration.
Use the build command your project already uses:

```bash
npm run build
```

Orcha is compiled and included as part of the application build. The same
agent folders and runtime API you used locally are used in production.

## Configure production credentials

Provide model-provider credentials through your deployment environment:

```bash
ANTHROPIC_API_KEY=...
```

Do not copy a local `.env` file into the production bundle.

## Deploy the application

Deploy the output of `npm run build` the same way you deploy the rest of your
Node.js application. No playground frontend is included in the production
output.

Application code remains unchanged:

```ts

const result = await orcha.assistant.run(
  "Explain durable sessions.",
).result;
```

## Preserve durable sessions

The default Node storage writes sessions under `.orcha/sessions`. Use
persistent shared storage when a session must:

- survive a process or container restart,
- resume on another application instance,
- wait for a client action and continue later.

Read sessions through `get()`, `history()`, `events()`, and `list()` rather
than accessing storage files directly.

## Production checklist

- Run `npm run build` in CI.
- Run focused agent tests before deployment.
- Supply provider credentials through the production environment.
- Keep `.orcha/sessions` on persistent storage when sessions must resume.
- Save `sessionId` in your application database when users may return later.
- Await `execution.evaluations` in short-lived jobs when scores must finish
  before the process exits.
