Back to Blog

DeepSeek V4 Pro with Claude Code: Low-Cost AI Coding

Tutorials and Guides8607
DeepSeek V4 Pro with Claude Code: Low-Cost AI Coding

Abstract

AI coding assistants have become essential productivity tools for modern software developers. As a powerful command-line AI agent, Claude Code delivers outstanding performance in code writing, project analysis, bug fixing and code refactoring. However, continuous use of its official API services leads to relatively high long-term costs. DeepSeek V4 Pro stands out among mainstream large language models, featuring strong capabilities in code generation, logical reasoning and complex task processing. After the official permanent price adjustment, it has become a highly cost-effective alternative for individual developers and small teams.

This article introduces two practical methods to connect DeepSeek V4 Pro with Claude Code: manual modification of configuration files and deployment via the cc-switch management tool. As a professional API gateway, 4sapi provides more favorable pricing than official services and enables unified invocation of different large models, helping enterprises cut operational expenses.

1. Preparations and Background Introduction

In modern software development workflows, AI coding tools greatly reduce repetitive work and improve overall development efficiency. Claude Code, running entirely on the terminal, is favored by a large number of developers for its deep adaptation to command-line environments and comprehensive agent capabilities. It can traverse local code repositories, understand project architectures, and complete end-to-end development tasks based on user instructions.

Despite its powerful functions, the high token cost of the official API restricts long-term large-scale usage. In contrast, DeepSeek V4 Pro has made remarkable progress in code-related scenarios. Its core advantages lie in robust reasoning ability and affordable charging standards, making it an ideal replacement for cost control.

Before starting configuration, users need to finish three basic preparations. First, visit the official DeepSeek open platform to complete account registration and login. Second, enter the API key management page to generate a valid access credential and ensure there is sufficient balance in the account for normal API calls. Third, confirm that Claude Code is properly installed on local Windows, macOS or Linux devices and can run stably.

According to real usage statistics, ordinary developers consume hundreds of thousands of tokens every month in daily coding work. Choosing cost-effective model services can effectively control long-term operating expenditures. Users can select different integration solutions based on their usage habits: manually editing configuration files for fixed model usage, or using the cc-switch tool for multi-model management and quick switching.

2. Method 1: Modify Configuration Files Manually

This solution is applicable to users who use DeepSeek V4 Pro as the default model for a long time and do not need frequent model switching. The operation is simple and does not rely on additional third-party tools. The whole process is divided into finding the configuration directory and writing standard configuration rules.

2.1 Locate the Configuration File

All environment parameters and service settings of Claude Code are stored in the settings.json file inside the hidden .claude folder under the user directory. The file path varies across operating systems. On Windows systems, the full path is C:\Users\Your Username\.claude\settings.json. For macOS and Linux distributions, users can find the .claude folder under the user home directory.

If the settings.json file does not exist in the target path, users can create a new file with the same name using any text editor. There is no need to launch Claude Code in advance during this process.

2.2 Edit Configuration Parameters

Open the settings.json file and write the complete JSON configuration content. Replace the placeholder content with the real API key applied from the DeepSeek platform. The standard configuration code is shown below:

json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your_deepseek_api_key",
    "ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4-flash",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro[1m]",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-pro[1m]",
    "ANTHROPIC_MODEL": "deepseek-v4-pro[1m]",
    "ANTHROPIC_REASONING_MODEL": "deepseek-v4-pro[1m]"
  }
}

Each parameter has a clear functional definition. ANTHROPIC_BASE_URL refers to the compatible API endpoint provided by DeepSeek for Anthropic-style clients, which ensures normal data interaction between Claude Code and the DeepSeek service. A series of model-related parameters realize model mapping: the Haiku, Opus and Sonnet model tags built into Claude Code are associated with DeepSeek’s lightweight and flagship models.

Among them, deepseek-v4-pro[1m] is the flagship model equipped with a 1 million token context window, which is used to handle complex reasoning and heavy coding tasks. deepseek-v4-flash is a lightweight model that focuses on fast response and low cost, suitable for simple auxiliary work.

After saving the file, restart the terminal and run the claude command. The client will automatically connect to the DeepSeek API service, and the configuration will take effect immediately.

3. Method 2: Manage Multiple Models with cc-switch

For technical teams and developers who need to switch between multiple model vendors frequently, repeatedly modifying configuration files is inefficient and prone to errors. The open-source tool cc-switch is specially developed to solve this problem. This tool natively supports centralized management of multiple model providers, which is its core built-in function. It provides a visual graphical interface, enabling users to configure, test and switch various AI service providers with one click.

3.1 Install cc-switch

Users can obtain installation packages matching different operating systems from the official GitHub repository of cc-switch. The project provides installation files for Windows, macOS and Linux. For Windows users, you can choose MSI installation packages or portable compressed packages. macOS users can use DMG or tar.gz files, while Linux users can select DEB, RPM or AppImage packages according to the system distribution.

