Skip to main content
Helicone OSS LLM Observability

Vercel AI SDK Integration

Integrate Helicone AI Gateway with Vercel AI SDK to access 100+ LLM providers with full observability.
2 min read

Introduction#

Vercel AI SDK is a TypeScript toolkit for building AI-powered applications with React, Next.js, Vue, and more.

Note

The Helicone provider for Vercel AI SDK is available as a dedicated package: @helicone/ai-sdk-provider.

Integration Steps#

Create an account and generate an API key

Sign up at helicone.ai and generate an API key.

Note

You'll also need to configure your provider API keys (OpenAI, Anthropic, etc.) at Helicone Providers for BYOK (Bring Your Own Keys).

Set up your Helicone API key in your .env file

Install the Helicone AI SDK provider

Configure Vercel AI SDK with Helicone

Info

You can switch between 100+ models without changing your code. Just update the model name!

Tip

While you're here, why not give us a star on GitHub? It helps us a lot!

Complete Working Examples#

Basic Text Generation#

Streaming Text#

UI Message Stream Response#

Convert streaming results to a UI-compatible response format:

Provider Selection#

By default, Helicone's AI gateway automatically routes to the cheapest provider. You can also manually select a specific provider:

With Custom Properties and Session Tracking#

Tool Calling#

Agents#

Use Vercel AI SDK's Agent API with Helicone to build multi-step reasoning agents:

Helicone Prompts Integration#

Use prompts created in your Helicone dashboard instead of hardcoding messages in your application:

Note

When using promptId, you must still pass a placeholder messages array to satisfy the Vercel AI SDK's validation. The actual prompt content will be fetched from your Helicone dashboard, and the placeholder messages will be ignored.

Benefits of using Helicone prompts:

  • 🎯 Centralized Management: Update prompts without code changes
  • 👩🏻‍💻 Perfect for non-technical users: Create prompts using the Helicone dashboard
  • 🚀 Lower Latency: Single API call, no message construction overhead
  • 🔧 A/B Testing: Test different prompt versions with environments
  • 📊 Better Analytics: Track prompt performance across versions

Additional Examples#

For more comprehensive examples, check out the GitHub repository.

Info

Looking for a framework or tool not listed here? Request it here!

Additional Resources#