Skip to content

models: Add support for DeepSeek models #428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

veeragoni
Copy link

@veeragoni veeragoni commented Jul 12, 2025

Features

  • New DeepSeek Model Provider: Full implementation with streaming and tool use support
  • OpenAI-compatible API: Uses OpenAI client for seamless integration with DeepSeek endpoints
  • Tool Use Support: Proper tool calling with calculator, file operations, and shell commands
  • Reasoning Model Support: Handles DeepSeek-specific features like reasoning content
  • Beta Features: Support for beta endpoint and advanced DeepSeek capabilities

Changes

  • src/strands/models/deepseek.py: New DeepSeek model provider implementation with proper tool use streaming
  • src/strands/models/__init__.py: Export DeepSeekModel class
  • tests_integ/models/test_model_deepseek.py: Comprehensive integration tests (8 test cases)
  • tests_integ/models/ds_test.py: Demonstration script showing tool use capabilities
  • README.md: Update documentation with DeepSeek examples and provider list

Usage

from strands.models.deepseek import DeepSeekModel
from strands_tools import calculator

model = DeepSeekModel(api_key="your-key", model_id="deepseek-chat")
agent = Agent(model=model, tools=[calculator])
result = agent("What is 42 ^ 9")  # Uses calculator tool correctly

Testing

✅ All 8 integration tests passing
✅ Basic conversation, structured output, streaming, tool usage
✅ Multi-tool workflows (calculator, file_read, shell)
✅ Configuration updates and async operations
✅ Tool use streaming matches OpenAI/Ollama implementations
✅ All mypy type checks passing

Documentation PR

strands-agents/docs#135

Type of Change

New feature

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

I ran hatch run prepare

Checklist

[x] I have read the CONTRIBUTING document
[x] I have added any necessary tests that prove my fix is effective or my feature works
[x] I have updated the documentation accordingly
[x] I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
[x] My changes generate no new warnings
[x] Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Suresh Veeragoni added 2 commits July 11, 2025 18:18
## Features
- **New DeepSeek Model Provider**: Full implementation with streaming and structured output support
- **OpenAI-compatible API**: Uses OpenAI client for seamless integration with DeepSeek endpoints
- **Reasoning Model Support**: Handles DeepSeek-specific features like reasoning content
- **Beta Features**: Support for beta endpoint and advanced DeepSeek capabilities

## Changes
- `src/strands/models/deepseek.py`: New DeepSeek model provider implementation
- `src/strands/models/__init__.py`: Export DeepSeekModel class
- `tests_integ/models/test_model_deepseek.py`: Comprehensive integration tests (7 test cases)
- `tests_integ/models/providers.py`: Add DeepSeek to provider configuration
- `README.md`: Update documentation with DeepSeek examples and provider list

## Usage
```python
from strands.models.deepseek import DeepSeekModel
model = DeepSeekModel(api_key="your-key", model_id="deepseek-chat")

Testing
✅ All 7 integration tests passing

✅ Basic conversation, structured output, streaming, tool usage

✅ Configuration updates and async operations
@veeragoni veeragoni changed the title # Add support for DeepSeek models models: Add support for DeepSeek models Jul 12, 2025
@zastrowm zastrowm added the area-provider Related to model providers label Jul 22, 2025
@SamYuan1990
Copy link

+1
I am attempting strands agent with official strands agents example and use deep seek as LLM service.
I found some formatting issue, so, if by this PR, we can have official support with DeepSeek instead of OpenAI... that's great.

strands.types.exceptions.EventLoopException: Failed to deserialize the JSON body into the target type: messages[2]: invalid type: sequence, expected a string at line 1 column 755

@mo-silent
Copy link

Hi @veeragoni ,
I see the CICD checks are failing. Would you like help fixing these issues?
I'm also interested in adding DeepSeek support and could collaborate with you.

@pgrayy
Copy link
Member

pgrayy commented Aug 18, 2025

Deepseek provides an OpenAI compatible endpoint (docs) and so can already be accessed using Strand's OpenAIModel provider. You just need to pass in the base_url into client_args (docs).

@mo-silent
Copy link

mo-silent commented Aug 18, 2025

Deepseek provides an OpenAI compatible endpoint (docs) and so can already be accessed using Strand's OpenAIModel provider. You just need to pass in the base_url into client_args (docs).

@pgrayy
I think you haven't tried to call Deepseek using the OpenAIModel provider. Deepseek does offer endpoints compatible with OpenAI. But in the OpenAIModel definition of stands-agent, it encapsulates request, which makes it incompatible with deepseek. For specific differences, you can refer to my screenshot:

Processing of agent OpenAIModel

stands-agent

Openai chat create api reference

openai-chat-create

Deepseek chat create api reference

deepseek

Solution

  1. Add Deepseek module provider
  2. Create a Custom Model Provider, inherit from OpenAIModel Provider and add subclasses to handle the content method

However, I have found that many people have the need to call deepseek, so I think it would be better to add a deepseek provider

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-provider Related to model providers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants