[GH-ISSUE #67] Claude Code with DeepSeek Anthropic-compatible API fails during project analysis: Invalid user_id #22

Open
opened 2026-10-26 09:43:47 +00:00 by bsakaguchi · 8 comments
Owner

Originally created by @Victor-ChanX on GitHub (May 6, 2026).
Original GitHub issue: https://github.com/deepseek-ai/awesome-deepseek-agent/issues/67

Description

I encountered a compatibility issue when using Claude Code with DeepSeek's Anthropic-compatible API endpoint.

Claude Code can start successfully, and it works in a clean empty directory. However, when I run it inside a real project directory and ask it to read or analyse the codebase, it starts by searching/listing files and then fails during a subsequent API request with the following error:

API Error: 400 Invalid 'user_id': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.

Environment
Tool: Claude Code
API endpoint: https://api.deepseek.com/anthropic
Model: deepseek-v4-pro[1m]
OS: macOS
Usage scenario: Claude Code project-level code analysis

My environment variables are configured as follows:

export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=sk-xxxx
export ANTHROPIC_MODEL='deepseek-v4-pro[1m]'
export ANTHROPIC_DEFAULT_OPUS_MODEL='deepseek-v4-pro[1m]'
export ANTHROPIC_DEFAULT_SONNET_MODEL='deepseek-v4-pro[1m]'
export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-v4-flash

I also previously tested with:

export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-v4-flash
export CLAUDE_CODE_EFFORT_LEVEL=max

But the issue still appears after disabling these two variables.

Steps to reproduce
Configure Claude Code to use DeepSeek's Anthropic-compatible endpoint.
Run Claude Code in a clean empty directory.
It starts successfully.
Run Claude Code inside an actual code project.
Ask Claude Code to read or analyse the project code, for example:
Please read this codebase and explain how it works.
Claude Code starts file search/listing operations.
The request then fails with:
API Error: 400 Invalid 'user_id': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'.
What I have already tried

I have tried the following:

Cleared global Claude Code configuration and cache.
Removed local project-level .claude configuration.
Removed .mcp.json and mcp-server.json.
Disabled Claude Code plugins.
Disabled MCP-related configuration.
Removed Claude Code backups and old project history.
Tested in a clean directory, where Claude Code can start successfully.
Tested again in the real project directory, where the error happens during codebase analysis.

Because the clean directory works but project-level analysis fails, it seems that the issue may be triggered by the request generated during Claude Code's tool/codebase workflow.

Expected behaviour

Claude Code should be able to continue project-level code analysis through DeepSeek's Anthropic-compatible endpoint without the Invalid user_id error.

Actual behaviour

Claude Code starts normally, performs some file search/listing operations, and then the API request fails with a 400 error:

Invalid 'user_id': string does not match pattern.
Possible cause

This may be related to how the DeepSeek Anthropic-compatible endpoint handles Claude Code requests involving tool calls, project context, session metadata, or user identification fields.

The error message mentions user_id, but I could not find any invalid user_id in my local Claude Code configuration. It is possible that some field generated by Claude Code during project analysis is being interpreted or validated as user_id by the compatibility layer.

Related reference

There is a similar Claude Code issue where invalid tool/MCP names caused a pattern validation error:

https://github.com/anthropics/claude-code/issues/858

Although my error is shown as user_id, the behaviour seems similar in that a field generated during Claude Code execution may not match the expected pattern.

Request

Could you please confirm whether DeepSeek's Anthropic-compatible API fully supports the current Claude Code request format, especially during project-level code analysis involving tool calls?

If this is a known compatibility issue, could you provide a recommended workaround, such as:

a specific Claude Code version,
a recommended DeepSeek model setting,
environment variables to disable certain Claude Code features,
or guidance on which request fields need to be sanitised?

Thank you.

Originally created by @Victor-ChanX on GitHub (May 6, 2026). Original GitHub issue: https://github.com/deepseek-ai/awesome-deepseek-agent/issues/67 ## Description I encountered a compatibility issue when using Claude Code with DeepSeek's Anthropic-compatible API endpoint. Claude Code can start successfully, and it works in a clean empty directory. However, when I run it inside a real project directory and ask it to read or analyse the codebase, it starts by searching/listing files and then fails during a subsequent API request with the following error: ```text API Error: 400 Invalid 'user_id': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'. ``` Environment Tool: Claude Code API endpoint: https://api.deepseek.com/anthropic Model: deepseek-v4-pro[1m] OS: macOS Usage scenario: Claude Code project-level code analysis My environment variables are configured as follows: export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic export ANTHROPIC_AUTH_TOKEN=sk-xxxx export ANTHROPIC_MODEL='deepseek-v4-pro[1m]' export ANTHROPIC_DEFAULT_OPUS_MODEL='deepseek-v4-pro[1m]' export ANTHROPIC_DEFAULT_SONNET_MODEL='deepseek-v4-pro[1m]' export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-v4-flash I also previously tested with: export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-v4-flash export CLAUDE_CODE_EFFORT_LEVEL=max But the issue still appears after disabling these two variables. Steps to reproduce Configure Claude Code to use DeepSeek's Anthropic-compatible endpoint. Run Claude Code in a clean empty directory. It starts successfully. Run Claude Code inside an actual code project. Ask Claude Code to read or analyse the project code, for example: Please read this codebase and explain how it works. Claude Code starts file search/listing operations. The request then fails with: API Error: 400 Invalid 'user_id': string does not match pattern. Expected a string that matches the pattern '^[a-zA-Z0-9_-]+$'. What I have already tried I have tried the following: Cleared global Claude Code configuration and cache. Removed local project-level .claude configuration. Removed .mcp.json and mcp-server.json. Disabled Claude Code plugins. Disabled MCP-related configuration. Removed Claude Code backups and old project history. Tested in a clean directory, where Claude Code can start successfully. Tested again in the real project directory, where the error happens during codebase analysis. Because the clean directory works but project-level analysis fails, it seems that the issue may be triggered by the request generated during Claude Code's tool/codebase workflow. Expected behaviour Claude Code should be able to continue project-level code analysis through DeepSeek's Anthropic-compatible endpoint without the Invalid user_id error. Actual behaviour Claude Code starts normally, performs some file search/listing operations, and then the API request fails with a 400 error: Invalid 'user_id': string does not match pattern. Possible cause This may be related to how the DeepSeek Anthropic-compatible endpoint handles Claude Code requests involving tool calls, project context, session metadata, or user identification fields. The error message mentions user_id, but I could not find any invalid user_id in my local Claude Code configuration. It is possible that some field generated by Claude Code during project analysis is being interpreted or validated as user_id by the compatibility layer. Related reference There is a similar Claude Code issue where invalid tool/MCP names caused a pattern validation error: [https://github.com/anthropics/claude-code/issues/858](https://github.com/anthropics/claude-code/issues/858?utm_source=chatgpt.com) Although my error is shown as user_id, the behaviour seems similar in that a field generated during Claude Code execution may not match the expected pattern. Request Could you please confirm whether DeepSeek's Anthropic-compatible API fully supports the current Claude Code request format, especially during project-level code analysis involving tool calls? If this is a known compatibility issue, could you provide a recommended workaround, such as: a specific Claude Code version, a recommended DeepSeek model setting, environment variables to disable certain Claude Code features, or guidance on which request fields need to be sanitised? Thank you.
Author
Owner

@Agents365-ai commented on GitHub (May 6, 2026):

check https://github.com/Agents365-ai/dsclaude
I fixed it, it worked now

<!-- gh-comment-id:4386853732 --> @Agents365-ai commented on GitHub (May 6, 2026): check https://github.com/Agents365-ai/dsclaude I fixed it, it worked now
Author
Owner

@Victor-ChanX commented on GitHub (May 6, 2026):

check https://github.com/Agents365-ai/dsclaude I fixed it, it worked now

牛逼兄弟,但是这个官方我觉得应该也要重视一下吧

<!-- gh-comment-id:4387024372 --> @Victor-ChanX commented on GitHub (May 6, 2026): > check https://github.com/Agents365-ai/dsclaude I fixed it, it worked now 牛逼兄弟,但是这个官方我觉得应该也要重视一下吧
Author
Owner

@Agents365-ai commented on GitHub (May 6, 2026):

不知道是那边更新导致的,有可能是deepseek 有可能是claude code 更新导致的不兼容的一个小问题

<!-- gh-comment-id:4387080252 --> @Agents365-ai commented on GitHub (May 6, 2026): 不知道是那边更新导致的,有可能是deepseek 有可能是claude code 更新导致的不兼容的一个小问题
Author
Owner

@Victor-ChanX commented on GitHub (May 6, 2026):

不知道是那边更新导致的,有可能是deepseek 有可能是claude code 更新导致的不兼容的一个小问题

使用dsclaude-desktop还是报错
Your provider setup needs a fix

Some required fields are missing or malformed. Open Setup to finish configuring it.

Details

用你的提供的脚本,我查看了一下仔细的报错,现在 claude code desktop 好像只只支持 claude 的自己的模型名字

<!-- gh-comment-id:4390272415 --> @Victor-ChanX commented on GitHub (May 6, 2026): > 不知道是那边更新导致的,有可能是deepseek 有可能是claude code 更新导致的不兼容的一个小问题 使用dsclaude-desktop还是报错 Your provider setup needs a fix Some required fields are missing or malformed. Open Setup to finish configuring it. Details 用你的提供的脚本,我查看了一下仔细的报错,现在 claude code desktop 好像只只支持 claude 的自己的模型名字
Author
Owner

@Agents365-ai commented on GitHub (May 7, 2026):

Image

Image 我测试这个版本还可以

<!-- gh-comment-id:4397613136 --> @Agents365-ai commented on GitHub (May 7, 2026): <img width="1195" height="785" alt="Image" src="https://github.com/user-attachments/assets/a39b121c-d643-45a3-afda-532dd8a2a231" /> <img width="288" height="303" alt="Image" src="https://github.com/user-attachments/assets/ce638bda-bc0d-4a13-9a44-e72246521f2a" /> 我测试这个版本还可以
Author
Owner

@Agents365-ai commented on GitHub (May 7, 2026):

Image

Image更新后直接挂掉

<!-- gh-comment-id:4397693569 --> @Agents365-ai commented on GitHub (May 7, 2026): <img width="774" height="634" alt="Image" src="https://github.com/user-attachments/assets/107e684c-cb96-4e3c-a20c-2e812d8cdd54" /> <img width="303" height="343" alt="Image" src="https://github.com/user-attachments/assets/7522368f-c873-4b19-b610-6219cde85eba" />更新后直接挂掉
Author
Owner

@Agents365-ai commented on GitHub (May 7, 2026):

check https://github.com/Agents365-ai/dsclaude I fixed it, it worked now

牛逼兄弟,但是这个官方我觉得应该也要重视一下吧

目前应该已经恢复了

<!-- gh-comment-id:4397786370 --> @Agents365-ai commented on GitHub (May 7, 2026): > > check https://github.com/Agents365-ai/dsclaude I fixed it, it worked now > > 牛逼兄弟,但是这个官方我觉得应该也要重视一下吧 目前应该已经恢复了
Author
Owner

@Agents365-ai commented on GitHub (May 7, 2026):

Image 可以了,dsclaude-desktop可用

<!-- gh-comment-id:4397967280 --> @Agents365-ai commented on GitHub (May 7, 2026): <img width="1181" height="789" alt="Image" src="https://github.com/user-attachments/assets/fe027263-cafe-49a1-bc59-01796487ec31" /> 可以了,dsclaude-desktop可用
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/awesome-deepseek-agent#22
No description provided.