Deploy a minimal chat app
A no-brainer server-side tutorial from API key to deployed character chat.
This tutorial builds a tiny web chat that keeps your LoreOS API key server-side. The browser talks to your server; your server talks to LoreOS. A coding agent can follow this page in a clean workspace without private repository access.
You will:
- Create a character.
- Run a local chat UI.
- Send a user message.
- Poll LoreOS events until the character reply appears.
- Deploy the same app to Render with an invite key.
Requirements
- Node 20+
- A LoreOS API key:
- demo sandbox key for local testing; or
- invite key for persistent deployment
curljq
For a local copy-paste test, issue a short-lived demo sandbox key:
Demo keys are capped to three characters, five sessions, sixty messages, 1,200 input characters, and no image generation, managed Telegram, webhook delivery, budget changes, app creation, or extra API keys.
Use an invite key before deploying to Render. Do not deploy a demo key as a production key because it expires automatically and intentionally blocks product surfaces such as image generation, managed Telegram, webhooks, app creation, budget changes, and extra API keys.
Set your key:
1. Create the app files
Create a local folder:
Create package.json:
Create setup.mjs:
Create server.mjs:
2. Create the character
Run the setup script:
The script calls POST /v1/characters and GET /v1/characters/{slug}/readiness.
Expected shape:
needs_attention is expected for a bare text-only demo character because it has no
persona, voice guide, or identity image yet. The text chat flow below still works. For
production launch, add richer character state and check readiness again; image features
need an identity image and visual readiness.
3. Run locally
Open http://localhost:8787.
The app uses three server endpoints:
The important detail: POST /api/message does not wait for the model. It returns the
LoreOS cursor, then the browser polls /api/events until a character event appears.
4. Deploy to Render
Create a new Render Web Service from the folder examples/loreos-node-chat.
Use:
Set environment variables:
Run npm run setup once locally before deploying, or run it from Render Shell after
the env vars are set.
What success looks like
When you send a message, your browser should show:
Then, after polling the event log, it should render one or more character bubbles from:
Debug checklist
401 api key required— the server did not sendAuthorization: Bearer.403 api key invalid or revoked— rotate or reissue the key.404 character— the slug is wrong or belongs to a different app.402 budget_exceeded— raise the app or end-user cap before sending another message.- No reply yet — continue polling
GET /v1/sessions/{id}/events?since=<cursor>and check session runs/events.
Never put LOREOS_KEY in client-side JavaScript.