Orq MCP is live: Use natural language to interrogate traces, spot regressions, and experiment your way to optimal AI configurations. Available in Claude Desktop, Claude Code, Cursor, and more. Start now →
Open Organization > API Keys in the AI Studio. Click Create API Key, give it a name, and copy it.Then open a terminal and run the command below, replacing your-api-key-here with the copied key. The code samples in the next steps read it from this environment variable.
Create an instrumentation.js file at the root of your project:
TypeScript
// instrumentation.jsimport { registerOTel, OTLPHttpJsonTraceExporter } from '@vercel/otel';export function register() { registerOTel({ serviceName: 'your-project-name', traceExporter: new OTLPHttpJsonTraceExporter({ url: 'https://my.orq.ai/v2/otel/v1/traces', headers: { 'Authorization': `Bearer ${process.env.ORQ_API_KEY}`, }, }), });}
Then enable telemetry on each generation call:
TypeScript
// index.jsimport { register } from './instrumentation.js';import { generateText } from "ai";import { openai } from "@ai-sdk/openai";register();const result = await generateText({ model: openai("gpt-4.1"), prompt: "Write a short story about a robot", experimental_telemetry: { isEnabled: true, },});
Configure logfire and instrument Pydantic AI before running the agent:
Python
import logfirefrom pydantic_ai import Agentlogfire.configure( service_name='orq-traces', send_to_logfire=False, metrics=False,)logfire.instrument_pydantic_ai()agent = Agent('openai:gpt-4o-mini')result = agent.run_sync('What is the capital of France?')print(result.output)
from opentelemetry.sdk.trace import TracerProviderfrom opentelemetry.sdk.trace.export import BatchSpanProcessorfrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporterfrom orq_ai_sdk.openai_agents_instrumentation import OpenAIAgentsInstrumentorfrom agents import Agent, Runner# Set up OpenTelemetrytracer_provider = TracerProvider()tracer_provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))# Instrument OpenAI agents with Orq.aiOpenAIAgentsInstrumentor().instrument(tracer_provider=tracer_provider)agent = Agent(name="Assistant", instructions="You are a helpful assistant")result = Runner.run_sync(agent, "Write a haiku about recursion in programming.")print(result.final_output)
All subsequent Runner.run_sync() / Runner.run() calls are automatically traced.
Using a different framework? orq.ai supports observability for LangChain, LiteLLM, CrewAI, AWS Strands, Mastra, and more.See the Frameworks overview for the full list and setup guides.
Run the agent and open Traces in the AI Studio. Every request will appear with model, latency, token counts, and cost. For agentic frameworks, individual tool calls and steps appear as child spans.