Skip to content

Commit 71bce58

Browse files
committed
feat: type video chat content blocks
1 parent 24875e0 commit 71bce58

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

src/types/api.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
// ---- Text / Chat (Anthropic Messages API) ----
22

3+
export type VideoSource =
4+
| {
5+
type: 'url';
6+
url: string;
7+
detail?: 'low' | 'default' | 'high';
8+
fps?: number;
9+
max_long_side_pixel?: number;
10+
}
11+
| {
12+
type: 'base64';
13+
media_type: string;
14+
data: string;
15+
detail?: 'low' | 'default' | 'high';
16+
fps?: number;
17+
max_long_side_pixel?: number;
18+
};
19+
320
export type ContentBlock =
421
| { type: 'text'; text: string }
22+
| { type: 'video'; source: VideoSource }
523
| { type: 'thinking'; thinking: string }
624
| { type: 'tool_use'; id: string; name: string; input: Record<string, unknown> }
725
| { type: 'tool_result'; tool_use_id: string; content: string };

test/sdk/text.test.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,70 @@ describe('MiniMaxSDK.text', () => {
3737
expect(result.id).toBe('msg-123');
3838
});
3939

40+
it('passes video content blocks through to chat requests', async () => {
41+
let requestBody: unknown;
42+
server = createMockServer({
43+
routes: {
44+
'/anthropic/v1/messages': async request => {
45+
requestBody = await request.json();
46+
return jsonResponse({
47+
id: 'msg-video',
48+
type: 'message',
49+
role: 'assistant',
50+
content: [{ type: 'text', text: 'A short clip.' }],
51+
model: 'MiniMax-M3',
52+
stop_reason: 'end_turn',
53+
usage: { input_tokens: 20, output_tokens: 4 },
54+
});
55+
},
56+
},
57+
});
58+
59+
const sdk = new MiniMaxSDK({
60+
apiKey: 'test-key',
61+
baseUrl: server.url,
62+
});
63+
64+
await sdk.text.chat({
65+
messages: [{
66+
role: 'user',
67+
content: [
68+
{ type: 'text', text: 'What happens in this clip?' },
69+
{
70+
type: 'video',
71+
source: {
72+
type: 'url',
73+
url: 'https://example.com/clip.mp4',
74+
detail: 'high',
75+
fps: 0.5,
76+
max_long_side_pixel: 1280,
77+
},
78+
},
79+
],
80+
}],
81+
});
82+
83+
expect(requestBody).toMatchObject({
84+
model: 'MiniMax-M3',
85+
messages: [{
86+
role: 'user',
87+
content: [
88+
{ type: 'text', text: 'What happens in this clip?' },
89+
{
90+
type: 'video',
91+
source: {
92+
type: 'url',
93+
url: 'https://example.com/clip.mp4',
94+
detail: 'high',
95+
fps: 0.5,
96+
max_long_side_pixel: 1280,
97+
},
98+
},
99+
],
100+
}],
101+
});
102+
});
103+
40104
it('streaming skips empty SSE data events', async () => {
41105
const chunk = JSON.stringify({
42106
type: 'content_block_delta',

0 commit comments

Comments
 (0)