# Response models and response filtering

> What is responsemodel in FastAPI, how does it relate to the function's return type, and why does it matter for security?

Canonical: https://www.internhack.in/learn/interview/fastapi-interview/fastapi-response-model
Last updated: 2026-11-28

Difficulty: Beginner

## Question

What is response_model in FastAPI, how does it relate to the function's return type, and why does it matter for security?

*The full answer is for InternHack members. Open the page link above to read it.*

## Concepts covered

response_model, return type annotation, output filtering, response_model_exclude_unset, data leakage

Previous: [Pydantic models and request body](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-pydantic-models) · Next: [Dependency Injection in FastAPI](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-dependency-injection) · [All of FastAPI Interview](https://www.internhack.in/learn/interview/fastapi-interview)

## More FastAPI Interview questions

- [Async vs sync route handlers](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-async-routes)
- [Authentication and JWT in FastAPI](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-authentication)
- [Error handling and HTTPException](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-error-handling)
- [Middleware in FastAPI](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-middleware)
- [Database integration with SQLAlchemy](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-database)
- [Background tasks in FastAPI](https://www.internhack.in/learn/interview/fastapi-interview/fastapi-background-tasks)

## Related

- [Learn](https://www.internhack.in/learn)
- [Interview Prep](https://www.internhack.in/learn/interview)
- [FastAPI Interview](https://www.internhack.in/learn/interview/fastapi-interview)
