Skill: Minimax OpenAI-Compatible Provider
Purpose
Use MiniMax as the default language model provider through a standardized OpenAI-compatible adapter, completely decoupling business logic from the specific LLM API implementation.
When to Use
- Implementing Topic Ranking, Draft Generation, or Guardian risk assessment.
- Setting up the central LLM invocation framework in
src/adapters/model/.
Required Inputs
- Expected model behavior parameters (
systemPrompt,userPrompt,temperature). - Environment routing strings via
secrets/providers.example.jsonlogic (e.g., falling back ontoMODEL_PRIMARYif specific model isn't requested).
Expected Outputs
- A standardized
CompletionResponseobject containing the model text, token usage, and latency.
Constraints
- Business logic (like
RankingService) MUST NOT know that MiniMax is the underlying provider. It only knows anICompletionProviderinterface. - Must read base URLs from
OPENAI_BASE_URL(usuallyhttps://api.minimaxi.com/v1) and keys fromOPENAI_API_KEY. - Network errors must be caught and redacted so that
fetchdoesn't throwAPI_KEY=xxxinto standard out.
Step-by-Step Execution
- Wrap an OpenAI REST client or generic
fetchinvocation targetingOPENAI_BASE_URL/chat/completions. - Map
modelargument toprocess.env.MODEL_PRIMARY(e.g.,MiniMax-M2.7) orprocess.env.MODEL_FAST. - Execute request and normalize the response body to internal domains.
- Handle rate-limiting (429) gracefully using exponential backoff without crashing the global autonomous pipeline.
Validation Checklist
- [ ] Does the
minimaxProvider.tsclass implementIModelProvider? - [ ] Is the business logic importing
IModelProviderand ignoring provider-specific quirks? - [ ] Are models dynamically selectable by env variables rather than hardcoded string literals?