The Shape of a Request
A free lesson from Swipe AI · Building With AI APIs, level 1 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
Nearly every AI API call has the same basic shape, even though the exact details differ between providers: an endpoint (the specific address the request is sent to), an API key (a private credential that proves the request is really from you and lets the provider bill your account), and a payload (the actual content of the request — usually your prompt, plus some settings).
The response that comes back is typically structured data (not just plain text) — it usually includes the model's actual answer, plus extra information like how many tokens the request used. Your code reads that structured response and pulls out the specific piece it needs.
Conceptual shape of a request:
endpoint: "https://<provider>/generate"
api_key: "sk-••••••••••••" (kept secret, never shared publicly)
payload: {
prompt: "Summarize this text in one sentence.",
max_output_length: 50
}
response: {
output: "The text explains how photosynthesis works.",
tokens_used: 34
}An API key deserves real caution: it's tied to your account and its usage bill, so it should never be pasted into code that gets shared publicly or shown on screen — treat it the way you'd treat a password, not a piece of ordinary text.
What is an API key's actual purpose?
The actual content sent in an API request — usually the prompt plus settings — is called the ____.
It's safe to paste an API key into code that will be shared publicly, as long as the request itself succeeds.
Free ai tools
Keep your streak going in Swipe AI
Swipe through every level of Building With AI APIs on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →