Observability for MiniMax with Opik

MiniMax provides OpenAI-compatible and Anthropic-compatible APIs for its language models. Opik can trace either protocol by wrapping the corresponding Python SDK client.

Install the dependencies

Install Opik and the SDK for the protocol you plan to use:

$pip install opik openai anthropic

Configure Opik for your deployment:

$opik configure

Set your MiniMax API key:

$export MINIMAX_API_KEY="<MINIMAX_API_KEY>"

Choose an endpoint

Use the endpoint for your account region and SDK protocol:

RegionOpenAI-compatible base URLAnthropic-compatible base URL
Globalhttps://api.minimax.io/v1https://api.minimax.io/anthropic
Chinahttps://api.minimaxi.com/v1https://api.minimaxi.com/anthropic

You can find additional API details in the global MiniMax documentation or the China MiniMax documentation.

Track OpenAI-compatible calls

Wrap the OpenAI client with track_openai and pass the MiniMax base URL:

1import os
2
3from openai import OpenAI
4from opik.integrations.openai import track_openai
5
6client = OpenAI(
7 api_key=os.environ["MINIMAX_API_KEY"],
8 base_url="https://api.minimax.io/v1",
9)
10client = track_openai(client, project_name="minimax-demo")
11
12response = client.chat.completions.create(
13 model="MiniMax-M3",
14 messages=[{"role": "user", "content": "Explain observability in one sentence."}],
15)
16
17print(response.choices[0].message.content)

For a China account, change base_url to https://api.minimaxi.com/v1.

Track Anthropic-compatible calls

Wrap the Anthropic client with track_anthropic and pass the MiniMax base URL:

1import os
2
3import anthropic
4from opik.integrations.anthropic import track_anthropic
5
6client = anthropic.Anthropic(
7 api_key=os.environ["MINIMAX_API_KEY"],
8 base_url="https://api.minimax.io/anthropic",
9)
10client = track_anthropic(client, project_name="minimax-demo")
11
12response = client.messages.create(
13 model="MiniMax-M3",
14 max_tokens=512,
15 messages=[{"role": "user", "content": "Explain observability in one sentence."}],
16)
17
18print(response.content[0].text)

For a China account, change base_url to https://api.minimaxi.com/anthropic.

Model identifiers

Use the model identifier exposed by your MiniMax account. Current text model identifiers include:

  • MiniMax-M3
  • MiniMax-M2.7

The wrapped clients preserve the normal SDK response objects while Opik records the request, response, token usage, and model metadata.