Skip to content
AgenticAIWiki
  1. Learn
  2. Part 0
  3. 0. Your first agent in 15 minutes
  4. 0.1

Lesson 0.1 · 1 of 5 · 5 min read · Reviewed 24 Nov 2026

Make your first call in the Playground

By the end, you can

  • Send a request to a model and read the reply, the stop reason and the token usage.
  • Explain why the Playground needs no real API key.

You will have a working agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done. by the end of this chapter. It starts with one request.

The idea

Every interaction with a model through an API is a request and a reply. Open the Playground project Your first message and press Run. The code does this:

import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic(); // reads ANTHROPIC_API_KEY

const message = await client.messages.create({
  model: 'claude-haiku-5-5',
  max_tokens: 300,
  messages: [{ role: 'user', content: 'What is a context window?' }],
});
console.log(message.content[0].text);
console.log(message.stop_reason, message.usage);

Three things come back that you will use in every chapter:

  • content: a list of blocks. Today it holds one text block. Soon it will hold tool calls.
  • stop_reasonStop reason: The field in a response that says why generation stopped: end_turn, max_tokens, stop_sequence, tool_use and others.: why the model stopped. end_turn means it finished. max_tokens means it was cut off.
  • usage: input and output tokensOutput tokens: The tokens the model generates in its reply, including any tool calls and thinking., which is what you pay for.

Why no real key

The Playground runs a simulator in your browser. It answers with simple, visible rules, so you can see why it replied the way it did in the TraceTrace: A record of everything that happened during one request or agent run, as a tree of timed steps. tab. Keys start with sk-ant-sim-. If you paste a real key, it is blanked at once and never sent anywhere.

How it fails

Leave out max_tokens and you get a 400 error. Use a key that does not start with sk-ant-sim- and you get a 401. Try both: reading real error messages early saves hours later.

Key points

  • A request names a model, a max_tokens limit and a list of messages. The reply has content, a stop_reason and usage.
  • The model keeps no memory between requests. Your code sends the conversation every time.
  • The Playground simulates the API in your browser, so keys start with sk-ant-sim- and nothing costs money.
Hands-on labRuns in the Playground

Send a first request and read it

Make one call to the simulated model and read the reply, the stop reason and the token usage.

You will have: A script that prints the reply, its stop_reason, its token counts and the error you get without max_tokens.

Steps

  1. Run the starter and confirm the request succeeds.
  2. Join the text blocks in message.content and print the start of the reply.
  3. Print stop_reason and the input and output token counts from usage.
  4. Send a second request without max_tokens inside try/except and print the error type.

Done when

  • The output shows a stop_reason of end_turn or max_tokens.
  • Input and output token counts are both printed as numbers.
  • The broken request prints an error type instead of crashing the script.

Open in the Playground No API key needed.

Starter code (Python)
import anthropic

client = anthropic.Anthropic()  # reads the simulated key from the environment

message = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=300,
    messages=[{"role": "user", "content": "What is a context window?"}],
)

# TODO: join the text blocks in message.content and print the first 80 characters
# TODO: print message.stop_reason
# TODO: print the input and output token counts from message.usage
# TODO: send a second request without max_tokens inside try/except and print the error type
print("starter ran: fill in the TODOs")
Show a solution
import anthropic

client = anthropic.Anthropic()  # reads the simulated key from the environment

message = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=300,
    messages=[{"role": "user", "content": "What is a context window?"}],
)

text = "".join(b.text for b in message.content if b.type == "text")
print("reply:", text[:80])
print("stop_reason:", message.stop_reason)
print("input tokens:", message.usage.input_tokens, "| output tokens:", message.usage.output_tokens)

# Now break it on purpose: leave out max_tokens and read the error.
try:
    client.messages.create(model="claude-sonnet-5-5", messages=[{"role": "user", "content": "Hi"}])
except Exception as err:
    print("error caught:", type(err).__name__)

Do it Run your first message in the Playground in the Playground. No API key needed.

Quick checkYou send a second request but leave out the first question and answer. What does the model know about them?
How sure are you?
Pick an answer and how sure you are