コンテンツにスキップ

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.

pathRole
examples/next-basic-chat/app/api/chat/handler.tsMain Vela integration for the chat POST route
examples/next-basic-chat/app/api/vela/readiness/route.tsAuthorization-free readiness endpoint
examples/next-basic-chat/lib/vela-scope.tsStores, clears, and serializes Hosted Connect return scope into the request body
examples/next-basic-chat/app/api/chat/route.test.tsTests for missing env, missing scope, blocked, deny, and allow paths
  1. Call getVelaEnvironmentDiagnostics() before reading the request body.
  2. Restore scope from the body vela object with resolveVelaExecutionScope().
  3. Bind scope with createVelaIntegration({ client, executionScope }).
  4. Create the non-allow response with prepareExecutionWithResponse().
  5. Use the @vel4ai/ai-sdk and ai runtime only after allow.
  6. Share execution.createResultReporter() between stream callbacks and the catch block.
Terminal window
pnpm dev:vela
pnpm dev:next-basic-chat
pnpm dev:assistant-ui-demo
SurfaceURL
Vela control planehttp://localhost:4000
Next basic chathttp://localhost:3000
assistant-ui demohttp://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.