Skip to content
Book a free 30-minute call with an engineer

FastAPI development

Async Python APIs and model serving

PydanticSQLAlchemySQLModelAlembicUvicornCeleryRedispytestDocker

Backend

Building with FastAPI

FastAPI is what we use for small, fast Python services: mobile app backends, internal APIs and endpoints that serve AI models. It's async, it validates requests with Pydantic and it writes the OpenAPI docs for you from the type hints.

A typical setup from us adds SQLAlchemy or SQLModel, Alembic migrations, a Celery or ARQ worker, auth and tracing, all packaged in Docker. FastAPI doesn't include an admin panel or a full ORM, so for big back-office platforms we usually recommend Django instead.

main.pyPython
1app = FastAPI()​
2​
3​
4class Quote(BaseModel):​
5 pickup: str​
6 dropoff: str​
7 weight_kg: float = Field(gt=0, le=2000)​
8​
9​
10@app.post("/quotes")​
11async def create_quote(q: Quote, db: DB = Depends(get_db)):​
12 km = await routing.distance(q.pickup, q.dropoff)​
13 price = round(4.5 + km * 1.2 + q.weight_kg * 0.05, 2)​
14 row = await db.quotes.insert(**q.model_dump(), price=price)​
15 return {"id": row.id, "price": price}​

The kind of FastAPI code our team writes every week.

What we build with FastAPI

  1. 01

    REST APIs

    Typed, validated endpoints with interactive Swagger and ReDoc docs your frontend team can try in the browser.

  2. 02

    ML & LLM model serving

    Production endpoints for ML models, embeddings and LLM pipelines, with timeouts and request limits.

  3. 03

    Microservices

    Small services that talk over HTTP or a message queue and deploy independently.

  4. 04

    Real-time features

    WebSockets and server-sent events for streaming responses and live updates.

  5. 05

    Data APIs

    Read APIs over analytics databases and warehouses for dashboards and reports.

  6. 06

    Migration from Flask

    Moving Flask services to FastAPI for async I/O and typed request and response models.

Why teams pick FastAPI

01

Quick under load

Async I/O on Starlette and Uvicorn handles many concurrent requests on modest servers.

02

Docs that stay current

The OpenAPI spec comes from the code, so it can't drift out of date.

03

Validation included

Pydantic models reject bad input with clear error messages before your code runs.

04

Close to the AI tooling

It sits in the same language as the ML libraries and can stream LLM output as it's generated.

Good fits

  • AI and LLM APIs
  • Mobile app backends
  • Microservice platforms
  • Data access layers
  • Internal tooling APIs

Where we use it

FastAPI questions

Is FastAPI production ready?

Yes, it's widely used in production. We run it behind a reverse proxy with several Uvicorn workers, add structured logs, metrics and tracing, and deploy it in containers with health checks and autoscaling. It's straightforward to operate.

FastAPI or Django: which should we pick?

FastAPI for APIs, microservices and model serving where you want speed and little overhead. Django for full platforms that need its admin, ORM and plugins. We often use both: Django for the main product, FastAPI for one high-traffic or AI-heavy service.

Can FastAPI stream responses from an LLM?

Yes. It supports streaming responses and server-sent events, so tokens appear in your web or mobile UI while the model is still writing. We add per-user limits, caching and cost tracking so a busy day doesn't produce a surprise bill.

How do you test FastAPI services?

Unit tests cover the business logic. Integration tests use the TestClient or httpx against a real database in Docker. We also check responses against the OpenAPI schema so a backend change can't quietly break the frontend or mobile apps. All of it runs in CI on each pull request.

Pairs well with