VOOZH about

URL: https://dev.to/liandanxiaai/how-to-use-deepseek-in-claude-code-and-opencode-db7

⇱ How to Use DeepSeek in Claude Code and OpenCode - DEV Community


How to Use Liandanxia DeepSeek Models in Claude Code and OpenCode

This guide explains how to connect Liandanxia's DeepSeek models to Claude Code and OpenCode.

Step 1: Register a Liandanxia Account and Create an API Key

First, sign up for a Liandanxia account and create an API key from your account dashboard.

Keep your API key secure. It should look similar to:

sk-your_api_key

Step 2: Install Claude Code or OpenCode

You can use Liandanxia models with either Claude Code or OpenCode.


Claude Code

Install Claude Code on Windows

Open a cmd window and run:

curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

Wait for the installation to complete.

Configure Environment Variables

Claude Code can be pointed to Liandanxia's API endpoint by setting the following environment variables.

Windows CMD

setx ANTHROPIC_BASE_URL "https://api.liandanxia.io"
setx ANTHROPIC_AUTH_TOKEN "sk-your_api_key"
setx ANTHROPIC_MODEL "deepseek-v4-pro"

After running these commands, close the current terminal window and open a new one for the changes to take effect.

Then start Claude Code:

claude

macOS / Linux / Git Bash

export ANTHROPIC_BASE_URL="https://api.liandanxia.io"
export ANTHROPIC_AUTH_TOKEN="sk-your_api_key"
export ANTHROPIC_MODEL="deepseek-v4-pro"

Then run:

claude

Claude Code should now use the Liandanxia DeepSeek model.


OpenCode

Install OpenCode

On macOS, Linux, WSL, or Git Bash, run:

curl -fsSL https://opencode.ai/install | bash

If you are using Windows CMD, consider running this command inside Git Bash or WSL.

Configure OpenCode

OpenCode uses the provider config key, not providers.

Create or update an opencode.json file in your project root:

{"$schema":"https://opencode.ai/config.json","model":"ldx/deepseek-v4-pro","provider":{"ldx":{"npm":"@ai-sdk/openai-compatible","name":"LDX","options":{"baseURL":"https://api.liandanxia.io/v1","apiKey":"sk-your_api_key"},"models":{"deepseek-v4-pro":{},"deepseek-v4-flash":{}}}}}

After saving the file, run OpenCode from your project directory:

opencode

Recommended: Use an Environment Variable for Your API Key

To avoid storing your API key directly in your project configuration, use an environment variable instead.

macOS / Linux / Git Bash

export LDX_API_KEY="sk-your_api_key"

Windows CMD

setx LDX_API_KEY "sk-your_api_key"

After using setx, restart your terminal.

Then update your opencode.json file:

{"$schema":"https://opencode.ai/config.json","model":"ldx/deepseek-v4-pro","provider":{"ldx":{"npm":"@ai-sdk/openai-compatible","name":"LDX","options":{"baseURL":"https://api.liandanxia.io/v1","apiKey":"{env:LDX_API_KEY}"},"models":{"deepseek-v4-pro":{},"deepseek-v4-flash":{}}}}}

Now OpenCode will read your Liandanxia API key from the LDX_API_KEY environment variable.


Model Options

You can switch models by changing the model field in opencode.json.

For example:

"model":"ldx/deepseek-v4-pro"

or:

"model":"ldx/deepseek-v4-flash"

Use deepseek-v4-pro when you need stronger reasoning and higher-quality coding performance. Use deepseek-v4-flash when you want faster responses and lower cost.


Summary

Claude Code configuration:

ANTHROPIC_BASE_URL=https://api.liandanxia.io
ANTHROPIC_AUTH_TOKEN=sk-your_api_key
ANTHROPIC_MODEL=deepseek-v4-pro

OpenCode configuration:

{"model":"ldx/deepseek-v4-pro","provider":{"ldx":{"npm":"@ai-sdk/openai-compatible","options":{"baseURL":"https://api.liandanxia.io/v1","apiKey":"{env:LDX_API_KEY}"},"models":{"deepseek-v4-pro":{},"deepseek-v4-flash":{}}}}}

Once configured, you can use Liandanxia's DeepSeek models directly inside Claude Code or OpenCode.