Skip to main content
All use casesUse Case

Backend infrastructure for an AI tool that reads, writes, and reviews code.

Coding agents run long LLM analysis loops against a codebase and need to track tool-call state, not just a single prompt/response. The kit's background job system and streaming layer handle the async, long-running parts; you build the tool-calling loop on top.

FastAPIOpenAI / AnthropicCeleryRedisSSEPostgreSQL

The usual pain points

  • Running multi-step LLM analysis loops that take minutes, not seconds
  • Streaming intermediate progress back to a CLI or editor client
  • Tracking token usage across many chained LLM calls per task
  • Isolating and rate-limiting usage per developer or per team

How the kit solves them

  • Celery background jobs handle long multi-step analysis loops
  • SSE streaming pushes intermediate output back to the client as it's produced
  • Token tracking aggregates usage across chained calls for accurate billing
  • Per-API-key tiers separate individual developer usage from team-wide usage

Example implementation

main.py
@celery.task(bind=True)
def run_coding_task(self, task_id: str, repo_context: str, instruction: str):
    total_tokens = 0
    for step in plan_steps(instruction):
        response = llm.chat(messages=build_step_prompt(step, repo_context), track_tokens=True)
        total_tokens += response.tokens
        publish_progress(task_id, step, response.content)
    meter.record(self.request.headers.get("key_id"), total_tokens)

Ready to build your ai coding agent backend?

FastAPI AI Kit ships with everything shown above, pre-configured and production-ready. Clone the repo and start building in minutes.

Ready to ship your AI backend this weekend?

Join developers who skipped weeks of boilerplate and went straight to building.

Read the docs
No subscriptions · One-time payment · Lifetime updates