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.0.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.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceai_portkey-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.2 Darwin/24.5.0

File hashes

Hashes for traceai_portkey-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4a0be75f7630488dbc3d8bc339a07dbb3c096988b98732391d8c157490736c45
MD5 07439b3f887ede0f28cdbd00c3231265
BLAKE2b-256 b3e357fc69c05eec94445580f53e1fbdf48bcc1462fa00726440c3abb9b1eca3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceai_portkey-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.2 Darwin/24.5.0

File hashes

Hashes for traceai_portkey-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6486af1f3a76e29c598c22e7d50a004ba7a7567f472e75ad7533e10904836a3d
MD5 dfdf2848cf2fe20bae2cd111dc9f6020
BLAKE2b-256 ac5f7fadfff9f33d0fcd297280d1ec22876b782dac1e2f94689c7cdc2fb3916d

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