Vercel AI SDK
The AI SDK (by Vercel) is a TypeScript toolkit for building AI-powered applications with Next.js, React, and other frameworks. It provides unified APIs for text generation, streaming, tool use, and structured outputs across multiple LLM providers. Respan gives you full observability over every LLM call, tool execution, and multi-step workflow — and gateway routing to 250+ models.
Set up Respan
Create an account at platform.respan.ai and grab an API key. For gateway, also add credits or a provider key.
Run npx @respan/cli setup to set up with your coding agent.
Example projects
Tracing
Gateway
Setup
Set environment variables
OPENAI_API_KEY is used for LLM requests. RESPAN_API_KEY is used to export traces to Respan.
Initialize Respan
Next.js
Serverless / Node
Create instrumentation.ts in your project root (same level as package.json). Next.js calls register() automatically at startup.
Then add serverExternalPackages to next.config.ts:
View your trace
Open the Traces page to see your AI calls with full input/output, token usage, tool calls, and cost.
Configuration
Attributes
With experimental_telemetry metadata
Pass metadata directly on each AI SDK call. The instrumentation maps these to Respan fields automatically.
With propagateAttributes
Override per-request using a context scope. All AI SDK calls within the scope inherit these attributes.
Decorators (optional)
Decorators are not required. All generateText, streamText, tool calls, and agent steps are auto-traced by the instrumentor. Use withWorkflow and withTask to add structure when you want to group AI calls into named workflows with nested tasks.