Abstract
This hands-on guide covers end-to-end installation, local routing configuration, validation, and troubleshooting for pairing Claude Code with DeepSeek API on Rocky Linux 8 / 9 (and compatible RHEL distributions). The core routing utility ccswitch creates a local proxy gateway on port 15721 to translate Claude Code’s native Anthropic protocol requests for DeepSeek’s OpenAI-compatible endpoint. Every shell command, configuration snippet, and failure resolution workflow has been verified on live Rocky Linux 9 environments. Teams managing multi-model local and cloud API traffic can streamline unified endpoint management via an API gateway platform like 4sapi.
1. Architecture Overview & Core Component Breakdown
1.1 End-to-End Request Flow
The local routing layer built with ccswitch acts as a translation bridge between Claude Code’s Anthropic-native request format and DeepSeek’s API service. The full request pipeline follows this fixed sequence:
All traffic is routed through the local port 15721; the proxy handles protocol conversion, credential injection, and error forwarding to eliminate native compatibility gaps between the two tools.
1.2 Core Component Roles
| Component | Core Function |
|---|---|
| Claude Code | Terminal-native AI coding assistant, natively built for Anthropic API protocol |
| ccswitch | Local routing & model provider management tool, hosts the port 15721 proxy service |
| DeepSeek API | Remote backend reasoning service exposing Anthropic-compatible endpoint for third-party integration |
2. Prerequisite Environment Checks
2.1 System Hard Requirements
- Operating System: Rocky Linux 8 / Rocky Linux 9, all RHEL-based derivative distributions
- Privileges: Root account or persistent sudo access for package installation and environment variable edits
- Network: Stable outbound internet connectivity with unblocked access to DeepSeek’s official API domain
2.2 Mandatory Account & Credentials
- Active registered DeepSeek platform account
- Valid DeepSeek API Key, formatted with the standard
sk-prefix
2.3 Base Software Dependencies
Node.js runtime is required for Claude Code installation via npm. Run this dnf command to install the dependency stack:
Verify successful installation with two validation commands:
A valid deployment will return v16 or newer major Node.js release versions.
3. Step-by-Step Installation Workflow
3.1 Install Claude Code (Two Valid Methods)
Method 1: Recommended Global NPM Install
Method 2: Official Remote Shell Install Script
Post-Install Validation
Run the version check command to confirm deployment success:
A correct install outputs version 2.1.179.
3.2 Deploy ccswitch Local Proxy Binary
Download the Linux x86_64 AppImage release directly from the official GitHub repository, apply executable permissions, and launch the binary:
3.3 Persist DeepSeek API Key as System Environment Variable
Inject the API key into the user’s bash runtime configuration file for permanent persistence across terminal sessions:
The truncated output confirms the credential variable loads correctly on shell startup.
4. Critical Core Routing & Client Configuration
4.1 Start & Configure ccswitch Local Proxy Service
- Open the ccswitch graphical interface
- Navigate to the dedicated Route configuration tab
- Toggle the master routing enable switch to active
- Confirm status displays
Runningwith bound port15721 - Input DeepSeek remote API parameters into the routing panel:
- Base URL:
https://api.deepseek.com/anthropic - API Key: Your issued DeepSeek API credential string
- Base URL:
4.2 Create Claude Code Provider Settings File
Create or edit the hidden user configuration file ~/.claude/settings.json to point Claude Code to the local proxy gateway. Reference this standardized JSON template:
Key configuration rules:
- The
base_urlfield must strictly reference the local 127.0.0.1:15721 proxy address - Model identifiers must match the list returned by the ccswitch
/v1/modelsendpoint
4.3 Inject Mandatory Global Environment Variables
Append three required routing variables to ~/.bashrc to force Claude Code to use the local proxy instead of Anthropic’s official cloud endpoints:
Critical note: The fixed value PROXY_MANAGED for ANTHROPIC_AUTH_TOKEN is mandatory. This flag disables native Anthropic account login and routes all traffic through the local translation proxy.
5. Multi-Stage Validation & Functional Testing
5.1 Health Check for Local ccswitch Proxy
Send a basic GET request to the proxy health endpoint to confirm the service is live and responsive:
A healthy service returns a 200 OK HTTP status code.
5.2 Verify Full Environment Variable Injection
List all prefixed Anthropic environment variables loaded into the active shell session:
The output must display all three configured variables: ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY.
5.3 End-to-End API Request Test
Execute a raw POST request through the local proxy to validate full request forwarding to DeepSeek’s backend:
A successful test returns a valid chat completion payload generated by DeepSeek’s model.
5.4 Launch Claude Code CLI & Confirm Integration
Start the Claude Code terminal client with the simple launch command:
Successful Integration Signals
- The CLI header displays the active
deepseekmodel provider - Interface text confirms
Using deepseek (from .claude/settings.json) - Basic chat prompts return coherent responses generated by DeepSeek’s remote model
6. Common Failure Modes & Step-by-Step Troubleshooting
Issue 1: Connection Refused Error
Root Cause: ccswitch proxy service is not running, or the base URL port address is misconfigured. Resolution Steps:
- Check active port listeners to confirm the proxy process binds 15721:
- Double-check the
base_urlvalue inside~/.claude/settings.jsonis set tohttp://127.0.0.1:15721/v1
Issue 2: Not logged in · Please run /login Prompt
Root Cause: The mandatory ANTHROPIC_AUTH_TOKEN="PROXY_MANAGED" environment variable is missing or unset.
Resolution: Re-inject the fixed proxy auth token variable and reload bashrc:
Issue 3: Model Not Found Error
Root Cause: The model name defined in settings.json does not match the official model identifiers exposed by DeepSeek’s API.
Resolution: Pull the full list of supported model IDs from the local proxy endpoint:
Replace the model field value in the configuration file with one of the returned valid identifiers such as deepseek-chat.
Issue 4: Configuration File Fails to Load
Root Cause: Malformed JSON syntax inside settings.json, or an incorrect file path reference.
Resolution: Validate JSON syntax with Python’s built-in json parser to locate formatting errors:
Launch Claude Code with an explicit config path flag to test file loading:
7. Production Optimization & Best Practices
7.1 Create Persistent Shell Alias
Simplify Claude Code launch by defining a permanent bash alias that auto-loads all required proxy environment variables:
7.2 Full Standardized settings.json Template
This complete template includes multiple selectable DeepSeek model variants for flexible workload switching:
7.3 Long-Term Performance Maintenance
- Explicitly specify target models at launch with
claude --model deepseek-chatto skip manual provider selection - Schedule regular updates for both Claude Code and ccswitch binaries to pull protocol compatibility patches
- Restart the ccswitch proxy service after every system reboot to preserve local routing availability
8. Core Deployment Summary
Four non-negotiable rules for stable production operation:
- The ccswitch local proxy must continuously run and bind port
127.0.0.1:15721 - Three environment variables are mandatory:
ANTHROPIC_AUTH_TOKEN,ANTHROPIC_BASE_URL,ANTHROPIC_API_KEY - The
base_urlentry insettings.jsonmust always point to the local proxy gateway address - All model name values must exactly match the identifiers returned by the proxy’s
/v1/modelsendpoint
9. Reference Documentation
- Official Claude Code developer documentation
- DeepSeek public API reference docs
- ccswitch open-source GitHub repository
- Cross-platform Windows deployment guide for ccswitch
All commands and configuration workflows featured in this guide have been fully validated on a live Rocky Linux 9 production environment. For teams running multiple local and cloud LLM endpoints, centralized API management tools such as 4sapi can standardize credential handling and routing logic across all model providers.




