Skip to main content

AI Gateway

Route your LLM calls through the AI Gateway with a single base URL change. Zero vendor lock-in: always run on the best model at the lowest cost for your use case.

Observability

Instrument your code with OpenTelemetry to capture traces, logs, and metrics for every LLM call, agent step, and tool use.

AI Gateway

Overview

The Vercel AI SDK is a TypeScript toolkit for building AI-powered applications with streaming, structured outputs, and multi-model support. By connecting it to Orq.ai’s AI Gateway via the @orq-ai/vercel-provider, you get access to 300+ models with a single provider setup.

Key Benefits

Orq.ai’s AI Gateway enhances your Vercel AI applications with:

Complete Observability

Track every generation, stream, and structured output with detailed traces

Built-in Reliability

Automatic fallbacks, retries, and load balancing for production resilience

Cost Optimization

Real-time cost tracking and spend management across all your AI operations

Multi-Provider Access

Access 300+ LLMs and 20+ providers through a single, unified integration

Prerequisites

Before integrating Vercel AI with Orq.ai, ensure you have:
  • An Orq.ai account and API Key
  • Node.js 18 or higher
To setup your API key, see API keys & Endpoints.

Installation

Configuration

Configure the Orq.ai provider with your API key:
TypeScript
base_url: https://api.orq.ai/v3/router

Text Generation

TypeScript

Streaming Responses

TypeScript

Structured Output

Use a JSON system prompt and parse the response:
TypeScript

Model Selection

With Orq.ai, you can use any supported model from 20+ providers:
TypeScript

Observability

Getting Started

The Vercel AI SDK provides powerful React hooks and utilities for building AI-powered applications with built-in OpenTelemetry support. The SDK includes experimental telemetry features that automatically capture detailed traces of AI operations, making integration with Orq.ai straightforward for comprehensive observability.

Prerequisites

Before you begin, ensure you have:
  • An Orq.ai account and an API Key.
  • Vercel AI SDK v3.1+ (with telemetry support).
  • Node.js 18+ (or Bun 1.3.5+) and TypeScript support.
  • API keys for your LLM providers (OpenAI, Anthropic, etc.).

Install Dependencies

Configure Orq.ai

Set up your environment variables to connect to Orq.ai’s OpenTelemetry collector: Unix/Linux/macOS:
Windows (PowerShell):
Using .env file:

Integrations

The Vercel AI SDK has built-in OpenTelemetry support through the experimental_telemetry option. Here’s how to integrate it with Orq.ai:
The examples in this section call the openai provider from @ai-sdk/openai directly. This routes requests to OpenAI without going through the AI Router. To route through Orq.ai, replace openai with the provider from @orq-ai/vercel-provider as shown in the Text Generation section above.
The simplest way to enable telemetry is using the SDK’s native support:
Here the main factor to enable telemetry is to include the following payload when generating text. This can be used across the board.

Asset Capture in the Control Tower

When you instrument Vercel AI SDK with OpenTelemetry and send traces to Orq.ai, agents, tools, and models are automatically extracted from the spans and registered in Control Tower.

Installation

Configuration

TypeScript

Agent Detection

The example below calls the openai provider from @ai-sdk/openai directly, bypassing the AI Router. Replace openai with the provider from @orq-ai/vercel-provider to route through Orq.ai.
The Vercel AI SDK does not have a built-in way to mark a span as an agent. To capture agents in Control Tower, use manual OpenTelemetry instrumentation with tracer.startActiveSpan(). The span name (e.g., "translator-agent") becomes the agent name in Control Tower. This approach captures tools and models alongside the agent span. Captures: agent/translator-agent, tool/translate, model/gpt-4o
TypeScript

Evaluations & Experiments

Once your agents are running, use Evaluatorq to score outputs across a dataset and Experiments to compare configurations side-by-side.

Run Evaluations with Evaluatorq

Run parallel evaluations across your agents and compare results.

Run Experiments via the API

Compare agent configurations and view results in the AI Studio.