# DeepSeek v4 API Complete API reference for DeepSeek v4 LLM models powered by DeepSeek. ## Model Updates ### DeepSeek v4 Pro 0813 - Flaq AI has updated DeepSeek v4 Pro to DeepSeek's official `deepseek-v4-pro-0813` release. - Use the `0813` model IDs below to access the official version. - The original Pro model IDs are unavailable. | Variant | 0813 Model ID | Unavailable Model ID | |---------|---------------|----------------------| | Text to Text | `deepseek-v4-pro-text-to-text-0813` | `deepseek-v4-pro-text-to-text` | | Web Search | `deepseek-v4-pro-web-search-0813` | `deepseek-v4-pro-web-search` | ### DeepSeek v4 Flash 0731 - Flaq AI has updated DeepSeek v4 Flash to DeepSeek's official `deepseek-v4-flash-0731` release. - Use the `0731` model IDs below to access the updated version. - The original Flash model IDs are unavailable. | Variant | 0731 Model ID | Unavailable Model ID | |---------|---------------|----------------------| | Text to Text | `deepseek-v4-flash-text-to-text-0731` | `deepseek-v4-flash-text-to-text` | | Web Search | `deepseek-v4-flash-web-search-0731` | `deepseek-v4-flash-web-search` | ## Model Variants This API supports four DeepSeek v4 model variants: | Model | ID | Description | |-------|----|-------------| | **DeepSeek v4 Pro Text to Text** | `deepseek-v4-pro-text-to-text-0813` | High-quality text reasoning and writing | | **DeepSeek v4 Flash Text to Text** | `deepseek-v4-flash-text-to-text-0731` | Faster, more affordable text generation | | **DeepSeek v4 Pro Web Search** | `deepseek-v4-pro-web-search-0813` | Web-aware answers with DeepSeek v4 Pro reasoning | | **DeepSeek v4 Flash Web Search** | `deepseek-v4-flash-web-search-0731` | Faster web-aware answers with DeepSeek v4 Flash | ## Quick Comparison | Feature | Pro Text to Text | Flash Text to Text | Pro Web Search | Flash Web Search | |---------|------------------|------------|----------------|------------------| | Text input | Required ✅ | Required ✅ | Required ✅ | Required ✅ | | Image input | Not supported ❌ | Not supported ❌ | Not supported ❌ | Not supported ❌ | | File input | Not supported ❌ | Not supported ❌ | Not supported ❌ | Not supported ❌ | | Web search | Not supported ❌ | Not supported ❌ | Enabled ✅ | Enabled ✅ | | Streaming response | SSE | SSE | SSE | SSE | | `max_tokens` | Optional | Optional | Optional | Optional | | `top_p` | Optional | Optional | Optional | Optional | | `top_k` | Optional | Optional | Optional | Optional | ## DeepSeek v4 Pro Text to Text ### Endpoint ```http POST /api/v1/chat/completions ``` ### Request Parameters #### Required | Parameter | Type | Description | |-----------|------|-------------| | `model` | string | Must be `"deepseek-v4-pro-text-to-text-0813"` | | `messages` | array | Ordered text-only messages. Supports `system`, `user`, and `assistant` roles. See LLM API for the message structure. | | `stream` | boolean | `true` for SSE, `false` for a single JSON response. | #### Message Support | Field | Text | File | Image | |-------|------|------|-------| | `messages` | Required ✅ | Not supported ❌ | Not supported ❌ | #### Optional | Parameter | Type | Range | Description | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 0` | Maximum output tokens. | | `top_p` | number | `0.0` - `1.0` | Limits cumulative probability mass for candidate tokens. | | `top_k` | integer | `0` - `100` | Limits the number of candidate tokens. | ### Example Request ```javascript const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Accept': 'text/event-stream', 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'deepseek-v4-pro-text-to-text-0813', messages: [ { role: 'user', content: 'Hello' } ], stream: true, max_tokens: 500, top_p: 0.5, top_k: 1 }) }); ``` ## DeepSeek v4 Flash Text to Text ### Endpoint ```http POST /api/v1/chat/completions ``` ### Request Parameters #### Required | Parameter | Type | Description | |-----------|------|-------------| | `model` | string | Must be `"deepseek-v4-flash-text-to-text-0731"` | | `messages` | array | Ordered text-only messages. Supports `system`, `user`, and `assistant` roles. See LLM API for the message structure. | | `stream` | boolean | `true` for SSE, `false` for a single JSON response. | #### Message Support | Field | Text | File | Image | |-------|------|------|-------| | `messages` | Required ✅ | Not supported ❌ | Not supported ❌ | #### Optional | Parameter | Type | Range | Description | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 0` | Maximum output tokens. | | `top_p` | number | `0.0` - `1.0` | Limits cumulative probability mass for candidate tokens. | | `top_k` | integer | `0` - `100` | Limits the number of candidate tokens. | ### Example Request ```javascript const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'deepseek-v4-flash-text-to-text-0731', messages: [ { role: 'user', content: 'Write a four-line modern poem about a programmer drinking coffee.' } ], stream: false, max_tokens: 500, top_p: 0.5, top_k: 1 }) }); ``` ## DeepSeek v4 Pro Web Search ### Endpoint ```http POST /api/v1/chat/completions ``` ### Request Parameters #### Required | Parameter | Type | Description | |-----------|------|-------------| | `model` | string | Must be `"deepseek-v4-pro-web-search-0813"` | | `messages` | array | Ordered text-only messages. Supports `system`, `user`, and `assistant` roles. See LLM API for the message structure. | | `stream` | boolean | `true` for SSE, `false` for a single JSON response. | #### Message Support | Field | Text | File | Image | |-------|------|------|-------| | `messages` | Required ✅ | Not supported ❌ | Not supported ❌ | #### Optional | Parameter | Type | Range | Description | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 0` | Maximum output tokens. | | `top_p` | number | `0.0` - `1.0` | Limits cumulative probability mass for candidate tokens. | | `top_k` | integer | `0` - `100` | Limits the number of candidate tokens. | ### Example Request ```javascript const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Accept': 'text/event-stream', 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'deepseek-v4-pro-web-search-0813', messages: [ { role: 'user', content: 'What date is it today?' } ], stream: true, max_tokens: 500, top_p: 0.5, top_k: 1 }) }); ``` ## DeepSeek v4 Flash Web Search ### Endpoint ```http POST /api/v1/chat/completions ``` ### Request Parameters #### Required | Parameter | Type | Description | |-----------|------|-------------| | `model` | string | Must be `"deepseek-v4-flash-web-search-0731"` | | `messages` | array | Ordered text-only messages. Supports `system`, `user`, and `assistant` roles. See LLM API for the message structure. | | `stream` | boolean | `true` for SSE, `false` for a single JSON response. | #### Message Support | Field | Text | File | Image | |-------|------|------|-------| | `messages` | Required ✅ | Not supported ❌ | Not supported ❌ | #### Optional | Parameter | Type | Range | Description | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 0` | Maximum output tokens. | | `top_p` | number | `0.0` - `1.0` | Limits cumulative probability mass for candidate tokens. | | `top_k` | integer | `0` - `100` | Limits the number of candidate tokens. | ### Example Request ```javascript const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Accept': 'text/event-stream', 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'deepseek-v4-flash-web-search-0731', messages: [ { role: 'user', content: 'What date is it today?' } ], stream: true, max_tokens: 500, top_p: 0.5, top_k: 1 }) }); ``` ## Response Format DeepSeek V4 LLM models return OpenAI-compatible completion responses. With `stream: true`, the response is Server-Sent Events; with `stream: false`, the response is a single JSON object. ### Error Response ```json { "error": { "code": "1001", "param": null, "message": "Authorization is empty", "type": "invalid_request_error" } } ``` ## Best Practices 1. **Choose the right variant:** Use Pro models for higher-quality reasoning and Flash models for lower-latency, lower-cost workloads. 2. **Use Web Search for current events:** Choose Pro or Flash Web Search when the answer depends on up-to-date online information. 3. **Tune sampling parameters carefully:** `top_p` and `top_k` are supported across all DeepSeek v4 variants and can change output diversity. 4. **Send only supported inputs:** Do not send file or image parts to any DeepSeek v4 route. 5. **Match Accept with stream mode:** Use `Accept: text/event-stream` for streaming requests and `Accept: application/json` for non-streaming requests.