Follow the default installation wizard to complete deployment. The latest stable version of cc-switch comes with dozens of preset configurations of mainstream model service providers, greatly reducing the difficulty of manual configuration.

3.2 Add DeepSeek Service Node

Launch the installed cc-switch client and follow the steps to create a new service node for DeepSeek V4 Pro:

  1. Click the Add Provider button on the main interface to open the configuration panel.
  2. Fill in all configuration items as required to ensure the accuracy of each parameter.
Configuration ItemContent to Fill
Provider NameDeepSeek V4 Pro
API KeyValid DeepSeek API Key
Request Endpointhttps://api.deepseek.com/anthropic
API FormatAnthropic Messages
Authentication FieldANTHROPIC_AUTH_TOKEN
Main Modeldeepseek-v4-pro[1m]
Reasoning Modeldeepseek-v4-pro[1m]
Default Haiku Modeldeepseek-v4-flash
Default Sonnet Modeldeepseek-v4-pro[1m]
Default Opus Modeldeepseek-v4-pro[1m]

Check the options of writing general configuration and enabling high-intensity reasoning, then save the settings. The tool will automatically generate standard configuration codes and complete node creation.

3.3 Connectivity Test and Service Activation

Select the newly created DeepSeek node in the provider list and click the test button. Under normal network conditions, the average response delay of the test is about 600 milliseconds. A successful connection prompt means the API link works properly. Then click the enable button to set DeepSeek V4 Pro as the default service for Claude Code.

Apart from managing multiple model vendors via cc-switch, 4sapi acts as a professional API gateway. It offers more cost-effective rates than official platforms and supports unified scheduling and invocation of diverse large models, helping teams further streamline service management and cut costs.

4. Startup Operation and Common Fault Troubleshooting

After completing the configuration via either of the two methods above, users can start using the combined workflow of Claude Code and DeepSeek V4 Pro. This section introduces the basic startup steps and solutions for the most common runtime errors.

4.1 Basic Startup Steps

Open the terminal and switch the working directory to the local project folder. Enter the command claude to launch the client. Users can run the built-in command /init to generate project rule files, or directly input coding requirements, bug repair requests and other instructions. At this time, all requests initiated by Claude Code will be forwarded to the DeepSeek model.

4.2 Troubleshoot Model Mismatch Errors

Model mismatch is the most frequent error when switching models via cc-switch. The specific performance is that the client returns a 400 error code, prompting that the requested model name is not included in the model list supported by the current API service.

The root cause is that the running Claude Code session caches the previous model information and environment variables. When the background service provider is switched, the session content is not updated synchronously, leading to model matching failure.

The standard solution is as follows: keep the current terminal session running, enter the built-in command /model, and select the newly configured DeepSeek model from the pop-up list. After confirmation, send a simple test message to verify whether the model replies normally.

To avoid such errors, it is recommended to close all existing Claude sessions before switching model providers in batches. In addition, users can press the d key after selecting the model to set it as the default option for new sessions, which simplifies repeated operations.

5. Model Usage Recommendations

DeepSeek V4 Pro and its lightweight version have clear application boundaries. Users can select corresponding models according to task types to balance performance and cost.

The deepseek-v4-pro[1m] model has a 1 million token ultra-long context window. It is the best choice for large-scale project architecture design, full repository code analysis, multi-module code refactoring and complex bug troubleshooting. For simple tasks such as single code writing, script generation and text sorting, deepseek-v4-flash is more suitable. It features faster response speed and lower token consumption, which can effectively save service costs.

Combined with the classification rules of Claude Code, users can bind different DeepSeek models to different working modes of the client to realize automatic matching of tasks and models.

6. Conclusion

Connecting DeepSeek V4 Pro with Claude Code solves the pain point of high costs brought by official API services, while retaining excellent AI coding capabilities. Users can choose different deployment schemes according to actual needs: manual configuration is suitable for scenarios with a single fixed model, while cc-switch, which supports centralized management of multiple model providers, is more suitable for users who frequently switch services.

In daily use, mastering the troubleshooting method for model mismatch errors can ensure the stable operation of the workflow. Benefiting from DeepSeek’s permanent price reduction policy, individual developers and small and medium-sized teams can use high-performance large language models at a low cost, without worrying about excessive token expenditure.

The combination of Claude Code’s powerful terminal agent capabilities and DeepSeek’s cost-effective model services builds a stable, efficient and low-cost AI development workflow. With the continuous iteration of related tools and models, this solution will be applied to more development and operation scenarios, and bring greater value to technical practitioners.

Tags:DeepSeek V4 ProClaude Codecc-switchAI CodingLLM API

Recommended reading

Explore more frontier insights and industry know-how.