ResponsesAgent interface. Register the AI Gateway as an external model to reach 300+ models from inside Databricks, and instrument agents with OpenTelemetry to capture their LLM calls in Orq.ai.
AI Gateway
Serve any Orq.ai model through a Databricks serving endpoint, with cost tracking and fallbacks.
Observability
Export traces from agents running on Model Serving, with prompts, tokens, and cost.
Prerequisites
- An Orq.ai account and API key
- A Databricks workspace with Model Serving enabled
- MLflow 3.11 or later, plus
databricks-sdkanddatabricks-agentsinstalled locally
Store the API key
Both sections below read the key from a Databricks secret. Keep it there rather than in an endpoint configuration, where anyone with view access on the endpoint can read it. Skipcreate_scope if the scope already exists:
AI Gateway
Databricks external models accept any OpenAI-compatible endpoint through thecustom provider, so the AI Gateway can back a Databricks serving endpoint. Set external_model.name to the model to serve, and point custom_provider_url at the AI Gateway:
Any enabled model works. Set
external_model.name to its Orq.ai slug and see supported models. One endpoint serves one model, so create an endpoint per model.Observability
Adding OpenTelemetry to an agent already running on Model Serving sends its LLM calls to Orq.ai, with full request and response content, token usage, and cost. There are four changes: add an exporter at module level, flush at the end ofpredict, declare three extra packages, and pass the endpoint and key at deploy time.
This covers agents deployed from code with
agents.deploy(). Agents created in the no-code Agent Bricks builder run on an endpoint that Databricks manages, which exposes neither environment variables nor model dependencies, so they cannot be instrumented this way.Add the exporter to the agent
Add this at module level in the agent file, above the agent class. It opens the connection to Orq.ai and attaches the instrumentor that records LLM calls.OpenAIInstrumentor records calls made through the OpenAI SDK, which is what WorkspaceClient().serving_endpoints.get_open_ai_client() returns. Agents built on another client library need the matching OpenInference instrumentor in its place, otherwise the agent deploys cleanly and produces no spans:
predict, before returning. Model Serving keeps the container alive between requests, so the flush is what sends spans promptly rather than leaving them queued:
Declare the dependencies
The serving environment installs only the packages declared on the model, so add these to the existingpip_requirements on log_model. Without them the agent fails to import at request time:
Pass the endpoint and key
Add these toenvironment_vars on agents.deploy(). OTEL_SERVICE_NAME is optional and sets the name used to filter traces later:
Configuring OTLP through the standard
OTEL_EXPORTER_OTLP_* variables alone does not export traces from Model Serving. The managed runtime sets up its own MLflow tracing, which takes precedence, and spans reach the Databricks experiment rather than Orq.ai. Add the exporter to the agent as shown above instead.View traces
Traces appear in AI Studio under the Traces tab. Each LLM call arrives as a span carrying the request and response messages, prompt and completion tokens, the resolved model and provider, and computed cost. Filter on the value set inOTEL_SERVICE_NAME to isolate one agent.
Complete example
This example calls a Databricks native endpoint. To route the agent through the AI Gateway instead, setLLM_ENDPOINT to the endpoint created above.
Full agent module and deployment script
Full agent module and deployment script
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 agents and compare results.
Run Experiments via the API
Compare agent configurations and view results in the AI Studio.