Strict Mode
Strict mode ensures the model strictly follows the JSON Schema format when generating function calls.
Strict mode ensures the model strictly follows the JSON Schema format when generating function calls. When enabled, the SDK automatically:
- Sends the request to the DeepSeek Beta endpoint (
https://api.deepseek.com/beta) - Passes
strict: truein all tool definitions to the API - Enforces that all object properties are required and sets
additionalProperties: false
The server validates the JSON Schema and returns an error if it doesn't conform to the supported schema types.
There are two ways to enable strict mode:
Model-Level Strict (Recommended)
Set strict: true on the model to enable strict mode for all tool calls globally:
When using model-level strict, all tools in requests will automatically have strict: true — you don't need to set it on each tool individually. The SDK also automatically switches to the Beta endpoint via model.enableBeta().
You can also manually trigger Beta endpoint switching:
Per-Tool Strict
Set strict: true on individual tools. All tools in the same request must have the same strict value — mixing strict and non-strict tools is not allowed:
When any tool has strict: true, the SDK automatically detects this and switches to the Beta endpoint before sending the request.
Type Safety
TypeScript enforces consistency at compile time through dedicated types:
StrictTool[]— All tools must havestrict: trueNonStrictTool[]— All tools havestrict: falseor undefinedConsistentTools=StrictTool[] | NonStrictTool[]— Union type used bygenerateTextand agent methods
A runtime validation via validateToolConsistency() is also performed as a fallback, throwing an error if strict and non-strict tools are mixed.
Supported JSON Schema Types
Strict mode supports a subset of JSON Schema types. Using unsupported types will result in a server-side error:
| Type | Notes |
|---|---|
object | All properties must be required; additionalProperties must be false |
string | Supports pattern, format (email, hostname, ipv4, ipv6, uuid); no minLength/maxLength |
number / integer | Supports minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, const, default |
boolean | Fully supported |
array | No minItems/maxItems support |
enum | Fully supported |
anyOf | Fully supported for union types |
$ref / $def | Supported for modular schemas and recursive structures |
Strict mode is a Beta feature. When any tool has strict: true, the SDK automatically switches to the Beta endpoint. The server validates the JSON Schema — if it contains unsupported types or doesn't conform to the strict mode requirements, an error will be returned. See the DeepSeek API documentation for complete details on supported JSON Schema types.

