[BUG] Use API key over the Claude Code Max Plan when API config is set to false in headless mode

Resolved 💬 4 comments Opened Mar 13, 2026 by zazabap Closed Apr 11, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

I double checked how the claude code is working for API usage and found something surprised me. Currently I login with my own claude account and trying to implement experiment with my own claude code max plan. Inside the claude code status, I setup use custom API key as false. However, when I tried to run the command using headless mode with -p, claude-code CLI tool prioritize the usage of API key even I setup custom API usage to false.

What Should Happen?

When config status for custom API key usage is setup as false, even with -p using claude code outside, it should follow the config prioritize using the Claude Max plan instead of API key.

Error Messages/Logs

Steps to Reproduce

  1. Create an account using Claude Max.
  2. Setup an API key in the environment.
  3. Setup the config status to false.
  4. Run the Claude code with -p option to see whether the command is using API instead of Claude Max Subscription.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.74

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Cursor

Additional Information

<img width="1010" height="284" alt="Image" src="https://github.com/user-attachments/assets/476aba2f-f8e1-4903-b351-7cdacb1b9cf5" />
<img width="675" height="285" alt="Image" src="https://github.com/user-attachments/assets/d7854f1a-8a6a-4295-9cfb-1452390d57dc" />
<img width="799" height="636" alt="Image" src="https://github.com/user-attachments/assets/041c719a-a8e7-454f-aa1c-87bd6c56628e" />

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