When Success Isn't the Whole Story
A free lesson from Swipe AI · Building With AI APIs, level 2 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
A request can succeed — no error, no rejection, the provider accepted it and sent something back — and still not give you what you actually needed. The response might come back with an empty output field, a result that doesn't match what you asked for, or content your code wasn't expecting at all.
This is exactly why checking the response before using it matters, even when the request technically worked. Good code validates: is the expected field actually present? Is it empty? Does it look like a reasonable answer, or something clearly off? Skipping that check means bugs show up as bad output shown to a real user, not as an obvious crash.
A request that "succeeds" but still needs a second look:
response: {
output: "",
tokens_used: 2,
finish_reason: "complete"
}
No error was returned — but output is empty. Code that skips checking this would show nothing (or crash) instead of catching the problem.Why does a successful request still need its response checked before use?
Good code checks a response's content — is the field present, is it empty, does it look reasonable — ____ using it.
If an API request succeeds with no error, the content it returns is guaranteed to be exactly what your code expected.
Reading the Response
10 questions · pass with 60% — just like in the app.
Why is treating the entire response object as "the answer" a mistake?
An API response typically bundles the actual answer together with other metadata, like token usage.
The response field name that holds the actual answer ____ between different providers.
What should you check before relying on a response field name in your code?
A request can technically succeed and still return an empty or unexpected result.
Good code checks a response for problems ____ using its content.
What does it mean when an API request "succeeds" but the expected field is empty?
Skipping response validation means problems are more likely to show up as bad output shown to a real user, rather than an obvious crash.
A response bundling the real answer together with details like token counts is an example of ____ data.
Which of these is a genuine reason to validate a response before using it?
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 →