diff --git a/src/types/api.ts b/src/types/api.ts index 222786f..b914d97 100644 --- a/src/types/api.ts +++ b/src/types/api.ts @@ -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 } | { type: 'tool_result'; tool_use_id: string; content: string }; diff --git a/test/sdk/text.test.ts b/test/sdk/text.test.ts index 4318651..a9558e8 100644 --- a/test/sdk/text.test.ts +++ b/test/sdk/text.test.ts @@ -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',