A small adventure in APIs & AI agents

Fetch a dog with Pip.
Keep the code.

Ask for a dog photo and watch the reply arrive. The service sends an address; your browser uses it to show the picture. Keep a small webpage that makes the same request.

Already curious about the code? Make your own page.

Free to explore · No account or API key · Beginner friendly

01 / Explore

Fetch a dog photo and follow the request

Live API / scripted model

Pip is your guide. The API request is live; Pip’s agent steps are scripted. No AI model runs here.

The plan

A map of the journey
You ask a model, it requests a tool, the tool returns a result, and the model answers you. Youmake a requestModelchoose a tooldog.ceoreturn an addressBack to youinspect the result

Pip is ready. Let’s make the button work.

Your photo arrives here.
Choose a dog, then select Fetch a dog.

The record

Scripted teaching log

Each stop leaves a card. Follow what was requested, returned and used.

  1. Fetch a dog to see the request and response here.
  1. 01Ask
  2. 02Choose
  3. 03Call
  4. 04Inspect
  5. 05Explain
  6. 06Return

School network blocking the API? A sample illustrates the response without fetching a photo.

02 / Look closer

What information came back from the API?

Getting a photo address is different from seeing the photo. Your browser can open the address and display it. A model given only that address has not seen the picture itself.

Run the lesson to inspect a response.

03 / Change the evidence

Take away the clue.

This written example contains a breed in its address. Hide the whole address, including the filename. What can you still reasonably conclude?

A local illustration. No model call or experiment runs here.

Illustrated tool response

{
  "status": "success",
  "message": "https://images.dog.ceo/breeds/beagle/example.jpg"
}

The address contains “beagle”. That supports a statement about its label, not an image-recognition claim.

04 / Make it yours

Download and edit your own dog-photo page

One file. A button, a photo and the code that connects them. Save it, open it and change it.

Download the working HTMLRead the code

No installation, account or API key. The file opens locally. Fetching photos still needs internet access to Dog CEO.

  1. Save pip-dog-fetch.html on your computer.
  2. Open the saved file in your browser.
  3. Select Fetch a dog.
  4. Open the file in a text editor, change its heading, save and refresh.

Look closer: find fetch, where your page asks another service for data. Then find response.ok, which checks whether the HTTP request succeeded.

Just the request

An API is a way for one program to ask another for something. Each example below makes one request. JavaScript and Python print the photo address; curl prints the full JSON reply. No AI model, account or API key is needed.

JavaScript Browser console or a modern Node.js .mjs file
const response = await fetch('https://dog.ceo/api/breeds/image/random');
if (!response.ok) throw new Error('Request failed');
const dog = await response.json();
if (dog.status !== 'success') throw new Error('No dog returned');
console.log(dog.message);
Python Python 3, no extra packages
import json
from urllib.request import urlopen

with urlopen('https://dog.ceo/api/breeds/image/random', timeout=8) as response:
    dog = json.load(response)
print(dog['message'])
curl A terminal with curl; use curl.exe in Windows PowerShell
curl --fail --max-time 8 https://dog.ceo/api/breeds/image/random

Explore the Dog CEO API documentation. Make one request at a time; this lesson does not need a polling loop.

Connect the ideas

Tools for building and inspecting agent workflows

The browser lesson illustrates the pieces. In a real application, tools such as these can help you connect and inspect them.

Dog CEO
The live API that returns the image address. Meet the API
LangChain
Tools for building model-powered applications, including agents that use tools. Read the introduction
LangGraph
Infrastructure for orchestrating stateful agent workflows. The map illustrates a workflow; it is not running LangGraph. Explore graphs
Langfuse
Observability tools for recording and inspecting LLM application runs. Our board is a teaching illustration, not a Langfuse trace. Explore traces

Keep asking

It worked. What can we trust?

Pip brought back an address. That tells us where the photo came from. It does not prove that a model understood the picture.

Now imagine thousands of answers, with sources that change. How do we keep track of what still holds up? That is the problem behind Simone Consumption Engine, our product in development. This lesson does not run the engine.

Try the free AI course

Bring the whole class

Teach the request-and-response cycle

How do we know what an AI answer is based on? Take the discussion further with a suggested lesson plan, printable student worksheet and answer key.

Open the teacher guide
What happens when you use this lesson?

Starting a live run contacts dog.ceo and loads a photo from images.dog.ceo. Those services receive ordinary connection information such as your IP address. The teaching sample makes no API call. This lesson uses no model service, account, microphone or camera. The page is hosted by Cloudflare. The collection stays in page memory and clears on refresh. Responses to the learning questions stay in your browser.

File details on this page

Format, size and a short SHA-256 identifier, measured when this page was built.