track_anthropic

opik.integrations.anthropic.track_anthropic(anthropic_client: AnthropicClient, project_name: str | None = None) AnthropicClient

Adds Opik tracking to an Anthropic client.

Integrates with the following anthropic library objects:
  • AsyncAnthropic,

  • Anthropic,

  • AsyncAnthropicBedrock,

  • AnthropicBedrock,

  • AsyncAnthropicVertex,

  • AnthropicVertex,

Supported methods (for all classes above) are:
  • client.messages.create()

  • client.messages.stream()

Can be used within other Opik-tracked functions.

Parameters:
  • anthropic_client – An instance of Anthropic client.

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

Returns:

Anthropic client with integrated Opik tracking logic.