Quickstart: Vercel AI SDK
Esta página aún no está disponible en tu idioma.
Use the traces your AI SDK agent emits to test its behavior in Mibo. You enable the SDK’s built-in telemetry, send a trace over OpenTelemetry, and write your first tool-call test.
Before you start
Section titled “Before you start”- A Mibo account with a verified email. Open the verification link in the browser you signed up with.
- Node.js 22.18 or later to run TypeScript directly.
- An OpenAI API key for the model in this example.
Tested November 21, 2026 with Node.js 26.13.1 and the package versions pinned below.
1. Create a Mibo API key
Section titled “1. Create a Mibo API key”Open the verification link in the browser you signed up with. If you open it elsewhere, Mibo asks you to choose a new password and earlier API keys stop working. If you own the workspace, create an API key in Settings and copy it. Mibo shows the key only once. If you’re a workspace member, ask the owner for a key.
This example sets service.name with OTEL_SERVICE_NAME. A workspace key lets Mibo create an Agent with that name on the first trace. A key scoped to one Agent sends traces to that Agent. See trace routing.
2. Install the packages
Section titled “2. Install the packages”Run these commands in a new project directory. The script uses top-level await, so set the project to ES modules.
npm init -ynpm pkg set type=moduleThis guide uses AI SDK 7 with the OpenTelemetry integration from @ai-sdk/otel. AI SDK 7 accepts experimental_telemetry as a deprecated alias for telemetry. Mibo also reads the ai.* attributes emitted by AI SDK 5.
3. Point the exporter at Mibo
Section titled “3. Point the exporter at Mibo”export OTEL_SERVICE_NAME=vercel-supportexport OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://api.mibo-ai.com/public/tracesexport OTEL_EXPORTER_OTLP_TRACES_HEADERS='x-api-key=<YOUR_MIBO_API_KEY>'export OTEL_METRICS_EXPORTER=noneexport OTEL_LOGS_EXPORTER=noneexport OPENAI_API_KEY='<YOUR_OPENAI_API_KEY>'The exporter uses the traces-specific endpoint as written. If you use the generic OTEL_EXPORTER_OTLP_ENDPOINT, set it to https://api.mibo-ai.com so the exporter appends /v1/traces to the base URL. The metrics and logs settings keep the SDK focused on trace export.
4. Send your first trace
Section titled “4. Send your first trace”Save the following as agent.ts.
import { OpenTelemetry } from '@ai-sdk/otel';import { openai } from '@ai-sdk/openai';import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';import { NodeSDK } from '@opentelemetry/sdk-node';import { generateText, registerTelemetry, stepCountIs, tool } from 'ai';import { z } from 'zod';
const sdk = new NodeSDK({ traceExporter: new OTLPTraceExporter({ timeoutMillis: 10_000 }),});sdk.start();registerTelemetry(new OpenTelemetry({ agentSpanName: 'functionId' }));
try { const { text } = await generateText({ model: openai.chat('gpt-4o-mini'), prompt: 'Use lookupOrder to check order A-1042.', tools: { lookupOrder: tool({ description: 'Look up an order by ID', inputSchema: z.object({ orderId: z.string() }), execute: async ({ orderId }) => ({ orderId, status: 'shipped', eta: 'Friday' }), }), }, stopWhen: stepCountIs(3), timeout: 20_000, maxRetries: 0, experimental_telemetry: { isEnabled: true, functionId: 'support-agent' }, });
console.log(text);} finally { await sdk.shutdown();}Run the script.
node agent.tsThe script prints the model’s reply, for example Your order A-1042 has shipped and should arrive on Friday. Awaiting sdk.shutdown() flushes buffered spans before the script exits. In a server, start the SDK once and shut it down when the server stops.
Open Traces and select the Agent that received the trace by its current name. If Mibo created the Agent for this example, its initial name is vercel-support. Open the order trace and click View raw trace data to inspect the invoke_agent support-agent and chat gpt-4o-mini spans. If the model called lookupOrder, you’ll also see execute_tool lookupOrder in the raw data and the call under What the agent did.
5. Create your first test
Section titled “5. Create your first test”- Wait for the order trace to finish, then click Create test from this trace.
- Open Draft if the editor shows tabs. Set Name to
Looks up the orderand clear Checks a trace when so the test checks each new trace for this Agent. - Keep the Tool call check. If the draft omits it, choose Tool call from Does check. Set Tool name to
lookupOrderand select Must call. Remove the other checks and click Save test. - Run
node agent.tsagain. Open the new trace on Traces and look under Test results. The check passes when the trace records a call tolookupOrder.
What Mibo reads from the trace
Section titled “What Mibo reads from the trace”| Data | AI SDK 7 OpenTelemetry attributes |
|---|---|
| User input and final reply | gen_ai.input.messages and gen_ai.output.messages |
| Requested model | gen_ai.request.model |
| Tool name and arguments | gen_ai.tool.name and gen_ai.tool.call.arguments on the tool span |
| Token usage | gen_ai.usage.input_tokens and gen_ai.usage.output_tokens |
The recordInputs and recordOutputs telemetry options default to true. With recordInputs: false, Mibo skips tests that have a Checks a trace when condition if the trace has no usable user input. With recordOutputs: false, checks on the reply have no text to read. Review Data handling before sending traces that contain personal data.
Endpoint reference
Section titled “Endpoint reference”Send OTLP/HTTP protobuf with x-api-key to https://api.mibo-ai.com/public/traces. See OpenTelemetry (OTLP) for OTLP/HTTP JSON, gzip compression, and exporter settings.
Troubleshooting
Section titled “Troubleshooting”| Problem | Likely cause | Solution |
|---|---|---|
404 or connection error |
Wrong host or path, such as /public/traces/v1/traces |
Set OTEL_EXPORTER_OTLP_TRACES_ENDPOINT to https://api.mibo-ai.com/public/traces. |
| HTTP 401 | Missing, invalid, or revoked key | Check the x-api-key entry in OTEL_EXPORTER_OTLP_TRACES_HEADERS. Ask the workspace owner to check whether the key is active. |
HTTP 401 with API_KEY_EXPIRED in the message |
The API key expired | Set x-api-key in OTEL_EXPORTER_OTLP_TRACES_HEADERS to an active key and rerun the script. |
| Export fails with a gRPC transport error | The exporter uses OTLP/gRPC | Use @opentelemetry/exporter-trace-otlp-proto for OTLP/HTTP protobuf. |
HTTP 400 with a message beginning OTLP traces need the 'service.name' resource attribute |
service.name is unset or defaults to unknown_service, and Mibo can’t infer the Agent |
Set OTEL_SERVICE_NAME before starting the SDK. |
| The script prints a reply but no trace appears | The process exits with spans still buffered | Await sdk.shutdown() in a short script. If you manage a tracer provider directly, await its forceFlush() to export buffered spans while it stays active. |
403 AGENT_LIMIT_REACHED |
Your plan has reached its Agent limit | Use an existing Agent or free capacity for a new one. See Agent limit reached. |
| HTTP 403 with “Monthly trace ingestion limit reached” in the message | Your workspace has used its monthly trace quota | Wait for the next usage period or upgrade. Once capacity returns, rerun the script or resend the rejected payload. |
| Export succeeds but the trace is hidden or tool calls are missing | Content capture is off, or the instrumentation emits an unsupported set of attributes | Keep recordInputs and recordOutputs enabled. Check the supported trace dialects. |
What’s next
Section titled “What’s next”- Creating test cases to check more of your Agent’s behavior.
- OpenTelemetry (OTLP) for routing, batching, and response codes.
- Collector fan-out to send a copy of your existing traces to Mibo.