A minimal endpoint
from fastapi import FastAPI
from pydantic import BaseModel, Field
app = FastAPI()
class AskRequest(BaseModel):
question: str = Field(min_length=3, max_length=2000)
@app.post("/ask")
async def ask(body: AskRequest) -> dict:
# Call your model here, with a timeout, and return its answer.
return {"answer": "stub"}Timeouts and limits
A model call can be slow. Wrap it in a timeout so one slow call cannot hold your workers, and cap the request size so a single caller cannot run up the bill.
Next
Streaming responses and background queues will be covered in a follow-up.



