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.4

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.4
File Size Uploaded Provenance Actions
traceai_portkey-0.1.4.tar.gz 6.9 kB With provenance Details for traceai_portkey-0.1.4.tar.gz

Built distribution (wheel)

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

Total release size: 16.2 kB

Release files / traceai_portkey-0.1.4.tar.gz

Download URL traceai_portkey-0.1.4.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
421349c461195e03bcc8eefe1bd4c1cd2f9290971fe3ca9687603de6df15d14e
BLAKE2b-256 checksum
How to use checksums
1aa3ad4d88f6498c495e041f2fb4c349e9152dd6e35f1b005403336f21f8288a
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 Nov 12, 2026.

Transparency log

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

Download URL traceai_portkey-0.1.4-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25be880c55cea8f500068c8cbc9560eda628e50928fa732915c9279ef62aefd7
BLAKE2b-256 checksum
How to use checksums
1789b2eb8408e2f6e29b80d4e256f576805a123cd28aec0576ff803c81325d62
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 Nov 12, 2026.

Transparency log

Security for traceAI-portkey 0.1.4

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.4.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 Nov 12, 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