---
title: "Discussion on \"Structuring OpenAI and Gemini Calls in FastAPI: Prompts, Fallbacks, and Retries\" | Hashnode"
description: "Discussion on \"Structuring OpenAI and Gemini Calls in FastAPI: Prompts, Fallbacks, and Retries\". Wrapping LLM clients in FastAPI — prompt versioning, output validation, retry backoff, and fallbacks that don't silently serve stale data"
url: "https://hashnode.com/posts/structuring-openai-and-gemini-calls-in-fastapi-prompts-fallbacks-and-retries/6a9f760f627ad9b613ef09d4"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Structuring OpenAI and Gemini Calls in FastAPI: Prompts, Fallbacks, and Retries](https://blog.madhav.dev/structuring-openai-and-gemini-calls-in-fastapi-prompts-fallbacks-and-retries?utm_source=hashnode&utm_medium=feed)

Wrapping LLM clients in FastAPI — prompt versioning, output validation, retry backoff, and fallbacks that don't silently serve stale data

Sep 8 · 7 min read · blog.madhav.dev  
Read the article

-   [#openai](https://hashnode.com/tag/openai)
-   [#fastapi](https://hashnode.com/tag/fastapi)
-   [#python](https://hashnode.com/tag/python)
-   [#llm](https://hashnode.com/tag/llm)
-   [#production](https://hashnode.com/tag/production)
-   [#backend-engineering](https://hashnode.com/tag/backend-engineering)

## Written by

[Madhav Bhasin](https://hashnode.com/@madhavbhasin)

@madhavbhasin · Noida, India

  
[View profile](https://hashnode.com/@madhavbhasin)

Production patterns for backend engineers who are tired of hello-world tutorials.

Senior full-stack engineer and engineering lead with 5+ years building cloud-native systems at scale. I write about the things the docs don't cover — GCP, FastAPI, Terraform, event-driven architecture, and AI-powered backends. No hello-world demos.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
