Registry / llm-agents / openinference-instrumentation-portkey

openinference-instrumentation-portkey

JSON →
library0.1.11pypypi✓ verified 79d ago

OpenInference instrumentation for Portkey AI gateway, enabling tracing of LLM calls made via Portkey. Version 0.1.8 supports Python 3.10-3.14. Part of the Arize AI OpenInference ecosystem for observability of AI applications.

pip install openinference-instrumentation-portkey
INSTALL
IMPORT
SIG · OPENINFERENCE-INST
O
openinference-instrumentation-portkey
llm-agentspythonv0.1.11
Install
2.8s avg
Import
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.11 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 24.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.8s · import 0.000s · 25MB
23MB installed
● package 23MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PortkeyInstrumentor
from openinference.instrumentation.portkey import PortkeyInstrumentor
from openinference_instrumentation_portkey import PortkeyInstrumentor

Initialize tracing by setting up an OpenTelemetry TracerProvider and calling PortkeyInstrumentor().instrument() before any Portkey usage.

import os from openinference_instrumentation_portkey import PortkeyInstrumentor from opentelemetry import trace as trace_api # Set up a TracerProvider (e.g., ConsoleSpanExporter for debugging) from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import SimpleSpanProcessor trace_provider = TracerProvider() trace_provider.add_span_processor( SimpleSpanProcessor(OTLPSpanExporter(endpoint=os.environ.get("OTEL_ENDPOINT", "http://localhost:4318/v1/traces"))) ) trace_api.set_tracer_provider(trace_provider) # Instrument Portkey PortkeyInstrumentor().instrument() # Now use Portkey normally - calls will be traced from portkey_ai import Portkey client = Portkey(api_key=os.environ.get("PORTKEY_API_KEY", "")) response = client.completions.create(prompt="Hello", model="gpt-3.5-turbo") print(response.choices[0].text)
Debug
Known issues
gotchaInstrumentation must be called before any Portkey client is created. If you import or instantiate Portkey before calling .instrument(), traces will not be captured.
fix
Ensure the .instrument() call happens at module-level before any Portkey usage, ideally right after setting up OpenTelemetry.
affects: all
gotchaIf no TracerProvider is set, instrumentation silently fails (no spans emitted). Ensure opentelemetry-api and a TracerProvider (e.g., from opentelemetry-sdk) are configured.
fix
Set a global tracer provider via trace_api.set_tracer_provider(TracerProvider()) and add a span processor with an exporter.
affects: all
gotchaThis package requires wrapt. If you have an older version of wrapt or wrapt is missing, you may see import errors. Versions >=1.14 are recommended.
fix
Install or upgrade wrapt: pip install 'wrapt>=1.14'
affects: all
Upgrade
Version history
0.1.11latest on PyPI · released May 18, 2026
Audit
Dependencies
openinference-instrumentationrequiredBase OpenInference instrumentation package providing core tracing APIs
portkey-airequiredPortkey AI client SDK - the instrumented library
opentelemetry-apirequiredOpenTelemetry API for creating spans and traces
wraptrequiredUsed for monkey-patching Portkey methods (compatible with wrapt 2.x)
Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
3
Resources
openinference-instrumentation-portkey — pip install openinference-instrumentation-portkey · libregistry