Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/types/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
// ---- Text / Chat (Anthropic Messages API) ----

export type VideoSource =
| {
type: 'url';
url: string;
detail?: 'low' | 'default' | 'high';
fps?: number;
max_long_side_pixel?: number;
}
| {
type: 'base64';
media_type: string;
data: string;
detail?: 'low' | 'default' | 'high';
fps?: number;
max_long_side_pixel?: number;
};

export type ContentBlock =
| { type: 'text'; text: string }
| { type: 'video'; source: VideoSource }
| { type: 'thinking'; thinking: string }
| { type: 'tool_use'; id: string; name: string; input: Record<string, unknown> }
| { type: 'tool_result'; tool_use_id: string; content: string };
Expand Down
64 changes: 64 additions & 0 deletions test/sdk/text.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,70 @@ describe('MiniMaxSDK.text', () => {
expect(result.id).toBe('msg-123');
});

it('passes video content blocks through to chat requests', async () => {
let requestBody: unknown;
server = createMockServer({
routes: {
'/anthropic/v1/messages': async request => {
requestBody = await request.json();
return jsonResponse({
id: 'msg-video',
type: 'message',
role: 'assistant',
content: [{ type: 'text', text: 'A short clip.' }],
model: 'MiniMax-M3',
stop_reason: 'end_turn',
usage: { input_tokens: 20, output_tokens: 4 },
});
},
},
});

const sdk = new MiniMaxSDK({
apiKey: 'test-key',
baseUrl: server.url,
});

await sdk.text.chat({
messages: [{
role: 'user',
content: [
{ type: 'text', text: 'What happens in this clip?' },
{
type: 'video',
source: {
type: 'url',
url: 'https://example.com/clip.mp4',
detail: 'high',
fps: 0.5,
max_long_side_pixel: 1280,
},
},
],
}],
});

expect(requestBody).toMatchObject({
model: 'MiniMax-M3',
messages: [{
role: 'user',
content: [
{ type: 'text', text: 'What happens in this clip?' },
{
type: 'video',
source: {
type: 'url',
url: 'https://example.com/clip.mp4',
detail: 'high',
fps: 0.5,
max_long_side_pixel: 1280,
},
},
],
}],
});
});

it('streaming skips empty SSE data events', async () => {
const chunk = JSON.stringify({
type: 'content_block_delta',
Expand Down