TraceAI MiniMax Instrumentation
OpenTelemetry instrumentation for MiniMax - chat completions via the OpenAI-compatible API.
Installation
pip install traceai-minimax
Features
- Automatic tracing of MiniMax API calls via OpenAI SDK
- Support for MiniMax-M2.7, MiniMax-M2.7-highspeed, MiniMax-M2.5, and MiniMax-M2.5-highspeed models
- Streaming response support
- Token usage tracking
- Function/tool calling support
- Full OpenTelemetry semantic conventions compliance
Usage
Basic Setup
from openai import OpenAI
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
from traceai_minimax import MiniMaxInstrumentor
# Set up tracing
provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))
trace.set_tracer_provider(provider)
# Instrument MiniMax
MiniMaxInstrumentor().instrument(tracer_provider=provider)
# Use MiniMax via OpenAI SDK
client = OpenAI(
api_key="your-minimax-api-key",
base_url="https://api.minimax.io/v1"
)
response = client.chat.completions.create(
model="MiniMax-M2.7",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
MiniMax Chat
from openai import OpenAI
client = OpenAI(
api_key="your-minimax-api-key",
base_url="https://api.minimax.io/v1"
)
# Simple chat
response = client.chat.completions.create(
model="MiniMax-M2.7",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is machine learning?"}
],
temperature=0.7,
max_tokens=1024
)
print(response.choices[0].message.content)
Streaming Responses
from openai import OpenAI
client = OpenAI(
api_key="your-minimax-api-key",
base_url="https://api.minimax.io/v1"
)
# Streaming chat
stream = client.chat.completions.create(
model="MiniMax-M2.7",
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
print()
Function Calling / Tools
from openai import OpenAI
import json
client = OpenAI(
api_key="your-minimax-api-key",
base_url="https://api.minimax.io/v1"
)
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city name"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "Temperature unit"
}
},
"required": ["location"]
}
}
}
]
response = client.chat.completions.create(
model="MiniMax-M2.7",
messages=[{"role": "user", "content": "What's the weather in Paris?"}],
tools=tools,
tool_choice="auto"
)
message = response.choices[0].message
if message.tool_calls:
for tool_call in message.tool_calls:
print(f"Function: {tool_call.function.name}")
print(f"Arguments: {tool_call.function.arguments}")
Async Usage
import asyncio
from openai import AsyncOpenAI
async def main():
client = AsyncOpenAI(
api_key="your-minimax-api-key",
base_url="https://api.minimax.io/v1"
)
response = await client.chat.completions.create(
model="MiniMax-M2.7",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
asyncio.run(main())
JSON Mode
from openai import OpenAI
client = OpenAI(
api_key="your-minimax-api-key",
base_url="https://api.minimax.io/v1"
)
response = client.chat.completions.create(
model="MiniMax-M2.7",
messages=[
{"role": "system", "content": "Output valid JSON only."},
{"role": "user", "content": "List 3 programming languages with their main use cases"}
],
response_format={"type": "json_object"}
)
import json
data = json.loads(response.choices[0].message.content)
print(data)
Configuration Options
TraceConfig
from fi_instrumentation import TraceConfig
from traceai_minimax import MiniMaxInstrumentor
config = TraceConfig(
hide_inputs=False,
hide_outputs=False,
)
MiniMaxInstrumentor().instrument(
tracer_provider=provider,
config=config
)
Captured Attributes
Common Attributes
| Attribute | Description |
|---|---|
gen_ai.span.kind |
"LLM" |
gen_ai.provider.name |
"minimax" |
gen_ai.request.model |
Model name (MiniMax-M2.7, MiniMax-M2.7-highspeed, MiniMax-M2.5, MiniMax-M2.5-highspeed) |
gen_ai.usage.input_tokens |
Input token count |
gen_ai.usage.output_tokens |
Output token count |
gen_ai.usage.total_tokens |
Total token count |
MiniMax-Specific Attributes
| Attribute | Description |
|---|---|
minimax.response_id |
Unique response ID |
minimax.finish_reason |
Response finish reason (stop, tool_calls, length) |
minimax.tool_calls_count |
Number of tool calls |
minimax.tools_count |
Number of tools provided |
Available Models
| Model | Description |
|---|---|
MiniMax-M2.7 |
Latest flagship model with enhanced reasoning and coding |
MiniMax-M2.7-highspeed |
High-speed version of M2.7 for low-latency scenarios |
MiniMax-M2.5 |
General-purpose model with 204K context window |
MiniMax-M2.5-highspeed |
Faster inference variant with 204K context window |
Important Notes
-
OpenAI SDK Required: MiniMax uses the OpenAI-compatible API, so you need the
openaipackage installed. -
Base URL: Always set
base_url="https://api.minimax.io/v1"when creating the client. -
API Key: Get your API key from the MiniMax Platform.
-
Selective Instrumentation: The instrumentor only traces calls to MiniMax's API. Regular OpenAI API calls are not affected.
-
Temperature: MiniMax requires temperature to be in the range (0.0, 1.0]. A value of exactly 0 is not accepted.
License
Apache-2.0
Metadata
Release files for traceAI-minimax 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| traceai_minimax-0.1.1.tar.gz | 11.0 kB | Without provenance | Details for traceai_minimax-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| traceai_minimax-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for traceai_minimax-0.1.1-py3-none-any.whl |
Total release size: 23.2 kB
Release files / traceai_minimax-0.1.1.tar.gz
| Download URL | traceai_minimax-0.1.1.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f7b09068ad44d627dbbc345a2727331f5a4824704de9e50ea0d8e5e0cbc6093
|
|
BLAKE2b-256 checksum How to use checksums |
22d384d340ed37d9ccddd45707e8995fa4c6c5dddd0e1986f46eb7e9226e9978
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / traceai_minimax-0.1.1-py3-none-any.whl
| Download URL | traceai_minimax-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d87cf4d322a067c81aa5bbe92a1053d943e42d9d279847b7e0c1cf1ce33716d4
|
|
BLAKE2b-256 checksum How to use checksums |
8ab51c4d3a7a650e5db88ae8aa800031213c7057ed9439584527a0067b0203fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for traceAI-minimax 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.