chat.completions.create calls and
publish them to Openlayer.
Evaluating Portkey completions
You can set up Openlayer tests to evaluate your Portkey completions in monitoring. Instrument your code so each request is traced and published to the platform. Install the Portkey SDK alongside Openlayer:Auto-instrumentation with init()
init() auto-instruments installed LLM SDKs, including Portkey when the portkey_ai
package is present (registry name "portkey"). Call it before you create a Portkey
client:
Manual trace_portkey()
If you prefer not to auto-instrument every installed SDK, call trace_portkey()
before you use Portkey. Tracing then happens automatically on
chat.completions.create:
OPENLAYER_API_KEY and OPENLAYER_INFERENCE_PIPELINE_ID in the
environment.
The optional inference_id kwarg is popped before the request is sent to Portkey.
What is captured
Openlayer records streaming and non-streamingchat.completions.create calls. For
each Portkey Chat Completion step, the tracer captures:
start_timeend_timelatencytokensprompt_tokenscompletion_tokensmodelmodel_parametersraw_outputinputs- Portkey-specific metadata (base URL,
x-portkey-*headers if available)