View module source on GitHub

This module is a wrapper around the Portkey client that allows for easy integration with Maxim.

It instruments the Portkey client to log to Maxim.

It also provides a wrapper around the Portkey chat-completions client that allows for easy integration with Maxim.

instrument_portkey

def instrument_portkey(client: PortkeyClient,
                       logger: Logger) -> MaximPortkeyClient

Attach Maxim OpenAI wrappers to a Portkey client.

This helper patches the openai_client attribute of a Portkey or AsyncPortkey instance so that all OpenAI-compatible calls are logged via Maxim.

Arguments:

NameDescription
clientInstance of Portkey or AsyncPortkey client.
loggerMaxim [Logger](/sdk/python/references/logger/logger) instance.

Returns:

The same client instance with its openai_client patched.