llm
DeepSeek LLM service implementation using OpenAI-compatible interface.
- class pipecat.services.deepseek.llm.DeepSeekThinkingConfig(*, type: Literal['enabled', 'disabled'] | str)[source]
Bases:
BaseModelConfiguration for thinking.
- Parameters:
type – Thinking mode. DeepSeek’s V4 models think before answering unless “disabled” turns it off, which for real-time voice cuts the time to the first answer token.
- class pipecat.services.deepseek.llm.DeepSeekLLMSettings(model: str | None | NotGiven = <factory>, extra: dict[str, Any]=<factory>, system_instruction: str | None | NotGiven = <factory>, temperature: float | None | NotGiven | NotGiven = <factory>, max_tokens: int | None | NotGiven | NotGiven = <factory>, top_p: float | None | NotGiven | NotGiven = <factory>, top_k: int | None | NotGiven = <factory>, frequency_penalty: float | None | NotGiven | NotGiven = <factory>, presence_penalty: float | None | NotGiven | NotGiven = <factory>, seed: int | None | NotGiven | NotGiven = <factory>, filter_incomplete_user_turns: bool | None | NotGiven = <factory>, user_turn_completion_config: UserTurnCompletionConfig | None | NotGiven = <factory>, use_provider_thinking_default: bool | NotGiven = <factory>, max_completion_tokens: int | None | NotGiven | NotGiven = <factory>, thinking: DeepSeekThinkingConfig | None | NotGiven = <factory>)[source]
Bases:
OpenAILLMSettingsSettings for DeepSeekLLMService.
- Parameters:
thinking – Thinking mode configuration. The service defaults this to disabled: DeepSeek’s V4 models otherwise run a reasoning pass before every answer, which delays the first spoken token. Set
DeepSeekThinkingConfig(type="enabled")to turn it on, orNoneto leave the choice to DeepSeek’s own default.
- class pipecat.services.deepseek.llm.DeepSeekLLMService(*, api_key: str, base_url: str = 'https://api.deepseek.com/v1', model: str | None = None, settings: DeepSeekLLMSettings | None = None, **kwargs)[source]
Bases:
OpenAILLMServiceA service for interacting with DeepSeek’s API using the OpenAI-compatible interface.
This service extends OpenAILLMService to connect to DeepSeek’s API endpoint while maintaining full compatibility with OpenAI’s interface and functionality.
- supports_developer_role: bool = False
Whether this service’s API supports the “developer” message role.
OpenAI’s native API supports it, but some OpenAI-compatible services (e.g. Cerebras) do not. Subclasses that don’t support it should set this to
False, which causes the adapter to convert “developer” messages to “user” messages before sending them to the API.
- supports_response_schema: bool = False
Whether the API can enforce a response schema. OpenAI-compatible services whose API cannot should set this to
False.
- adapter_class
alias of
DeepSeekLLMAdapter
- Settings
alias of
DeepSeekLLMSettings
- ThinkingConfig
alias of
DeepSeekThinkingConfig
- __init__(*, api_key: str, base_url: str = 'https://api.deepseek.com/v1', model: str | None = None, settings: DeepSeekLLMSettings | None = None, **kwargs)[source]
Initialize the DeepSeek LLM service.
- Parameters:
api_key – The API key for accessing DeepSeek’s API.
base_url – The base URL for DeepSeek API. Defaults to “https://api.deepseek.com/v1”.
model –
The model identifier to use. Defaults to “deepseek-flash”.
Deprecated since version 0.0.105: Use
settings=DeepSeekLLMService.Settings(model=...)instead. Will be removed in 2.0.0.settings – Runtime-updatable settings. When provided alongside deprecated parameters,
settingsvalues take precedence.**kwargs – Additional keyword arguments passed to OpenAILLMService.
- create_client(api_key=None, base_url=None, **kwargs)[source]
Create OpenAI-compatible client for DeepSeek API endpoint.
- Parameters:
api_key – The API key for authentication. If None, uses instance default.
base_url – The base URL for the API. If None, uses instance default.
**kwargs – Additional keyword arguments for client configuration.
- Returns:
An OpenAI-compatible client configured for DeepSeek’s API.
- build_chat_completion_params(params_from_context: OpenAILLMInvocationParams) dict[source]
Build parameters for DeepSeek chat completion request.
DeepSeek doesn’t support some OpenAI parameters like seed and max_completion_tokens.
- Parameters:
params_from_context – Parameters, derived from the LLM context, to use for the chat completion. Contains messages, tools, and tool choice.
- Returns:
Dictionary of parameters for the chat completion request.