{"library":"openinference-instrumentation-portkey","title":"OpenInference Portkey AI Instrumentation","description":"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.","language":"python","status":"active","last_verified":"Fri May 01","install":{"commands":["pip install openinference-instrumentation-portkey"],"cli":null},"imports":["from openinference_instrumentation_portkey import PortkeyInstrumentor"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom openinference_instrumentation_portkey import PortkeyInstrumentor\nfrom opentelemetry import trace as trace_api\n\n# Set up a TracerProvider (e.g., ConsoleSpanExporter for debugging)\nfrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import SimpleSpanProcessor\n\ntrace_provider = TracerProvider()\ntrace_provider.add_span_processor(\n    SimpleSpanProcessor(OTLPSpanExporter(endpoint=os.environ.get(\"OTEL_ENDPOINT\", \"http://localhost:4318/v1/traces\")))\n)\ntrace_api.set_tracer_provider(trace_provider)\n\n# Instrument Portkey\nPortkeyInstrumentor().instrument()\n\n# Now use Portkey normally - calls will be traced\nfrom portkey_ai import Portkey\n\nclient = Portkey(api_key=os.environ.get(\"PORTKEY_API_KEY\", \"\"))\nresponse = client.completions.create(prompt=\"Hello\", model=\"gpt-3.5-turbo\")\nprint(response.choices[0].text)\n","lang":"python","description":"Initialize tracing by setting up an OpenTelemetry TracerProvider and calling PortkeyInstrumentor().instrument() before any Portkey usage.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}