MCPcopy
hub / github.com/MiniMax-AI/cli / chatStream

Method chatStream

src/sdk/text/index.ts:8–29  ·  view source on GitHub ↗
(body: Partial<ChatRequest>)

Source from the content-addressed store, hash-verified

6
7export class TextSDK extends Client {
8 private async *chatStream(body: Partial<ChatRequest>): AsyncGenerator<StreamEvent> {
9 const url = chatEndpoint(this.config.baseUrl);
10
11 const res = await this.request({
12 url,
13 method: 'POST',
14 body,
15 stream: true,
16 authStyle: 'x-api-key',
17 });
18
19 const contentType = res.headers.get('content-type') || '';
20
21 if (!contentType.includes('text/event-stream') && !contentType.includes('stream')) {
22 throw new SDKError(
23 `Expected SSE stream but got content-type "${contentType}". Server may be experiencing issues.`,
24 ExitCode.GENERAL,
25 );
26 }
27
28 yield* this.streamSSE<StreamEvent>(res);
29 }
30
31 async chat(request: Partial<ChatRequest> & { stream: true }): Promise<AsyncGenerator<StreamEvent>>;
32 async chat(request: Partial<ChatRequest>): Promise<ChatResponse>;

Callers 1

chatMethod · 0.95

Calls 3

chatEndpointFunction · 0.90
requestMethod · 0.80
streamSSEMethod · 0.80

Tested by

no test coverage detected