minimax

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package minimax provides a MiniMax LLM provider using the Anthropic-compatible API. MiniMax recommends their Anthropic-compatible endpoint for new integrations. Docs: https://platform.minimax.io/docs/api-reference/text-anthropic-api

Index

Constants

View Source
const (
	ModelM27          = "MiniMax-M2.7"
	ModelM27Highspeed = "MiniMax-M2.7-highspeed"
	ModelM25          = "MiniMax-M2.5"
	ModelM25Highspeed = "MiniMax-M2.5-highspeed"
	ModelM21          = "MiniMax-M2.1"
	ModelM21Highspeed = "MiniMax-M2.1-highspeed"
	ModelM2           = "MiniMax-M2"
)

Model ToolCallID constants for programmatic use.

Variables

View Source
var ModelAliases = map[string]string{
	"minimax":      ModelM27,
	"minimax:fast": ModelM27,
	"minimax:2.7":  ModelM27,
	"minimax:2.5":  ModelM25,
	"minimax:2.1":  ModelM21,
	"minimax:2":    ModelM2,
}

ModelAliases maps short alias names to full model IDs. Used by the auto package for provider-prefixed resolution (e.g., "minimax/fast").

Functions

func DefaultOptions

func DefaultOptions() []llm.Option

DefaultOptions returns the default options for MiniMax.

func FillCost

func FillCost(model string, usage *llm.Usage)

FillCost calculates cost for the given usage and model and populates usage cost fields. Handles input, output, cache read, and cache write token costs. InputCost is calculated only for non-cache tokens (total input minus cache reads/writes).

Types

type Option

type Option func(*Provider)

Option is a functional option for configuring the MiniMax provider.

func WithLLMOpts

func WithLLMOpts(llmOpts ...llm.Option) Option

WithLLMOpts adds custom llm.Option configurations.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider implements the MiniMax LLM backend via the Anthropic-compatible API.

func New

func New(opts ...Option) *Provider

New creates a new MiniMax provider.

func (*Provider) CountTokens added in v0.26.0

func (p *Provider) CountTokens(_ context.Context, req llm.TokenCountRequest) (*llm.TokenCount, error)

CountTokens estimates the number of input tokens for the given request using the MiniMax BPE tokenizer (200K vocab, loaded from HuggingFace on first use).

The estimate accounts for:

  • Raw BPE token counts per message and tool definition
  • Per-message framing overhead (6 tokens/message)
  • Hidden default system prompt (35 tokens) when no system message is provided
  • Tool schema framing (116 tokens once + 20 tokens per additional tool)

All constants are empirically calibrated against the MiniMax-M2.7 API.

func (*Provider) CreateStream

func (p *Provider) CreateStream(ctx context.Context, opts llm.Request) (llm.Stream, error)

func (*Provider) Models

func (p *Provider) Models() []llm.Model

func (*Provider) Name

func (p *Provider) Name() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL