Musterby Elitery
Integrations

Portkey

Trace LLM calls routed through the Portkey AI Gateway in Muster.

Portkey is an AI gateway that routes calls across 250+ LLM providers with reliability, caching, and cost controls. Trace its calls in Muster via the Muster OpenAI wrapper pointed at Portkey's gateway URL.

Setup

%pip install openai langfuse portkey_ai
import os

os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-..."
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-..."
os.environ["LANGFUSE_BASE_URL"] = "https://app.getmuster.io"
from langfuse.openai import OpenAI
from portkey_ai import createHeaders, PORTKEY_GATEWAY_URL

client = OpenAI(
    api_key="xxx",  # Portkey accepts this header but ignores it
    base_url=PORTKEY_GATEWAY_URL,
    default_headers=createHeaders(
        api_key="<PORTKEY_API_KEY>",
        virtual_key="<PORTKEY_VIRTUAL_KEY>",
    ),
)

Example

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Your prompt"}],
)

from langfuse import get_client
get_client().flush()

See also