Respan instrumentation plugin for Portkey
Project description
respan-instrumentation-portkey
Respan instrumentation plugin for Portkey. Wraps OpenInference's Portkey instrumentor, translates spans into the Respan tracing shape, and strips off-contract helper aliases before export.
Configuration
1. Install
pip install respan-instrumentation-portkey
2. Set Environment Variables
| Variable | Required | Description |
|---|---|---|
RESPAN_API_KEY |
Yes | Your Respan API key for trace export. |
RESPAN_BASE_URL |
No | Defaults to https://api.respan.ai/api. |
PORTKEY_API_KEY |
Yes | Your Portkey API key for Portkey Gateway calls. |
PORTKEY_PROVIDER or PORTKEY_CONFIG |
Yes | Portkey provider slug or config slug. |
Quickstart
import os
from dotenv import load_dotenv
load_dotenv()
from portkey_ai import Portkey
from respan import Respan, workflow
from respan_instrumentation_portkey import PortkeyInstrumentor
respan = Respan(
api_key=os.environ["RESPAN_API_KEY"],
base_url=os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api"),
instrumentations=[PortkeyInstrumentor()],
)
client = Portkey(
api_key=os.environ["PORTKEY_API_KEY"],
provider=os.getenv("PORTKEY_PROVIDER"),
config=os.getenv("PORTKEY_CONFIG"),
)
@workflow(name="portkey_chat_completion")
def run_chat() -> str:
response = client.chat.completions.create(
model=os.getenv("PORTKEY_MODEL", "gpt-4o-mini"),
messages=[{"role": "user", "content": "Say hello from Portkey."}],
)
return response.choices[0].message.content or ""
try:
print(run_chat())
finally:
respan.flush()
respan.shutdown()
Further Reading
See the Respan example projects for runnable scripts.
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
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 respan_instrumentation_portkey-0.1.0.tar.gz.
File metadata
- Download URL: respan_instrumentation_portkey-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.12 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4be14485a8ee23696b2e33ee577d6c537693207481b9a4804bcb0ae7c1130bc3
|
|
| MD5 |
7cbff61eb83c9e9966d4aa0c0ffdacb4
|
|
| BLAKE2b-256 |
85d1e2a846fbdae4b2967d812706a797747e1d2129f6548358d6f74b0e056664
|
File details
Details for the file respan_instrumentation_portkey-0.1.0-py3-none-any.whl.
File metadata
- Download URL: respan_instrumentation_portkey-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.12 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dda4d4cf127a77c43fbe70a6e0369c06c3bbf06db10a1ec9974b6cfa1a462a15
|
|
| MD5 |
513cc0db1de3e156507962ebcab6a3da
|
|
| BLAKE2b-256 |
4408723fa64552ee6c9c4494df25d52c3e7c6735ef3ff109eac131c2909e0843
|