Claude API for Beginners: Your First Call, Key and Script
Learn how to use the Claude API in Python or Node, from getting an API key to a script that calls Claude.
- Claude API
- 7 days
- beginner
- 7 lessons
- about 3 hours
Free and self-paced. Every lesson is open to everyone.
Start with lesson 1What you will do
For people who can run a short Python or Node script but have never called an AI model from code. In seven days you set up a Claude Console account, keep your key out of your code, send your first request, pick a model, hold a conversation, stream replies and keep costs and limits in check. You end with a script that drafts a friendly reply to a customer review. The API is pay as you go with credits in the Claude Console.
How this course works
The course is free and you go at your own pace. Each lesson is short: a bit of reading and a few small tasks you do in the tool itself, so you learn by using it. Every lesson is open to everyone, no account needed. A free account saves your progress, so you can pick up where you left off on any device. What the account stores and how to get it removed is on the privacy page.
Syllabus
- Day 1, 20 minutes How to create a Claude API account and API key Create a Claude Console account, add credits and make a Claude API key with an expiry date that you store somewhere safe.
- Day 2, 25 minutes How to keep your Claude API key safe in a .env file Store your Claude API key in an environment variable and a .env file that git ignores, and know what to do if it leaks.
- Day 3, 25 minutes How to make your first Claude API call in Python or Node Send your first Claude API request from a Python or Node script and read the reply, the stop reason and the token usage.
- Day 4, 25 minutes How to choose a Claude API model: reply, speed and cost Compare two Claude models on the same task by reply, speed and cost, then pick the model ID your API script will use.
- Day 5, 25 minutes How to use a system prompt and keep a conversation in the Claude API Set the tone of every Claude reply with a system prompt and hold a conversation by sending the full message history each time.
- Day 6, 25 minutes How to stream Claude API responses and read the stop reason Stream a Claude reply word by word, read the events of a stream, and spot a reply that max_tokens cut off.
- Day 7, 30 minutes Claude API pricing, rate limits and a review reply script Read Claude API usage and pricing, set a spend limit, handle rate limit errors and run a script that drafts a review reply.