Skip to content

Instantly share code, notes, and snippets.

@sang4lv
Created November 10, 2025 13:42
Show Gist options
  • Select an option

  • Save sang4lv/bf0337816c1c8b9a96be7317efc403ee to your computer and use it in GitHub Desktop.

Select an option

Save sang4lv/bf0337816c1c8b9a96be7317efc403ee to your computer and use it in GitHub Desktop.
const provider = createOpenAI({
baseURL: 'https://api.minimax.io/v1',
apiKey: process.env.MINIMAX_API_KEY,
fetch: async (url, options) => {
if (options.body) {
const body = JSON.parse(options.body as string);
body.reasoning_split = true;
options.body = JSON.stringify(body);
}
const response = await fetch(url, options);
return response;
},
});
const model = provider.chat('MiniMax-M2-Stable');
const result = await streamText({
model: model,
messages: [{
role: 'user',
content: [
{
type: 'text',
text: 'What is in the following image?',
},
{
type: 'image',
image: 'https://cdn.gooo.ai/user-files/0fa6d9502a77e065459cc176a64865a2abf5a62f607bf498372223a9ed543254@chat',
},
],
}],
});
// data: {"type":"start"}
// data: {"type":"start-step","request":{"body":{"model":"MiniMax-M2-Stable","messages":[{"role":"user","content":[{"type":"text","text":"What is in the following image?"},{"type":"image_url","image_url":{"url":"https://cdn.gooo.ai/user-files/0fa6d9502a77e065459cc176a64865a2abf5a62f607bf498372223a9ed543254@chat"}}]}],"stream":true,"stream_options":{"include_usage":true}}},"warnings":[]}
// data: {"type":"finish-step","finishReason":"unknown","usage":{},"providerMetadata":{"openai":{}},"response":{"id":"aitxt-Y7eQ0zhatNgie5O2rI4iLJR8","timestamp":{},"modelId":"MiniMax-M2-Stable","headers":{"alb_receive_time":"1762782001.17","alb_request_id":"356733d3a4975da2ff0d4013ffab37101e84473e","connection":"keep-alive","content-length":"112","content-type":"application/json; charset=utf-8","date":"Mon, 10 Nov 2025 13:40:01 GMT","minimax-request-id":"df579d49011bfeb7bacbf3ec8a1a1954","strict-transport-security":"max-age=15724800; includeSubDomains","trace-id":"05611e31aa15ced1d9ae70f37e573519","x-session-id":"7f00258265e202b5cd68edca5780cddf"}}}
// data: {"type":"finish","finishReason":"unknown","totalUsage":{}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment