> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lithosai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DeepSeek-V4.1-Flash

> DeepSeek-V4.1-Flash 的模型 ID、长度限制、思考模式控制和支持的请求参数。

## 模型 ID

| 模型 ID |
| - |
| `deepseek-ai/DeepSeek-V4.1-Flash` |
| `deepseek-ai/DeepSeek-V4.1-Flash-fast` |
| `deepseek-ai/DeepSeek-V4.1-Flash-ultra` |

三个 ID 是同一个模型，接受的参数也相同。每个 ID 有自己的价格和[速率限制](https://docs.lithosai.com/zh/rate-limits.md)，分别在 [模型](https://console.lithosai.cloud/models?lang=zh) 和 [速率限制](https://console.lithosai.cloud/limits?lang=zh) 页面查看。

## 长度限制

| 限制 | token 数 |
| - | - |
| 上下文窗口 | 1,048,576 |
| 最大输出长度 | 393,216 |

上下文窗口同时包含输入和 `max_tokens`。输入加上 `max_tokens` 超过上限时，请求返回 400。`max_tokens` 可以设得比 393,216 大，但输出最多 393,216 个 token。

没有设置 `max_tokens` 的请求按模式使用默认值：

| 模式 | 默认 `max_tokens` |
| - | - |
| 关闭思考 | 8,192 |
| 开启思考 | 65,536 |
| 开启思考，推理强度 `max` | 131,072 |

如果上下文窗口中留给输出的空间小于默认值，默认值取剩余空间。包含图片且未设置 `max_tokens` 的请求最多可输出到最大输出长度。以上上限和默认值与 DeepSeek 官方 API 一致。对大段输入做长时间推理时可能超过默认值，使用推理强度 `max` 或长文档时请设置 `max_tokens`。

## 思考模式

思考模式默认开启，推理强度为 `high`，与 DeepSeek 官方 API 一致。用 `reasoning_effort` 或 DeepSeek 风格的 `thinking` 对象控制。

| 请求 | 思考模式 |
| - | - |
| 两个字段都不设置 | 开启，推理强度 `high` |
| `"reasoning_effort": "none"` | 关闭 |
| `"reasoning_effort": "high"` | 开启，使用你设置的推理强度 |
| `"thinking": {"type": "disabled"}` | 关闭 |
| `"thinking": {"type": "enabled"}` | 开启，推理强度 `high` |
| `"thinking": {"type": "enabled", "effort": "max"}` | 开启，使用你设置的推理强度 |

`reasoning_effort` 和 `thinking.effort` 可选 `none`、`minimal`、`low`、`medium`、`high`、`xhigh`、`max` 和 `ultra`。与 DeepSeek 官方 API 一样，部分取值按其他推理强度运行：

| 请求值 | 实际推理强度 |
| - | - |
| `none` | 关闭思考模式 |
| `minimal`、`low` | `low` |
| `medium`、`high`、`xhigh` | `high` |
| `max`、`ultra` | `max` |

其他值返回 400。

```python Python theme={null}
import os

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["LITHOSAI_API_KEY"],
    base_url="https://api.lithosai.cloud/v1",
)

# 关闭思考模式
response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4.1-Flash",
    messages=[{"role": "user", "content": "What is 17 * 23?"}],
    reasoning_effort="none",
)

# 开启思考模式，推理强度 max
response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V4.1-Flash",
    messages=[{"role": "user", "content": "What is 17 * 23?"}],
    extra_body={"thinking": {"type": "enabled", "effort": "max"}},
)
print(response.choices[0].message.reasoning_content)
print(response.choices[0].message.content)
```

```bash curl theme={null}
curl https://api.lithosai.cloud/v1/chat/completions \
  -H "Authorization: Bearer $LITHOSAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-ai/DeepSeek-V4.1-Flash",
    "messages": [{"role": "user", "content": "What is 17 * 23?"}],
    "thinking": {"type": "disabled"}
  }'
```

思考内容放在 `message.reasoning_content` 中，流式输出时放在 `delta.reasoning_content` 中，与 `content` 分开。`usage.completion_tokens_details.reasoning_tokens` 是思考内容的 token 数。这部分 token 计入 `completion_tokens`，按输出价格计费。

`max_tokens` 同时限制思考内容和回答。如果思考内容用完了全部额度，响应以 `finish_reason: "length"` 结束，`content` 为空。停止序列也会在思考内容中匹配，一旦匹配，响应会在回答开始之前结束。

## 参数

| 参数 | 说明 |
| - | - |
| `max_tokens`、`max_completion_tokens` | 同时限制思考内容和回答。默认值按模式而定，见[长度限制](#长度限制)。 |
| `temperature` | 0 到 2。 |
| `top_p` | 大于 0，最大为 1。 |
| `top_k`、`presence_penalty`、`frequency_penalty` | 支持。 |
| `stop` | 也会在思考内容中匹配。 |
| `seed` | 可以传，但不能让输出可复现。 |
| `stream`、`stream_options` | 无论是否设置 `include_usage`，流的最后都有一个携带用量的数据块。 |
| `tools`、`tool_choice` | `auto`、`required`、`none` 或指定函数。 |
| `response_format` | `text`、`json_object` 和 `json_schema`。 |
| `reasoning_effort`、`thinking` | 见[思考模式](#思考模式)。 |
| `user` | 支持。 |

设置 `tool_choice: "none"` 时，工具不会写入提示词，与 DeepSeek 官方 API 一致，模型以纯文本回答。

以下参数会返回 400：

| 参数 | `error.code` | `error.message` |
| - | - | - |
| `n` 不为 `1` | `unsupported_n` | `n must be 1` |
| `logprobs`，即使值为 `false` | `unsupported_parameter` | ``the parameter `logprobs` is not supported`` |
| `top_logprobs` | `unsupported_parameter` | ``the parameter `top_logprobs` is not supported`` |
| `logit_bias` | `unsupported_parameter` | ``the parameter `logit_bias` is not supported`` |
| API 未定义的字段，例如 `chat_template_kwargs` | `unknown_parameter` | `unrecognized request argument supplied: chat_template_kwargs` |

```json theme={null}
{
  "error": {
    "message": "the parameter `logprobs` is not supported",
    "type": "invalid_request_error",
    "param": null,
    "code": "unsupported_parameter"
  }
}
```

超出取值范围的参数，例如 `temperature: 3` 或 `top_p: 0`，同样返回 400。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.