-
Notifications
You must be signed in to change notification settings - Fork 0
DeepSeek API Chat Streaming
YarCraSy edited this page Jul 12, 2026
·
3 revisions
Official reference:
src/deepseekApi/providers/deepseek/DeepSeekProvider.tssrc/deepseekApi/providers/deepseek/features/Chat.tssrc/VsCodeApi/webviews/handlers/Chat/Streaming.ts
-
ChatHandlerprepares messages and configuration. -
createDeepSeekProvider(config)creates the provider. - The provider always opens an SSE request for chat responses.
- Each chunk is normalized as content or reasoning.
-
streaming.tspublishes events to the webview, where the UI renders accumulated deltas progressively rather than jumping per transport chunk. - When finished, the accumulated content is returned for history.
- The main endpoint is
POST /chat/completions. -
messagesacceptssystem,user,assistant, andtoolroles. -
stream: truesends deltas through Server-Sent Events and closes withdata: [DONE]. - In thinking mode, reasoning arrives as
reasoning_content, separate fromcontent. -
finish_reasonmay indicatestop,length,content_filter,tool_calls, or insufficient resources. -
usagemay include prompt, completion, cache hit/miss, and reasoning tokens.
cancelGeneration must trigger an AbortController shared by the active request. The handler should publish a controlled error or close event depending on the exact cancellation point.
Errors should arrive as streamError with a useful message. Do not leak the API key or full sensitive response bodies.
Review Error Codes before changing HTTP error mapping.