How to Use the DeepSeek Provider with CodeWhale: Complete Configuration Guide

To use the DeepSeek provider with CodeWhale, set provider = "deepseek" in your TOML configuration file, define the base_url and model under the [providers.deepseek] table, and optionally supply your API key and custom HTTP headers.

CodeWhale is an open-source LLM orchestration framework that routes requests to various AI providers through a unified configuration system. The tool uses a single TOML-based configuration file to manage provider settings, making it straightforward to switch between different language models including DeepSeek's suite of chat and code-generation models.

Understanding the Configuration Architecture

CodeWhale centralizes provider settings in config.toml (or the template config.example.toml). The crates/config module parses these values into an internal ProvidersToml structure that the runtime consumes when building HTTP requests.

The configuration system distinguishes between global settings (like the default provider and base_url) and provider-specific tables (like [providers.deepseek]) that contain authentication credentials, model names, and custom headers.

Step-by-Step DeepSeek Configuration

1. Select DeepSeek as the Default Provider

Set the top-level provider field to identify DeepSeek as your active backend. In config.example.toml at line 22, the template shows:

provider = "deepseek"

This value determines which provider configuration block CodeWhale will use for LLM requests.

2. Configure the API Base URL

Specify the DeepSeek endpoint using the base_url field. CodeWhale supports both the beta endpoint (https://api.deepseek.com/beta) and the classic endpoint (https://api.deepseek.com), as documented in config.example.toml at line 24:

base_url = "https://api.deepseek.com/beta"

If omitted, the runtime falls back to the beta URL when constructing request URLs.

3. Specify the Model Name

Inside the [providers.deepseek] table, set the model field to your desired DeepSeek model. According to config.example.toml at line 256, valid options include deepseek-v4-pro and deepseek-v4-flash:

[providers.deepseek]
model = "deepseek-v4-pro"

4. Add API Key Authentication

Provide your DeepSeek API key under the [providers.deepseek] table. The crates/config/src/lib.rs file at line 657 handles the api_key field, ensuring the value is read into memory but never logged to console or disk:

[providers.deepseek]
api_key = "YOUR_DEEPSEEK_API_KEY"

5. Configure Custom HTTP Headers

For enterprise deployments requiring additional headers, define the http_headers field as a TOML inline table. The configuration parser at crates/config/src/lib.rs line 530 maps these entries to the HTTP client:

[providers.deepseek]
http_headers = { "X-Custom-Header" = "value", "X-Enterprise-ID" = "12345" }

Complete Configuration Example

Copy the following snippet into your config.toml file to enable DeepSeek with full authentication and optional headers:


# Global provider selection (config.example.toml L22)

provider = "deepseek"

# DeepSeek API endpoint - use beta for latest features (config.example.toml L24)

base_url = "https://api.deepseek.com/beta"

[providers.deepseek]

# Model selection (config.example.toml L256)

model = "deepseek-v4-pro"

# Authentication (crates/config/src/lib.rs L657)

api_key = "YOUR_DEEPSEEK_API_KEY"

# Optional: Enterprise headers (crates/config/src/lib.rs L530)

# http_headers = { "X-Proxy-Auth" = "token" }

How CodeWhale Processes DeepSeek Settings

The configuration parsing logic resides in crates/config/src/lib.rs. At line 294, the Config struct contains a providers: ProvidersToml field that stores provider-specific settings:

// Simplified from crates/config/src/lib.rs L294
pub struct Config {
    pub provider: String,
    pub base_url: Option<String>,
    pub providers: ProvidersToml,
}

When the TOML file loads, the parser maps providers.deepseek.* entries to self.providers.deepseek (lines 657–669). The runtime later accesses these values through getter methods to construct API requests.

Runtime Implementation Details

During execution, CodeWhale retrieves the DeepSeek configuration to build HTTP requests. The following pattern from the request-building layer demonstrates how the tool consumes your configuration:

let cfg = Config::load().await?;
let deepseek_cfg = cfg.providers.deepseek;

// Construct request URL using configured base_url or default
let url = format!(
    "{}/v1/chat/completions",
    deepseek_cfg.base_url.unwrap_or_else(|| "https://api.deepseek.com/beta".to_string())
);

let model = deepseek_cfg.model.unwrap_or_else(|| "deepseek-v4-pro".to_string());

// Build headers with API key and custom headers
let mut req = http::Request::post(&url)
    .header("Authorization", format!("Bearer {}", deepseek_cfg.api_key.unwrap()));

if let Some(headers) = &deepseek_cfg.http_headers {
    for (k, v) in headers {
        req = req.header(k, v);
    }
}

This implementation automatically picks up your base_url, model, api_key, and http_headers values to authenticate and route requests to DeepSeek's API endpoints.

Summary

  • Configuration location: Edit config.toml or reference config.example.toml for the DeepSeek provider template.
  • Provider selection: Set provider = "deepseek" at the top level of your configuration file.
  • Endpoint setup: Configure base_url as https://api.deepseek.com/beta (recommended) or https://api.deepseek.com.
  • Model specification: Define your model under [providers.deepseek] using the model field (e.g., deepseek-v4-pro).
  • Security: Store your API key in providers.deepseek.api_key; CodeWhale never logs this value according to crates/config/src/lib.rs.
  • Customization: Add enterprise headers via providers.deepseek.http_headers for proxy or authentication requirements.

Frequently Asked Questions

What is the default DeepSeek endpoint in CodeWhale?

If you omit the base_url field, CodeWhale defaults to https://api.deepseek.com/beta when constructing request URLs. You can explicitly set this value or switch to the classic endpoint (https://api.deepseek.com) depending on your API access tier.

How do I switch between DeepSeek models?

Modify the model field inside the [providers.deepseek] table in your config.toml. Valid values include deepseek-v4-pro for high-quality generation and deepseek-v4-flash for faster inference. The configuration parser at config.example.toml line 256 documents these options.

Is the API key stored securely in CodeWhale?

Yes. According to the source code in crates/config/src/lib.rs at line 657, the api_key is parsed into memory as part of the ProvidersToml structure but is explicitly excluded from logging and debug output. Store the key only in your local configuration file and never commit it to version control.

Can I use custom HTTP headers with the DeepSeek provider?

Yes. Define the http_headers field as an inline table under [providers.deepseek]. The configuration module (crates/config/src/lib.rs line 530) parses these headers and injects them into every HTTP request sent to the DeepSeek API, enabling corporate proxy authentication or custom routing rules.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →