Skip to main content

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

respan_instrumentation_portkey-0.1.1.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

respan_instrumentation_portkey-0.1.1-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file respan_instrumentation_portkey-0.1.1.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_portkey-0.1.1.tar.gz
Algorithm Hash digest
SHA256 02bb14a170b59417e328374db605d07d1fd6302f41d68b9dff91451d3eb247ae
MD5 ff1603d90ba1bcc9dddb07ed164caf52
BLAKE2b-256 9e09f0ce600dcf5368f3c0b7edd45d70621215ec6c1dbc6d4ea78522b1a7ee58

See more details on using hashes here.

File details

Details for the file respan_instrumentation_portkey-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_instrumentation_portkey-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eace0697f8b8cf7e22ba33b700226113161481bdadd97551cb7ef80bf3030206
MD5 e16c6da4e6c83eecd07161a16225b3b5
BLAKE2b-256 2696ed98e10012964b1caadc93924cbcf2bfcf209219eaef102faca094a0d01b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

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