> ## Documentation Index
> Fetch the complete documentation index at: https://docs.definable.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# DeepSeek

> Use DeepSeek models for cost-effective, high-quality AI generation.

## Setup

```bash theme={null}
export DEEPSEEK_API_KEY="sk-..."
```

## Basic Usage

```python theme={null}
from definable.model import DeepSeekChat
from definable.model.message import Message

model = DeepSeekChat(id="deepseek-chat")
response = model.invoke(
    messages=[Message(role="user", content="Hello!")],
    assistant_message=Message(role="assistant", content=""),
)
print(response.content)
```

## Parameters

<ParamField path="id" type="str" default="deepseek-chat">
  Model identifier. Common values: `deepseek-chat`, `deepseek-reasoner`.
</ParamField>

<ParamField path="api_key" type="str">
  DeepSeek API key. Defaults to the `DEEPSEEK_API_KEY` environment variable.
</ParamField>

<ParamField path="base_url" type="str" default="https://api.deepseek.com">
  DeepSeek API base URL.
</ParamField>

<ParamField path="temperature" type="float">
  Sampling temperature.
</ParamField>

<ParamField path="max_tokens" type="int">
  Maximum output tokens.
</ParamField>

## Reasoning Support

DeepSeek models can produce reasoning content alongside their response:

```python theme={null}
from definable.model.message import Message

model = DeepSeekChat(id="deepseek-reasoner")
response = model.invoke(
    messages=[Message(role="user", content="Solve: what is 15! / 13!?")],
    assistant_message=Message(role="assistant", content=""),
)
print(response.reasoning_content)  # Step-by-step reasoning
print(response.content)            # Final answer
```

## Streaming

```python theme={null}
from definable.model.message import Message

for chunk in model.invoke_stream(
    messages=[Message(role="user", content="Explain quantum computing.")],
    assistant_message=Message(role="assistant", content=""),
):
    if chunk.content:
        print(chunk.content, end="", flush=True)
```

## Async Usage

```python theme={null}
from definable.model.message import Message

response = await model.ainvoke(
    messages=[Message(role="user", content="Hello!")],
    assistant_message=Message(role="assistant", content=""),
)
```

<Note>
  DeepSeek does not support native structured outputs (`supports_native_structured_outputs = False`). Structured output requests are handled via prompt engineering with JSON Schema instructions.
</Note>
