ReqLLM. Providers. Deepseek
(ReqLLM v1.16.0)
View Source
DeepSeek AI provider – OpenAI-compatible Chat Completions API.
Implementation
Uses built-in OpenAI-style encoding/decoding defaults. DeepSeek is fully OpenAI-compatible, so no custom request/response handling is needed.
Authentication
Requires a DeepSeek API key from https://platform.deepseek.com/
Configuration
# Add to .env file (automatically loaded)
DEEPSEEK_API_KEY=your-api-keyExamples
# Basic usage
ReqLLM.generate_text("deepseek:deepseek-chat", "Hello!")
# With custom parameters
ReqLLM.generate_text("deepseek:deepseek-reasoner", "Write a function",
temperature: 0.2,
max_tokens: 2000
)
# Streaming
ReqLLM.stream_text("deepseek:deepseek-chat", "Tell me a story")
|> Enum.each(&IO.write/1)
# With thinking mode enabled (default for reasoning models)
ReqLLM.generate_text("deepseek:deepseek-v4-pro", "Solve this complex problem",
reasoning_effort: :high,
provider_options: [
thinking: %{type: "enabled"}
]
)
# With maximum reasoning effort for complex tasks
ReqLLM.generate_text("deepseek:deepseek-v4-pro", "Complex reasoning task",
reasoning_effort: :xhigh
)
# Disable thinking mode
ReqLLM.generate_text("deepseek:deepseek-v4-pro", "Quick question",
provider_options: [
thinking: %{type: "disabled"}
]
)Models
DeepSeek offers several models including:
deepseek-chat- General purpose conversational modeldeepseek-reasoner- Reasoning and problem-solvingdeepseek-v4-flash- Fast reasoning model with lower latencydeepseek-v4-pro- Latest reasoning model with thinking support
Thinking Mode
DeepSeek models support thinking mode for improved reasoning.
See DeepSeek Thinking Mode Guide for details.
Options
thinking: %{type: "enabled"}- Enable thinking mode (default for reasoning models)thinking: %{type: "disabled"}- Disable thinking mode
Reasoning Effort
The reasoning_effort option controls the depth of reasoning. For compatibility,
:low and :medium are mapped to "high", and :xhigh is mapped to "max".
Only "high" and "max" are the meaningful values sent to the API:
:low→ mapped to"high":medium→ mapped to"high":high→"high"(default for thinking mode):xhigh→ mapped to"max"(maximum effort for complex tasks)
See https://platform.deepseek.com/docs for full model documentation.
Summary
Functions
Default implementation of attach/3.
Default implementation of attach_stream/4.
Default implementation of build_body/1.
Default implementation of decode_response/1.
Default implementation of decode_stream_event/2.
Callback implementation for ReqLLM.Provider.default_env_key/0.
Default implementation of encode_body/1.
Default implementation of extract_usage/2.
Default implementation of prepare_request/4.
Default implementation of translate_options/3.
Functions
Default implementation of attach/3.
Sets up Bearer token authentication and standard pipeline steps.
Default implementation of attach_stream/4.
Builds complete streaming requests using OpenAI-compatible format.
Default implementation of build_body/1.
Builds request body using OpenAI-compatible format for chat and embedding operations.
Default implementation of decode_response/1.
Handles success/error responses with standard ReqLLM.Response creation.
Default implementation of decode_stream_event/2.
Decodes SSE events using OpenAI-compatible format.
Callback implementation for ReqLLM.Provider.default_env_key/0.
Default implementation of encode_body/1.
Encodes request body using OpenAI-compatible format for chat and embedding operations.
Default implementation of extract_usage/2.
Extracts usage data from standard usage field in response body.
Default implementation of prepare_request/4.
Handles :chat, :object, and :embedding operations using OpenAI-compatible patterns.
Default implementation of translate_options/3.
Pass-through implementation that returns options unchanged.