Skip to main content

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)

Metadata

Release files for traceAI-portkey 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traceAI-portkey 0.1.3
File Size Uploaded Provenance Actions
traceai_portkey-0.1.3.tar.gz 6.9 kB With provenance Details for traceai_portkey-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for traceAI-portkey 0.1.3
File Interpreter ABI Platform Actions
traceai_portkey-0.1.3-py3-none-any.whl Python 3 none any Details for traceai_portkey-0.1.3-py3-none-any.whl

Total release size: 16.2 kB

Release files / traceai_portkey-0.1.3.tar.gz

Download URL traceai_portkey-0.1.3.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1684451393628b1ff2a2f8e46a30b6b977d30e3185a9132d7b28cb27b872c983
BLAKE2b-256 checksum
How to use checksums
02e371e922aa1300020416e7b1674271d47e8e23f2be475caf67191eb42d15c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / traceai_portkey-0.1.3-py3-none-any.whl

Download URL traceai_portkey-0.1.3-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
090377b42dfe4da13f64bcea2df8874518e1ac3bf476a0b498f8f12e0f158d00
BLAKE2b-256 checksum
How to use checksums
6b7ee4771a7f3faa9fffbd8514eb0741569701ea9d1dfda65e5e94cfb1348a3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for traceAI-portkey 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for traceai_portkey-0.1.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page