Set up Respan
Set up Respan
- Sign up — Create an account at platform.respan.ai
- Create an API key — Generate one on the API keys page
- Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page
Use AI
Use AI
Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.
What is 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.Example project
Example project
Setup
Create instrumentation file
Create
instrumentation.ts in your project root (same level as package.json):instrumentation.ts
Enable telemetry in AI calls
Add
experimental_telemetry to every AI SDK call. Use functionId to name each span and metadata to attach custom properties:View your trace
Open the Traces page to see your AI calls with full input/output, token usage, and cost.
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
apiKey | string | RESPAN_API_KEY env var | Respan API key. |
baseUrl | string | "https://api.respan.ai" | API base URL. |
debug | boolean | false | Enable debug logging for troubleshooting. |
Next.js streaming routes: If your AI calls use streaming (
streamText), set maxDuration in your route handler to avoid Vercel’s default timeout:Examples
Basic generation
Multi-step pipeline with metadata
EachgenerateText / streamText call creates a traced span. All spans within the same request are grouped into a single trace:
Streaming with tools
Attributes
Pass metadata and customer identifiers through theexperimental_telemetry.metadata object. The exporter maps these to Respan fields automatically:
| Attribute | Description |
|---|---|
customer_identifier | User/customer identifier for filtering in the dashboard. |
customer_name | Customer display name. |
customer_email | Customer email. |
thread_identifier | Conversation thread ID. |
| Any custom key | Added to the span’s metadata object in Respan. |
Troubleshooting
Missing @vercel/otel dependencies
Missing @vercel/otel dependencies
The If dependency conflicts persist, use yarn which is more lenient with peer dependencies:
@vercel/otel package may have broken peer dependencies. If you see missing module errors on startup, install them directly:package.json
No traces appearing
No traces appearing
- Verify
experimental_telemetry: { isEnabled: true }is set on every AI SDK call - Check that
instrumentation.tsis in your project root (same level aspackage.json) - Ensure
RESPAN_API_KEYis set in your environment - Enable debug mode to see export logs:
Turbopack workspace root warning
Turbopack workspace root warning
If you see “Next.js inferred your workspace root, but it may not be correct”, set the root explicitly in
next.config.js:next.config.js
Looking for gateway integration? See Gateway > Vercel AI SDK.