Use requests to send an HTTP GET request to an API, display the response, and handle likely failures through a staged prompting workflow. section 9.5.1
Build the task in three practical passes:
- Decompose the goal into smaller subtasks: initialize the request, display the response body, and handle errors. section 9.5.1
- Ask focused questions about GET-request best practices, response display, network errors, and non-200 responses. section 9.5.1
- Evaluate each response, revise unclear prompts, and treat generated guidance as material requiring developer judgment. section 9.5.1
Prompt sequence
Start with: “Decompose the following task into a series of smaller, manageable steps. The goal is to send an HTTP GET request to an API using Python’s requests library, display the response, and handle potential errors.” Then request focused explanations for initialization, response-body display, and network or non-200 errors. section 9.5.1
Figure 9.6 A chain-of-thought prompt gets the model to reason out a problem like a human would. You break down the problem and experiment with answers until you get the results you desire.
Use the figure to visualize decomposition, experimentation, and iterative refinement as a single prompting loop. section 9.5.1





