FRAMEWORK

Vercel AI SDK

Resolve governed behavior before generation, preserve native AI SDK streaming, and record the exact behavior identity when generation finishes.

EXECUTION BOUNDARY

Vira resolves before generation and contributes the compiled provider projection. The AI SDK still owns model invocation, streaming, and response delivery.

IDENTITY PRESERVED

Keep the behavior identity attached to the host framework.

  • project and application
  • Behavior Point
  • exact behavior revision
  • trace identity
  • provider target

SUPPORTED OPERATIONS

Use Vira where the control boundary actually belongs.

  1. 01

    resolve before generation

  2. 02

    prepend the compiled provider projection

  3. 03

    preserve streaming and non-streaming calls

  4. 04

    record finish output against the resolve-issued trace

  5. 05

    run shadow execution out of band when configured

IMPLEMENTATION HOOK

Keep the host runtime native.

This example mirrors the repository documentation. The exact API contract remains in Docs and source.

import { createViraMiddleware } from "@vira-behavior/ai-sdk";
const runtimeClient = { resolve: async (request: Parameters<typeof vira.resolve>[0]) => { const resolved = await vira.resolve(request); if (!resolved) throw new Error("VIRA_BEHAVIOR_NOT_RESOLVED"); return resolved; } };
const middleware = createViraMiddleware({ client: runtimeClient, request: resolveRequest });
// Wrap the existing model; streaming stays native.

SECURITY BOUNDARY

Integration does not equal authority.

Boundary

Runtime credentials stay scoped to project, application, environment, and capability.

Boundary

Control-plane publish authority is not granted to ordinary runtime middleware.

LIMITATIONS

State what the adapter does not control.

  • Vira does not replace the AI SDK request/stream lifecycle.
  • Shadow output must not replace the served response.
  • Client code must not invent or substitute a behavior revision.

Use the integration guide for the exact runtime contract.