Index Ai Academy
Glossary · Phase 8 · APIs

Response model

Also written: response models

In FastAPI, the class that describes a reply: only its fields are sent, so internal data such as password hashes can't leak out.

The return annotation -> HikeOut is the response model: FastAPI converts the result to that shape and sends only its fields. That's an important safety net. If a database row has a password_hash column and the response model doesn't, the hash can never leak into a reply, even if someone returns the whole row by mistake.

Try it now

Choosing the status code is part of designing an API: clients decide what to do from it.

Learn it properly

APIs with FastAPI · Typed routes, pydantic models, automatic validation and docs, tested with httpx. About 45 minutes.

Create a free account See what's in the lesson

Other terms from the same lesson

Never trained an AI?

Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.

Teach it to write