AI Isn’t Magic - You Need to Be Clear

Many people try Claude, ChatGPT, or other Large Language Models (LLMs) for the first time expecting the AI to understand everything perfectly from just a few casual words. Then reality hits: the responses are often off-target, either rambling without getting to the point, or too brief to be useful, sometimes completely missing the mark.

Where’s the problem? It’s not that AI is bad - it’s how we’re talking to it.

Think about it this way: a brilliant new colleague joins your team, but they know nothing about your project. If you just say “hey, fix that thing for me,” will they understand? Of course not. You need to tell them what to fix, how to fix it, and what the result should look like. The clearer you are, the better they perform. Same goes for AI - and that’s what prompt engineering is all about: mastering AI communication.

How to Use Claude API: Three Required Fields

Claude API Three Required Parameters

Using the Claude API is like filling out a delivery form - certain fields are mandatory, or your order won’t go through.

First up is model - which model do you want working on your task? The Claude family has several models, just like hiring someone means specifying who you need. claude-sonnet-4 offers the best value for most tasks; claude-opus-4 is the premium option for complex work but costs more; claude-haiku is fast and cheap, perfect for simple tasks. For most cases, sonnet does the job:

model="claude-sonnet-4-20250514"

Second is max_tokens - the maximum length of AI’s response. Note this is a ceiling, not a target. It’s like telling a colleague “keep the report under 2000 words” - they might wrap up in 500, or they might hit 2000 and get cut off mid-sentence. Don’t set this too low:

max_tokens=2000

Third is messages - your conversation history. This is the crucial part. You need to provide Claude with the full context of your conversation. The format is simple: a list where each message contains who said it (role) and what they said (content):

messages=[
    {"role": "user", "content": "What color is the ocean?"}
]

Conversations Need Back-and-Forth

User and Assistant Alternating Pattern

Claude API has a rule: user and assistant must take turns, and the user always speaks first. It’s like making a phone call - when someone picks up, you say “hello” first. You don’t call and wait silently for them to speak.

Here’s the correct conversation flow:

messages=[
    {"role": "user", "content": "Hello"},
    {"role": "assistant", "content": "Hello! How can I help you?"},
    {"role": "user", "content": "Can you explain what recursion is?"}
]

If you send two user messages in a row, the API throws an error:

# This will fail!
messages=[
    {"role": "user", "content": "Hello"},
    {"role": "user", "content": "Also check this out"}  # Can't send consecutively
]

Why this restriction? Claude was trained on conversational patterns - it expects a back-and-forth rhythm. Break that rhythm, and it gets confused.

System Prompt: Setting AI’s Character

System Prompt Persona Configuration

Beyond regular conversation, there’s a powerful tool called System Prompt. Its job is to establish Claude’s persona or rules before the conversation begins. Think of it like giving a new employee their handbook on day one - explaining company policies and their job responsibilities.

system="You are a professional Python developer. When answering questions, provide code examples and explain in plain English."

With this in place, Claude remembers these instructions throughout the entire conversation. Here’s a fun example:

system = "Your answers must be a series of thought-provoking questions. Never give direct answers."
prompt = "Why is the sky blue?"

# Claude might respond:
# Did you know sunlight is actually made up of many different colors?
# What happens when sunlight passes through the atmosphere?
# Why do shorter wavelength blue light rays scatter more easily?

System Prompts are perfect for setting output formats (like “respond in JSON”), defining tone (like “use a casual, friendly voice”), establishing expertise (like “you’re a backend engineer with 10 years of experience”), or setting constraints.

Complete Code: Putting It All Together

After all that explanation, here’s a complete example:

import anthropic

client = anthropic.Anthropic(api_key="your-api-key")

message = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=2000,
    system="You are a patient programming mentor who excels at explaining technical concepts using everyday examples.",
    messages=[
        {"role": "user", "content": "What is an API? Can you explain it in simple terms?"}
    ]
)

print(message.content[0].text)

Just a few lines of code, and you’re chatting with Claude.

Try It Yourself

Reading without practice gets you nowhere. Here are two quick exercises:

Exercise 1: Get Claude to count from 1 to 3. Write a prompt that makes Claude output content containing 1, 2, and 3. Hint: just ask directly - don’t overthink it.

Exercise 2: Make Claude respond like a 3-year-old. Write a System Prompt that makes Claude act like a toddler, then ask “How big is the sky?” and see what happens. Hint: think about how 3-year-olds talk - innocent, using simple words, often saying unexpectedly funny things.

Wrapping Up

Prompt engineering sounds fancy, but it’s really just the art of communicating with AI effectively. Master the basics we covered today, and the rest is iteration - experimenting, refining, and learning from results. It’s like cooking: first you learn to turn on the stove, add oil, and toss in ingredients. Only then can you start perfecting timing, seasoning, and presentation.

This is just lesson one. There’s much more ahead: formatting outputs, handling complex tasks, getting AI to honestly say “I don’t know” instead of making things up… We’ll take it step by step.


If this was helpful, give it a like so more people can find it. If you have friends who use AI daily but struggle to get satisfying answers, share this with them - it’s not that AI is broken, it’s that communication can be optimized.

Follow Dream Beast Programming for more advanced prompt engineering techniques. Let’s master this AI tool together.

Got questions or tips of your own? Drop them in the comments.