Skip to main content

Overview

DeepSeek provides specialized LLMs optimized for coding and general chat. The provider extends OpenAI’s interface with DeepSeek’s API endpoints and supports 128K context windows.

Installation

Basic Usage

Constructor Options

DeepSeekModelName
default:"deepseek-coder"
DeepSeek model name: "deepseek-coder" or "deepseek-chat"
string
DeepSeek API key (defaults to DEEPSEEK_API_KEY env variable)
number
Sampling temperature
number
Maximum tokens in response
number
Nucleus sampling parameter
object
Additional OpenAI client options (e.g., custom baseURL)

Supported Models

DeepSeek Coder

  • Context: 128K tokens
  • Optimized for: Code generation, completion, debugging
  • Use cases: Writing code, explaining code, refactoring

DeepSeek Chat

  • Context: 128K tokens
  • Optimized for: General conversation, reasoning
  • Use cases: Q&A, analysis, creative writing

Streaming

Function Calling

DeepSeek supports function calling (tool use):

Code Generation

Code Explanation

With LlamaIndex

Convenience Function

Configuration

Environment Variables

Custom Base URL

Default base URL: https://api.deepseek.com/v1

Global Settings

Model Selection Guide

Long Context Support

Both models support 128K context windows:

Error Handling

Tool Calling Support

Check if tool calling is supported:

Best Practices

  1. Use deepseek-coder for code: Better results for programming tasks
  2. Use deepseek-chat for general: Better for non-code tasks
  3. Leverage long context: Use full 128K for large codebases
  4. Provide context: Include relevant code snippets
  5. Use system messages: Guide the model’s behavior
  6. Enable streaming: Better UX for long generations

Example: Code Review Assistant

Example: Documentation Generator

Pricing

DeepSeek offers competitive pricing. Check DeepSeek pricing for current rates.

See Also