Skip to main content

OpenTelemetry instrumentation for Portkey AI

Project description

TraceAI Portkey Instrumentation

This is a simple example of how to use TraceAI's Portkey Instrumentation.

Requirements

  • portkey_ai
  • traceai_portkey
pip install portkey_ai traceai_portkey 

Register a new project with the auto instrumentor with the Portkey client.

from dotenv import load_dotenv
from portkey_ai import Portkey
from traceai_portkey import PortkeyInstrumentor
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType, EvalTag, EvalTagType, EvalSpanKind, EvalName, ModelChoices

# Load API keys from .env file
load_dotenv()

# --- Configure Future AGI Tracing Once ---
tracer_provider = register(
    project_name="My-AI-App",
    eval_tags=[
        EvalTag(
            type=EvalTagType.OBSERVATION_SPAN,
            value=EvalSpanKind.LLM,
            eval_name=EvalName.CONTEXT_ADHERENCE,
            custom_eval_name="Response_Quality"
        )
    ]
)

# Instrument the Portkey client
PortkeyInstrumentor().instrument(tracer_provider=tracer_provider)


# --- Your application logic remains the same! ---
client = Portkey(virtual_key="your-portkey-virtual-key")

completion = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Write a 6-word story about a robot who discovers music."}]
)

print(completion.choices[0].message.content)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

traceai_portkey-0.1.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

traceai_portkey-0.1.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file traceai_portkey-0.1.1.tar.gz.

File metadata

  • Download URL: traceai_portkey-0.1.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_portkey-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bddef94edbb61f3f4f8fa176ff434db21ff37b75ced211de33d702ba9a7a44a4
MD5 239fd4cb1fc7bf2d2ad58747b0346ae8
BLAKE2b-256 cc4bd387e70eb28dbb44cf301a4e5cd64528696274e0df1d0be0af408de46a6f

See more details on using hashes here.

File details

Details for the file traceai_portkey-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: traceai_portkey-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_portkey-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e054d7b087a89eb53b44afd3fd3589e9f3d6f12be288380deb0cb0cd424e90a
MD5 9e891d526716adfa09c04315554f2fb6
BLAKE2b-256 6e2dfc8633e1daf96a8df797013e976583ae7f32f5a3ca2191cc7ff09aa3b491

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page