Next Basic Chat
examples/next-basic-chat is the smallest complete example for adding Vela SDK to an existing Next.js + AI SDK chat route.
Files To Read
Section titled “Files To Read”| path | Role |
|---|---|
examples/next-basic-chat/app/api/chat/handler.ts | Main Vela integration for the chat POST route |
examples/next-basic-chat/app/api/vela/readiness/route.ts | Authorization-free readiness endpoint |
examples/next-basic-chat/lib/vela-scope.ts | Stores, clears, and serializes Hosted Connect return scope into the request body |
examples/next-basic-chat/app/api/chat/route.test.ts | Tests for missing env, missing scope, blocked, deny, and allow paths |
Route Structure
Section titled “Route Structure”- Call
getVelaEnvironmentDiagnostics()before reading the request body. - Restore scope from the body
velaobject withresolveVelaExecutionScope(). - Bind scope with
createVelaIntegration({ client, executionScope }). - Create the non-allow response with
prepareExecutionWithResponse(). - Use the
@vel4ai/ai-sdkandairuntime only afterallow. - Share
execution.createResultReporter()between stream callbacks and the catch block.
Local Dogfood
Section titled “Local Dogfood”pnpm dev:velapnpm dev:next-basic-chatpnpm dev:assistant-ui-demo| Surface | URL |
|---|---|
| Vela control plane | http://localhost:4000 |
| Next basic chat | http://localhost:3000 |
| assistant-ui demo | http://localhost:4100 |
Start only one demo surface on port 4100 at a time. pnpm dev:ai-app and pnpm dev:assistant-ui-demo use the same port, so prefer pnpm dev:assistant-ui-demo during SDK dogfood work.