MCPcopy
hub / github.com/rohitg00/agentmemory / MinimaxProvider

Class MinimaxProvider

src/providers/minimax.ts:19–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17 * MINIMAX_BASE_URL — base URL without path (default: https://api.minimax.io/anthropic)
18 */
19export class MinimaxProvider implements MemoryProvider {
20 name = 'minimax'
21 private apiKey: string
22 private model: string
23 private maxTokens: number
24 private baseUrl: string
25
26 constructor(apiKey: string, model: string, maxTokens: number) {
27 this.apiKey = apiKey
28 this.model = model
29 this.maxTokens = maxTokens
30 this.baseUrl =
31 getEnvVar('MINIMAX_BASE_URL') || 'https://api.minimax.io/anthropic'
32 }
33
34 async compress(systemPrompt: string, userPrompt: string): Promise<string> {
35 return this.call(systemPrompt, userPrompt)
36 }
37
38 async summarize(systemPrompt: string, userPrompt: string): Promise<string> {
39 return this.call(systemPrompt, userPrompt)
40 }
41
42 private async call(systemPrompt: string, userPrompt: string): Promise<string> {
43 const url = `${this.baseUrl}/v1/messages`
44 const response = await fetchWithTimeout(url, {
45 method: 'POST',
46 headers: {
47 'Content-Type': 'application/json',
48 'x-api-key': this.apiKey,
49 'anthropic-version': '2023-06-01',
50 },
51 body: JSON.stringify({
52 model: this.model,
53 max_tokens: this.maxTokens,
54 system: systemPrompt,
55 messages: [{ role: 'user', content: userPrompt }],
56 }),
57 })
58
59 if (!response.ok) {
60 const text = await response.text()
61 throw new Error(`MiniMax API error ${response.status}: ${text}`)
62 }
63
64 const data = (await response.json()) as {
65 content?: Array<{ type: string; text?: string }>
66 }
67 const textBlock = data.content?.find((b) => b.type === 'text')
68 return textBlock?.text ?? ''
69 }
70}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected