AI Gateway
Route agent model 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 the workload.
Observability
Export the traces and logs Workers emit to Orq.ai over OpenTelemetry, straight from the Workers runtime.
AI Gateway
Overview
Cloudflare Agents run on Workers and Durable Objects, and call models through the AI SDK. Pointing that provider at Orq.ai’s AI Gateway sends every model call that uses it through the gateway, so routing, fallbacks, and cost tracking apply to those calls. Calls that read the Workers AI binding directly keep going to Cloudflare.Key Benefits
Connecting Cloudflare Agents to Orq.ai’s AI Gateway adds:Complete Observability
Track model calls and their token usage with detailed traces and analytics
Built-in Reliability
Automatic fallbacks, retries, and load balancing for production resilience
Cost Optimization
Real-time cost tracking and spend management across every AI operation
Multi-Provider Access
Access 500+ LLMs and 30+ providers through a single, unified integration
Prerequisites
Before integrating Cloudflare Agents with Orq.ai, confirm:- An Orq.ai account and API Key
- A Cloudflare account with a Worker created from the Cloudflare Agents starter
wranglerinstalled and authenticated
Installation
Install the Agents SDK and the AI SDK with the OpenAI-compatible provider:Configure the Gateway
Create the provider once and pass it the gateway base URL.this.env carries the secret stored above:
TypeScript
baseURL: https://my.orq.ai/v3/router
Basic Agent Example
Every model call in anAgent subclass goes through the gateway with that provider:
TypeScript
AIChatAgent takes the same provider in onChatMessage:
TypeScript
Model Selection
With Orq.ai, use any supported model from 30+ providers by changing the model id:TypeScript
Observability
Getting Started
Cloudflare exports Workers telemetry to any OpenTelemetry-compliant destination, and Orq.ai is one of them, so traces and logs arrive from the Workers runtime itself.Create the destination
Cloudflare keeps destinations at the account level, so the same destination serves every Worker in the account.- In the Cloudflare dashboard, open Observability > Destinations and select Add destination.
- Name the destination, for example
orq-traces, and set Destination type to Traces. - Set OTLP endpoint to
https://my.orq.ai/v2/otel/v1/traces. - Add an Authorization entry under Custom headers with the value
Bearer <ORQ_API_KEY>. - Save, then repeat with the name
orq-logs, the type Logs, and the endpointhttps://my.orq.ai/v2/otel/v1/logs.
Reference the destination in Wrangler
Name the destinations in the Worker configuration, then redeploy:wrangler.jsonc
- Sample rate:
head_sampling_rateis the share of requests exported, from0to1. Lower it on high-volume Workers. - Persist:
persistkeeps a copy in Cloudflare as well. Persisted traces and logs count toward Cloudflare Observability usage from 1 December 2026, so the value above exports to Orq.ai alone.
View Traces
Open Traces for the path each request takes through the Worker and its connected services, and Logs for theconsole.log output the Worker emits. Model calls are recorded by the gateway, so they appear in the trace of the request that made them.
Traces
See each request through the Worker and the services it calls.
Logs
Search the
console.log output a Worker emits during a run.Evaluations & Experiments
Once 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 a set of agents and compare results.
Run Experiments via the API
Compare agent configurations and view results in the AI Studio.