Skip to main content

Command Palette

Search for a command to run...

Setting up Claude-Code with API Key

Updated
1 min read
P

I am a full-stack Ruby on Rails developer with experience in PostgreSQL, Docker, Heroku, and performance optimization. I love exploring new technology stacks and have recently developed an interest in mobile app development using Flutter. My skills in test-driven development and fixing security vulnerabilities have helped me deliver high-quality, reliable code. I am also currently learning about machine learning and its applications in real-world problem-solving. I bring a unique combination of technical expertise, creative problem-solving, and a passion for learning to any team. I am committed to delivering elegant and efficient software solutions and excited to contribute to an innovative and dynamic team that shares this vision.

As of the writing of this blog post, there was no straight forward way to use API key with Claude code.

I found following way

I have figured out following way, but not sure if they will change something in future which will break this, by the time you read this article.

But anyways, here is the simple steps:

  1. Open ~/.claude/settings.json file in your editor and put following code:

cat ~/.claude/settings.json

{
  "apiKeyHelper": "~/.claude/anthropic_key.sh"
}
  1. Now create that shell script file, and open in your code editor e.g: vi ~/.claude/anthropic_key.sh and put following content in it, replace with your correct API key here.
echo "sk_your_anthropic_api_key"
  1. Make the shell script executable
sudo chmod +x ~/.claude/anthropic_key.sh

That’s it, now if you run claude it should confirm with you do you really want to API key, you should say yes or choose the option that says yes

Enjoy!!