> For the complete documentation index, see [llms.txt](https://docs.layerlens.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.layerlens.ai/6.-build-wire-your-code/instrument-vercel-ai-sdk.md).

# Instrument Vercel AI SDK

Recipe — instrument a Vercel AI SDK call to emit traces (via REST).

**When to use:** Next.js or other Vercel AI SDK users.

## Steps (TypeScript)

Post traces via the REST API from your server route:

```typescript
await fetch("https://stratix.layerlens.ai/api/v1/traces", {
 method: "POST",
 headers: { "X-API-Key": process.env.LAYERLENS_STRATIX_API_KEY!, "Content-Type": "application/json" },
 body: JSON.stringify({ id, name: "ai-sdk-call", inputs, outputs, spans })
});
```

## See also

* [REST API](/13.2-surfaces/rest-api.md)
