track_openai

opik.integrations.openai.track_openai(openai_client: OpenAI | AsyncOpenAI, project_name: str | None = None) OpenAI | AsyncOpenAI

Adds Opik tracking to an OpenAI client.

Tracks calls to: * openai_client.chat.completions.create(), including support for stream=True mode. * openai_client.beta.chat.completions.parse() * openai_client.beta.chat.completions.stream()

Can be used within other Opik-tracked functions.

Parameters:
  • openai_client – An instance of OpenAI or AsyncOpenAI client.

  • project_name – The name of the project to log data.

Returns:

The modified OpenAI client with Opik tracking enabled.