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 →
Use this file to discover all available pages before exploring further.
AI Router
Route your LLM calls through the AI Router 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.
The OpenAI SDK provides powerful tools for building AI applications with GPT models. By connecting the SDK to Orq.ai’s AI Router, you transform your OpenAI integration into a production-ready system with enterprise-grade capabilities, complete observability, and access to 300+ models across 20+ providers.
While using the OpenAI SDK, set the Base URL to the AI Router to feed calls through our API without changing any other part of your code.Using the Orq.ai AI Router, you benefit from Platform Traces and Cost and Usage Monitoring, keeping full compatibility and a unified API with all models while using the OpenAI SDK.
from openai import OpenAIimport osclient = OpenAI( base_url="https://api.orq.ai/v3/router", api_key=os.getenv("ORQ_API_KEY"),)stream = client.chat.completions.create( model="openai/gpt-4o", messages=[ {"role": "user", "content": "Write a short story about robots."} ], stream=True)for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="", flush=True)
Integrate OpenAI SDK with Orq.ai’s observability to gain complete insights into model performance, token usage, API latency, and conversation flows using OpenTelemetry.
response = client.chat.completions.create( model="openai/gpt-4o", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is quantum computing in one sentence?"} ])print(response.choices[0].message.content)
from opentelemetry import tracetracer = trace.get_tracer(__name__)def analyze_document(document: str): with tracer.start_as_current_span("document-analysis") as span: span.set_attribute("document.length", len(document)) # Prepare prompt prompt = f"Analyze this text: {document}" with tracer.start_as_current_span("prepare-prompt") as prep_span: prep_span.set_attribute("prompt.length", len(prompt)) # Model inference with tracer.start_as_current_span("model-inference") as inf_span: inf_span.set_attribute("model", "gpt-4o") response = client.chat.completions.create( model="openai/gpt-4o", messages=[{"role": "user", "content": prompt}] ) inf_span.set_attribute("tokens.total", response.usage.total_tokens) # Process result with tracer.start_as_current_span("process-result") as proc_span: result = response.choices[0].message.content proc_span.set_attribute("result.length", len(result)) return resultanalysis = analyze_document("Machine learning is a subset of AI.")print(analysis)