Integrations
Opik
Trace Drex decision requests in Opik by wrapping the TypeSafe client, with the model and token usage on each span.
Opik traces LLM calls. Its TypeSafe integration, track_typesafe, wraps the typesafe-sdk client, and Drex answers that client's requests, so wrapping a client that points at Drex traces Drex calls. See Questions and Reading answers.
Verified with opik 2.2.137 and typesafe-sdk 0.7.5 against https://console.nace.ai: the wrapped call succeeds, and the span Opik builds names the model drex-max and carries the token usage Drex reported. The span was read from the client's outgoing message queue. Nothing was sent to an Opik backend, Comet's cloud or a self-hosted server, so what the Opik UI shows is not verified.
Setup
pip install opik typesafe-sdk
export TYPESAFE_API_KEY=nace_sk_...Create the key as shown in Authentication. Set TYPESAFE_BASE_URL to https://console.nace.ai (the host, without /v1); the sample reads it. For Drex on your own infrastructure, use that deployment's URL. Configure Opik itself as its documentation describes.
Trace a request
Set the model on every call. The SDK's default model, jev-latest, is refused by Drex with a 422 (unknown model).
import os
from typesafe_sdk import Noul, TypeSafeClient
from opik.integrations.typesafe import track_typesafe
client = track_typesafe(
TypeSafeClient(
api_key=os.environ["TYPESAFE_API_KEY"],
base_url=os.environ["TYPESAFE_BASE_URL"],
timeout=60,
),
project_name="drex-evals",
)
result = client.system_one(
"I was charged twice and want a refund.",
{"refund": Noul(instructions="Is the customer asking for a refund?")},
model="drex-max",
)
result.answers["refund"].noul # probability of yestimeout=60 is in seconds: the SDK's default of 10 seconds is shorter than Drex can take on a large request. See Migrate from TypeSafe. The async client, AsyncTypeSafeClient, works the same way against Drex; it was not checked with track_typesafe.
What works and what doesn't
noulandchoicequestions, and the modelsdrex-max,drex-v2.0anddrex-max-v1.1, worked through the SDK. List the model ids you can send withGET /v1/models; see Models.boxquestions aren't supported by Drex, which answers422and says so.- A
scorequestion has not been tried through Opik. Drex used to return itslegendas a list of level labels, whichtypesafe-sdk0.7.5 rejects when used directly (it validates an object keyed by level), and Opik wraps that client. Drex now sends the TypeSafe SDK an object keyed by level, recognized by itsX-TypeSafe-SDKheader, andX-Nace-Legend: arrayorobjectoverrides it; see Reading answers. That is available once the change is deployed. An objectlegendvalidates against the realtypesafe-sdkScoreAnswermodel offline, but a livescorecall through Opik against a deployment has not been run yet. Until you have tested one, ask score questions with the Python or TypeScript Nace SDK, or over HTTP.
Drex enforces its own request limits; see Limits. A failed request raises the SDK's error, never a low score; see Errors and retries.