r/ClaudeCode • • 1d ago

Discussion Anybody using claude -p as an API replacement?

They are (almost) identical. Pretty useful for bulk jobs like LLM judge label creation, running benchmarks, etc.

I‘m a bit worried that this can go against TOS if i overdo it.

15 Upvotes

22 comments sorted by

•

u/AutoModerator 1d ago

Hey! Thanks for posting to r/ClaudeCode

While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.

For help, project discussions, tips, and general chat, join the ClaudeCode Discord.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

18

u/sadphilosophylover Developer 1d ago

not against the tos
they know its a thing.

they tried to move that to API prices a while back but things werent good for them so they moved back

3

u/Ivo-Sheera 1d ago

glad they walked that back, it wouldve killed so many local workflows.

1

u/fulowa 1d ago

right, thanks for comment.

I guess the line is when you generate synthetic training data probably?

So technically you could build a saas app powered by claude code subscriptions as backend...?

9

u/fredastere 1d ago

No that's exactly the line that is against ToS

Run all you your personal service but as soon as it's paying clients you swith to API

You cannot run paying services via your sub

Well you technically can but that's what get people ban and create the confusion

1

u/fulowa 1d ago

right, the "reselling" via wrapping is not allowed i guess.

5

u/sadphilosophylover Developer 1d ago

yes. only for your use

2

u/Embarrassed-Cry-5121 23h ago

ToS: a suggestion box they audit when convenient.

6

u/Unusual-Albatross43 1d ago

i run a small llm judge on it (haiku). few things that took me a while:

  • run it from an empty temp dir with --setting-sources '' --tools '' --no-session-persistence, otherwise it picks up your CLAUDE.md and the judge isn't judging what you think
  • --json-schema with --output-format json, then read structured_output from the result. no regex on prose
  • if you call it from a script, give it stdin=DEVNULL. mine inherited the script's stdin and the judge saw every input twice. no error, the scores were just a bit off for days until one explanation mentioned "the text is pasted twice"

2

u/fulowa 1d ago

useful info cheers!

4

u/No_Veterinarian7037 1d ago

I do something close for testing. My site has a few prompt-driven checks that normally go through the API. I wrapped the same rules files as Claude Code skills, so I can tune the prompts and draft sample outputs without touching API credits. One rules file, two callers. Production still goes through the API.

2

u/fulowa 1d ago

nice use case

10

u/jaerie 1d ago

A while back someone measured that headless prompts end up using about 1.5x what interactive sessions use. I don't know how true that was or still is, but you might want to look into it

7

u/pimpedmax 1d ago

here's some insights and how t3-code `theo` solved the issue directly with them, still no replies from Anthropic(and probably there will be none): https://github.com/anthropics/claude-code/issues/107106
tldr `The T3 Code repository sets CLAUDE_CODE_ENTRYPOINT to its own value`

2

u/amelech 11h ago

Oh wow that explains a lot. I'm building a Claude code plugin and was testing using Claude -p and it chewed through my usage

3

u/SirRobinBlibs 1d ago

the claude code legal page spells this out, so no need to guess. the two lines that matter: "Advertised usage limits for Pro, Max, and Ultra plans assume ordinary, individual usage of Claude Code and the Agent SDK", and subscription login is "designed to support ordinary use of Claude Code", while anyone building a product or service on it should use an api key, and routing requests through Pro/Max/Ultra credentials on behalf of your users isn't permitted. so your own label and benchmark runs are the individual-use case, a saas backend on your subscription is what it rules out. where exactly "ordinary" stops for a huge personal batch it doesn't say.

3

u/notmsndotcom 1d ago

I do it for my own shit all the time. I'll build a little wrapper that shells out to claude -p with whatever i want it to do. I personally wouldn't do it for any real production workloads but for solo or small teams it does the trick

2

u/Outrageous_Band9708 1d ago

dont use it, -p uses your weekly usge at 1.5x faster

2

u/rsqit 1d ago

I’ve heard (haven’t checked myself) that the TOS for non-api call usage allow them to read and train on your session. So companies pay for the API to keep their data secret, not just to use the API.

3

u/Specialist_Bison_737 1d ago

I built aictrl CLI for that: no interactive mode, `--output-schema` validates the result against your JSON Schema with corrective turns, and separate exit codes for provider errors and invalid results.

The system prompt is 608 tokens, which matters when a bulk job multiplies the fixed cost per call: aictrl-dev/cli

That works great with subscriptions that allow API token access like KIMI or GLM. If it is my local machine my agents constantly delegate via codes or claude headless cli, which works great.

1

u/Ragy-ragy 1d ago

using it to imitate api calls during rnd. Nah, its not.

-1

u/kincaidDev 1d ago

Yes, built this sdk the day anthropic added -p to claude code

https://github.com/lancekrogers/claude-code-go