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_aitraceai_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
Release history Release notifications | RSS feed
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.2.tar.gz
(5.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file traceai_portkey-0.1.2.tar.gz.
File metadata
- Download URL: traceai_portkey-0.1.2.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73d7b68b7276c076b4383fc02d39fccd5981a9823e998a7f6079aa7ba997fa71
|
|
| MD5 |
bdc6dcb7215fa97f268e08b1e7ed2eca
|
|
| BLAKE2b-256 |
d356c830e11cf906e08afee97e83490d213d3c87b39511916250d9447d7f7428
|
File details
Details for the file traceai_portkey-0.1.2-py3-none-any.whl.
File metadata
- Download URL: traceai_portkey-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
187631b46d7dd3163464bcb1283064880a4392285e2b24ee3c77c75d33ca480c
|
|
| MD5 |
84b4b7961540df606c93989bc1451625
|
|
| BLAKE2b-256 |
da4e50310e8615195e99d1698f47574d31fb53e280d8f8396e75f73b3902975d
|