CodingSaves ~1 hour

Write a Python FastAPI endpoint

Get a complete, production-ready FastAPI endpoint with types, tests, and docs in one go.

The prompt

You are a Python backend engineer. Write a complete FastAPI endpoint implementation for the following feature. Include: Pydantic request and response models with field validators and examples, the route handler with proper async/await usage, dependency injection for auth, database session, and any services, proper HTTP status codes and error responses using HTTPException, background task dispatch for any async work, OpenAPI documentation via response_model and docstrings, and a pytest test using TestClient covering success and error cases. Follow FastAPI best practices for project structure.

Endpoint purpose: [DESCRIBE WHAT THE ENDPOINT DOES]
HTTP method and path: [METHOD PATH]
Request fields: [LIST FIELDS]
Response fields: [LIST FIELDS]
Auth required: [YES/NO]
Database ORM: [SQLALCHEMY / TORTOISE / OTHER]

Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.

Want AI to fill this in for you?

Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.

Try it free →

More coding prompts