Overview
Vercel’s AI SDK is a robust, end to end framework for powering your Agent. Freeplay provides a simple, lightweight integration to instrument your Agent, making it easy for you to:- Log agent interactions
- Evaluate your agent’s behavior and identify issues
- Iterate on your system prompt and monitor the impact
This guide will walk you through:
- Initializing Freeplay in your code - Installing dependencies and configuring your environment
- Managing your prompts in Freeplay - Migrating prompt and model configurations to Freeplay and accessing them in your app
- Integrating observability - Adding Freeplay logging to your SDK code for comprehensive data capture and agent tracing
Prerequisites
Before you begin, make sure you have- A Freeplay account with an active project
- You’re using Vercel AI SDK v5 or greater
Installation
Install the Freeplay Vercel SDK along with the required dependencies@opentelemetry/sdk-trace-base)
Configuration
Set up your credentials
Configure the following environment variables:Initialize the FreeplaySpanProcessor
Next JS instrumentation.ts
If you’re using Next’s included Telemetry harness, you can simply add the Freeplay processor to your existing setup
Node manual telemetry setup
If you’re not using Vercel’s Telemetry, you can add Freeplay’s Span Processor to another library when you initialize your app. For example:Using Freeplay-Hosted Prompts (Recommended)
One of Freeplay’s most powerful features is centralized prompt management. Instead of hardcoding prompts in your application, call them from Freeplay with version control and environment management.Using Raw OTEL
With this method, you can use the AI SDK as you normally may, and just need to add the following code snippet to yourstreamText (or similar) method you’re using for chat.
NOTE: This is not recommended except for initial testing, as many Freeplay features will not be available if you do not implement Freeplay prompt management.
Automatic Observability
Once initialized, the Freeplay SDK automatically instruments your Vercel AI SDK application with OpenTelemetry. This means every chat turn is traced and sent to Freeplay without any additional code.What Gets Tracked
Freeplay automatically captures:- LLM Interactions: Prompt version, inputs, provider, model name, tokens used, latency
- Tool executions: Which tools were called and their results
- Conversation flows: Multi-turn interactions and state transitions
Next Steps
Now that you’ve integrated Freeplay with your AI SDK application, you can:- Create and manage prompts in the Freeplay dashboard with version control
- Set up environments to test changes in staging before deploying to production
- Build evaluation datasets to systematically test your application’s performance
- Analyze traces to identify bottlenecks and optimize your agent workflows
- Collaborate with your team on prompt engineering and application improvements

