Skip to main content

1. Create the actor project

To follow this tutorial you need:
  • Node.js 22.19 or later
  • A Terse account
  • An OpenAI API key
Choose a language.
Create .env in agent-chat/. Add your provider key:
.env

2. Define the actor

src/actor.ts

3. Run locally and generate the client

Start the actor server:
Keep it running. Open a second terminal in agent-chat/. Generate the backend client:
Generated code points to http://127.0.0.1:7100/v1/projects/local/actors by default. Regenerate after making changes to actor code.

4. Add the application backend

app.ts

5. Connect the browser

frontend/vite.config.js
frontend/src/App.jsx

6. Try streaming and persistence

Start the app:
Open a third terminal in agent-chat/. Start React:

7. Deploy to Terse

From the actor project:
Open the Terse app. Open your profile menu. Select API tokens. Create a token and copy it.

Test the deployed actor locally

Keep React and your backend on your machine. Connect them to the actor running on Terse. Add these values to agent-chat/.env. Use the URL from terse deploy and your Terse API token:
Regenerate the client and restart the backend from agent-chat/:
Open http://localhost:5173 to use the app.