Documentation
¶
Overview ¶
Package deepseek wraps DeepSeek's OpenAI-compatible API.
DeepSeek derives from the OpenAI Chat Completions protocol while retaining its provider-specific reasoning semantics behind Chat.
Provider-specific behavior handled transparently:
- reasoning_content is decoded into a [chat.PartReasoning];
- ordinary prior assistant reasoning is omitted on later turns;
- reasoning associated with tool calls is replayed as reasoning_content.
Provider-specific request controls use the typed RequestOptions extension; the OpenAI SDK request shape is intentionally not exposed. Prefix completion remains a separate beta protocol and is not accepted by Chat.
See https://api-docs.deepseek.com/ for the full API reference.
Index ¶
Constants ¶
const ( OpenAIResponseExtensionKey = "deepseek/openai_response" OpenAIStreamChunkExtensionKey = "deepseek/openai_stream_chunk" )
Namespacing preserves provider-specific data without promoting it into the shared Core protocol or colliding with another provider.
const ( ModelV4Flash = "deepseek-v4-flash" ModelV4Pro = "deepseek-v4-pro" )
Production model IDs. See https://api-docs.deepseek.com/quick_start/pricing for the current pricing and context-window limits.
const ( // BaseURL is DeepSeek's production endpoint. Equivalent to // "https://api.deepseek.com/v1" — DeepSeek accepts both. BaseURL = "https://api.deepseek.com" )
const (
Provider = "DeepSeek"
)
Provider is the stable backend name for host-side attribution.
const RequestExtensionKey = "deepseek/request"
Namespacing preserves provider-specific data without promoting it into the shared Core protocol or colliding with another provider.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chat ¶ added in v0.13.0
type Chat = openai.ChatCompletions
Chat implements DeepSeek's chat protocol.
func NewChat ¶ added in v0.13.0
func NewChat(config ChatConfig) (*Chat, error)
NewChat rejects an invalid provider binding before the first chat call.
type ChatConfig ¶ added in v0.13.0
type ChatConfig struct {
APIKey string
DefaultOptions corechat.Options
BaseURL string
HTTPClient *http.Client
}
ChatConfig binds provider access and defaults shared by every chat call.
func (ChatConfig) Validate ¶ added in v0.13.0
func (c ChatConfig) Validate() error
type RequestOptions ¶
type RequestOptions struct {
Thinking *ThinkingConfig `json:"thinking,omitempty"`
LogProbs *bool `json:"logprobs,omitempty"`
TopLogProbs *int64 `json:"top_logprobs,omitempty"`
IncludeUsage *bool `json:"include_usage,omitempty"`
UserID string `json:"user_id,omitempty"`
}
RequestOptions contains documented DeepSeek Chat Completions fields that have no provider-neutral Core equivalent. Store it in [chat.Options.Extensions] under RequestExtensionKey.
func (RequestOptions) ValidateFor ¶
func (r RequestOptions) ValidateFor(generation corechat.Options, tools []corechat.ToolDefinition, stream bool) error
type ThinkingConfig ¶
type ThinkingConfig struct {
Type ThinkingMode `json:"type"`
}
ThinkingConfig controls DeepSeek's hybrid thinking mode.
func (ThinkingConfig) Validate ¶
func (t ThinkingConfig) Validate() error
type ThinkingMode ¶
type ThinkingMode string
ThinkingMode selects whether DeepSeek emits reasoning_content before its final answer. The API defaults to enabled when the field is omitted.
const ( ThinkingEnabled ThinkingMode = "enabled" ThinkingDisabled ThinkingMode = "disabled" )
These are the provider values this adapter recognizes.