What you'll build
You'll create a chatbot using Claude's API from Anthropic, the same process as Gemini but with a different provider. It requires a credit card to register, but you get $5 USD free credit to start. When you're done, you'll have another chatbot running in your terminal, this time connected to Claude. You'll learn to work with multiple AI providers, a key skill for choosing the best tool for each project.
Step 1: Get your Anthropic API Key
- Go to console.anthropic.com
- Create an account or sign in
- Go to API Keys โ Create Key
- Copy the key
Step 2: Ask an AI to write the code
Open Google AI Studio, ChatGPT, or any AI chat.
Copy and paste this prompt:
I need a simple Node.js chatbot that:
- Uses the Claude API (Anthropic)
- Works in the terminal
- Maintains conversation history
- Reads the API key from the ANTHROPIC_API_KEY environment variable
Give me the complete code and installation commands.
The AI will write all the code for you.
Step 3: Configure the key in your system
| System | Command |
|---|---|
| macOS/Linux | export ANTHROPIC_API_KEY="your-key-here" |
| Windows PowerShell | $env:ANTHROPIC_API_KEY="your-key-here" |
Step 4: Follow the instructions
The AI gave you:
- Commands to create the project
- Code for the file
- The command to run it
Follow its instructions step by step.
Did it work?
You: Hello Claude
Claude: Hello! How can I help you today?
If something failed
| Error | Cause | Solution |
|---|---|---|
authentication_error | Invalid API key | Check at console.anthropic.com |
insufficient_quota | No credits | Add payment method in console |
Cannot find module | Missing SDK | Run npm install @anthropic-ai/sdk |
rate_limit_error | Too many requests | Wait a few seconds |
What did you learn?
The process is identical to Gemini:
- You ask an AI for code
- You configure the API key
- You run it
The only difference is the API you use. The workflow is the same.
Next step
โ Chatbot with OpenAI โ Complete the trio
Want to understand more?
โ What is an LLM?