How to Set Up Your First Claude API Call
Step-by-step guide to making your first API call to Anthropic Claude with Python.
Jay Banlasan
The AI Systems Guy
This Claude API setup tutorial is the starting point for every automation I build. If you are a beginner looking to connect AI to your business, this is where you start. Four things: an API key, Python, one library, and 10 lines of code.
I use Claude as the backbone of every system I run. Client reports, ad creative generation, data analysis, content pipelines. It all starts with this exact setup.
What You Need Before Starting
- A computer with Python 3.8 or higher installed
- An Anthropic account (sign up at anthropic.com)
- A credit card on file for API usage (you will not be charged until you make calls)
- A text editor or IDE (VS Code works fine)
Step 1: Get Your API Key
Log into the Anthropic Console. Go to API Keys in the left sidebar. Click "Create Key." Name it something you will recognize later, like "my-first-project."
Copy the key immediately. You will not see it again after you close the modal. Store it somewhere safe. I keep mine in an .env file that never touches version control.
Step 2: Install the SDK
Open your terminal and run:
pip install anthropic
That installs the official Python SDK. It handles authentication, retries, and response parsing so you do not have to.
Step 3: Set Your API Key
The cleanest approach is an environment variable. Create a file called .env in your project folder:
ANTHROPIC_API_KEY=sk-ant-your-key-here
Then install python-dotenv to load it:
pip install python-dotenv
Step 4: Write Your First Call
Create a file called first_call.py:
import anthropic
from dotenv import load_dotenv
load_dotenv()
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
messages=[
{"role": "user", "content": "What are three ways AI can help a small business save time?"}
]
)
print(message.content[0].text)
Run it:
python first_call.py
You should see Claude respond with three practical suggestions. That is your first successful API call.
Step 5: Understand the Response
The client.messages.create() call sends your prompt to Claude and returns a structured response. Here is what each parameter does:
- model: Which Claude model to use. Sonnet is fast and cheap. Opus is the most capable.
- max_tokens: The maximum length of Claude's response. 1024 tokens is roughly 750 words.
- messages: The conversation history. Each message has a role ("user" or "assistant") and content.
The response object contains content, which is a list of content blocks. For text responses, content[0].text gives you the raw string.
Step 6: Add a System Prompt
System prompts tell Claude how to behave. This is where you define its role, tone, and constraints:
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
system="You are a business automation consultant. Give specific, actionable advice. No fluff.",
messages=[
{"role": "user", "content": "How should I automate my invoice process?"}
]
)
The system prompt is the single most important parameter for getting useful output. Be specific about what you want and what you do not want.
What to Build Next
Now that you have a working API call, you can build on this foundation:
- Batch processing: Loop through a list of inputs and process them all
- File handling: Read a CSV, process each row with Claude, write results back
- Conversational flows: Pass multiple messages to simulate a back-and-forth conversation
- Tool use: Let Claude call functions you define, like querying a database or sending an email
Every automation I run started exactly here. One API call. One response. Then layering complexity on top of a foundation that works.
Related Reading
- AI in Paid Advertising: The Complete Overview - how AI operations power ad accounts at scale
- Why AI Operations, Not AI Tools - the philosophy behind building systems instead of collecting tools
- The Automation Decision Tree - how to decide what to automate first
Want this system built for your business?
Get a free assessment. We will map every system your business needs and show you the ROI.
Get Your Free Assessment