I use my own API key in private projects, and it seems to work like this:

# .env file
ANTHROPIC_API_KEY=sk-...

In the project:

# .claude/settings.json
{
  "apiKeyHelper": "source .env && echo $ANTHROPIC_API_KEY"
}

Then invoke claude in inside the project root and verify with /status command:

Claude Code v1.0.85
  L Session ID: 69...
...
 Account
  L Auth Token: apiKeyHelper
  L API Key: apiKeyHelper

Source: https://github.com/anthropics/claude-code/issues/441#issuecomment-3207226042

If someone get this error: Error getting API key from apiKeyHelper (in settings or ~/.claude.json): /bin/sh: 1: source: not found

That error comes from the fact that your shell (likely /bin/sh) doesn’t recognize the source command — it’s a Bash built-in, not POSIX-standard.

Here's the fix (Force bash):

{ "apiKeyHelper": "bash -c 'source .env && echo $ANTHROPIC_API_KEY'" }

Never teach people to put a secret key in a non-popular env var convention file. Always put it in the popular environment variable file.

Answer from ImBIOS on Stack Overflow
🌐
Anthropic
anthropic.com › learn › build-with-claude
Anthropic Academy: Claude API Development Guide
Set up your developer account and generate API keys on the Anthropic Console. Use our quickstart guide to make your first API call · Get started with Claude Code with npm install -g @anthropic-ai/claude-code
🌐
Claude
claude.com › product › claude-code
Claude Code - AI coding agent for terminal & IDE | Claude
⏺ Now I'll fix the issue by updating the route.ts file to remove unused fileData code since the frontend constructs the messages for the API: ... ⏺ Great, there are no more instances of fileData in the route.ts file. Now let's run the lint check to ensure our changes don't cause any issues: ... ⏺ Bash(cd /Users/user/code/anthropic-quickstarts/financial-data-analyst && git commit -m "Fix unused fileData code in finance API route …
🌐
Anthropic
anthropic.com › news › claude-3-7-sonnet
Claude 3.7 Sonnet and Claude Code
API users also have fine-grained control over how long the model can think for. Claude 3.7 Sonnet shows particularly strong improvements in coding and front-end web development. Along with the model, we’re also introducing a command line tool for agentic coding, Claude Code.
🌐
Anthropic
docs.anthropic.com › en › docs › claude-code › sdk
Overview - Claude Docs
Code review agents that enforce style and best practices Business agents: Legal assistants that review contracts and compliance · Finance advisors that analyze reports and forecasts · Customer support agents that resolve technical issues ... For basic authentication, retrieve an Claude API key from the Claude Console and set the ANTHROPIC...
🌐
Claude
claude.com › platform › api
Claude Developer Platform | Claude
Run Python code, create visualizations, and analyze data directly within API calls.
🌐
Anthropic Courses
anthropic.skilljar.com › claude-with-the-anthropic-api
Building with the Claude API - Anthropic Courses
Implement prompt caching strategies to optimize API usage and reduce latency · Develop Model Context Protocol (MCP) servers and clients for standardized tool and resource integration · Deploy Anthropic Apps including Claude Code for automated development tasks and Computer Use for UI automation
Find elsewhere
🌐
AWS
docs.aws.amazon.com › amazon bedrock › user guide › amazon bedrock foundation model information › inference request parameters and response fields for foundation models › anthropic claude models › anthropic claude messages api
Anthropic Claude Messages API - Amazon Bedrock
This topic shows how to use the Anthropic Claude messages API with the base inference operations (InvokeModel or InvokeModelWithResponseStream). However, we recommend that you use the Converse API to implement messages in your application. The Converse API provides a unified set of parameters that work across all models that support messages.
🌐
Anthropic
anthropic.com › news › claude-opus-4-5
Anthropic
If you’re a developer, simply use claude-opus-4-5-20251101 via the Claude API. Pricing is now $5/$25 per million tokens—making Opus-level capabilities accessible to even more users, teams, and enterprises. Alongside Opus, we’re releasing updates to the Claude Developer Platform, Claude ...
🌐
Anthropic
anthropic.com › engineering › claude-code-best-practices
Claude Code: Best practices for agentic coding
Simply ask questions, and Claude will explore the code to find answers. Claude can effectively handle many git operations. Many Anthropic engineers use Claude for 90%+ of our git interactions: Searching git history to answer questions like "What changes made it into v1.2.3?", "Who owns this ...
🌐
Claude Docs
docs.claude.com
Documentation - Claude Docs
Integrate and scale using our API and SDKs. ... Craft and test powerful prompts directly in your browser. ... Learn about changes and new features in the Claude Developer Platform. ... Get started with Claude Code. ... Consult the Claude Code reference documentation for details on feature implementation and configuration. ... Learn about changes and new features in Claude Code. ... Explore Anthropic's educational courses and projects.
🌐
npm
npmjs.com › package › @anthropic-ai › claude-code
anthropic-ai/claude-code
Use Claude, Anthropic's AI assistant, right from your terminal. Claude can understand your codebase, edit files, run terminal commands, and handle entire workflows for you.. Latest version: 2.0.76, last published: 20 hours ago.
      » npm install @anthropic-ai/claude-code
    
Published   Dec 22, 2025
Version   2.0.76
Author   Anthropic
🌐
Reddit
reddit.com › r/claudeai › claude code with api key?
r/ClaudeAI on Reddit: Claude Code with API key?
April 11, 2025 -

I'm a bit confused about how claude code work for payment. I've been logging in with my personal account and paying for credits but now I have an API key from my employer which I'd like to use. I also have a Claude Desktop subscription from my employer, but when I log in with that for Claude Code I'm still prompted to pay for my own credits and I don't see how to enter my API key.

I must be misunderstanding something - does anyone have any tips?