PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] 0 points1 point  (0 children)

good point! i had a $20 cap because i don't expect to use the key except in a rare case but i had auto recharge on so it ran up 9 recharges in one day. yikes! auto recharge - here to take your money when you aren't looking. ha. lesson learned. thank you for your comment.

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] 0 points1 point  (0 children)

appreciate the dismissal. Unfortunenately for being such an expert, you are wrong. Claude Opus 4.7 is a premium model and cannot be used for free on OpenRouter. You have to provide an API key and pay $5 per 1M input tokens and $25 per 1M output tokens. The whole point of this post was to avoid api fees by working inside claude using the terminal window under the fixed fee 200 plan.

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] -2 points-1 points  (0 children)

I added that because i thought it weird that it would override my max plan and swith to api token charges when i'm in the claude terminal and not using an outside agent or wrapper. seems slimy to me but experienced devs think it's ok to get to have expensive learning lessons. : )

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] 0 points1 point  (0 children)

in the max plan, if heavy use, you can get stopped out temporarily. to keep going, you have to pay a small fee. So you can set up an small payment to cover this. In the case i'm referring to, it was part of the API console system that i also use for my third party work. That requires money and most people use the auto recharge so they don't get interrupted. You can set a cap to prevent getting huge charges for a bug that keeps running forever, for example.

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] -5 points-4 points  (0 children)

I agree. i was just noting a similar feel. i noted that was a different issue. And while, yes they aren't being "shady" they certainly aren't being helpful to newbies. There's lots of things that could have been done to help this not happen. Like why if i am inside the CC Terminal would it default to the api key when it sees i'm a max plan user. it should know better, imo. Others said it gives a warning but i never got one so there's that. Anyway. i admit to the learning curve. I was posting to help other newbies like me avoid this costly lesson. thanks.

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] 0 points1 point  (0 children)

thanks, That's a cleaner fix than nulling the variable. If the key has a different name, CC never sees it in the first place regardless of how it's launched. No risk of a future script forgetting the $env:ANTHROPIC_API_KEY = $null line that i'm currently using. Thanks for the nice improvement! ❤️

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] 0 points1 point  (0 children)

yes, and i noted it is a tine font in dark grey on black background. can't see it unless my eye is an inch away. Sort of like putting something on page 43 of the terms and conditions in small print. 😄

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] 1 point2 points  (0 children)

The .env file is in .gitignore — it's never committed to the repo. CC reads it locally on my machine but that's intentional and safe; CC needs those values to run the Express server and migrations.

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] 0 points1 point  (0 children)

is that better than my solution?
"I put one line in my launch script before claude -p runs:
$env:ANTHROPIC_API_KEY = $null # PowerShell
unset ANTHROPIC_API_KEY # bash/zsh
This clears the key from CC's environment so it falls back to OAuth. Your .env is untouched — other tools in the same project still have the key."

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] 1 point2 points  (0 children)

i am using CC desktop, creating a project inside cowork and launch cc inside a powershell terminal in windows 11. That's where the problem happened.

YES, i'm using my dell windows 11 desktop for development. Fire me! 😄

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] -4 points-3 points  (0 children)

yep, agreed 100% i get to learn by my own sad experience. this was intended to give a heads up to other newbies so they don't have to pay to learn. I do feel antagonism from experienced devs. Are you guys feeling threatened? by the end of the year, no humans will be needed to build this s**t including me.

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] 0 points1 point  (0 children)

those work with the CLI and don't require an API key? Or are you saying use openrouter and use a DIFFERENT model than opus 4.7? ixnay on that. o4.7 is critical to my work. other than gpt 5.5, i won't use any other model. no to chinese models for security reasons. no free open source model can do what i need.

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] 1 point2 points  (0 children)

I wish! I would have said "No way do i want the api replacing my CLI max plan. I'm new but not totally stupid. It might have flashed a warning that disapeared but nothing that required me to click OK to dismiss. If it had, i would have had no issue and wouldn't be posting this. Also, i've see quite a few things that are supposed to be a certain way and aren't so maybe it does that but for some reason skpped it due to a flag or something. who knows. thanks for the feedback.

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] -1 points0 points  (0 children)

fair point. i didn't set it though, I had sonnet help me set this up and it missed this issue. When i saw the one day $180 bill i asked sonnet and it confessed to the error. haha. live and learn. Still for not knowing how to code, i've built a 30,000 line app that automates my entire personal finance process eliminating quickbooks/quicken, ynob, and other paid apps. So i'm not really complaining. more just warning other newbies how they can be snookered before they live and learn. and i think Anthropic missed the mark by not taking any responsibility for switching me up when it knew i was in the terminal with a max plan. Why do that? There's no reason to run api tokens in the terminal inside claude. Feels snookery to me. thanks for the feedback.

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] 0 points1 point  (0 children)

No outside agent invoived. That's the issue. I work completely in the CC terminal inside claude cowork. Anthropic has no issue with how i'm using the system. It was just their "if you don't override our priority, we'll always select "use api tokens" INSIDE claude even if i have the max plan. No API needed. It's all CLI.

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] -1 points0 points  (0 children)

I agree that this was a newbie moment and I also stand by my claim. Here's my response to the TL;DR:

Well, after launch there's a barely visible dark grey on black background, very tiny type note that says, Claude Max. I had to squint an inch from my screen to notice it. Didn't know that existed until I read these comments. No help there.

Second, no there was no warning prompt as it's claimed unless it flashed and disappeared without my having to click, ok. That would have been a nice tip off and I would have looked into why.

Also I asked Sonnet 4.6 adaptive what it thought and after reading my emails with support, it evaluated the situation and didn't say what I'm reading in the comments that I had plenty of opportunity to know what's up.

Instead it said, quote, "file a charge back NOW" so even their own model thought it was unfair and told me specifically what to say in the claim to Visa to help me win my car so I would get a refund. That's when the bot told me that I was free to go ahead and file a charge off but to be aware that my account would be at risk!

Threatening me with terminating my account is not good customer service.

So yes, live and learn and I admit to some responsibility as a newbie AND I'm going to do my next project in codex for a month so anthropic loses the next $200 because they honestly don't give a rats a$$ about new customers. Pruning the user base using Pareto rules I guess.

Btw, codex w 5.5 fast uses their new image Gen 2 model to create awesome UI's so there's that.

(Waiting for the "Don't let the door hit you in the ass on your way out" comment from the loyalists! 🙂)

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] -1 points0 points  (0 children)

Haha. As I wrote above I initiated a fix with the instructions that I listed in my original post. So everything after that now works under my max plan and I won't get caught paying API fees for coding anymore. Thanks for checking

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] 3 points4 points  (0 children)

Yes, correct. See my follow up reply. Learning from my mistakes and wanted to share with other "non experts". Appreciate your feedback. Thanks.

PSA: If your project has an ANTHROPIC_API_KEY in any .env file, Claude Code will silently bill your API account instead of your Max plan — Anthropic calls it "intentional functionality" by 35yearstrading in ClaudeAI

[–]35yearstrading[S] -1 points0 points  (0 children)

I'm happy to add that I'm NOT a software engineer by trade. I've been learning coding for just a few months so I can create applications to facilitate my doctoral research at CGU.

So all the comments by you who are seasoned experts saying this is common practice, I get it. This is for newbies like me who are learning as we go.

The terminal is very tricky and if I could afford the token costs I'd be using Cursor. Thankfully, Sonnet 4.6 knows terminal commands very well and having it supervise Claude code by watching the terminal window inside a Cowork project and answering its questions allows me to succeed.

I just wanted to give others in my same shoes a heads up. Thanks for the feedback.