Metadata-Version: 2.4
Name: fastapi-gemini-blueprint
Version: 2.0.0
Summary: 2026 Production Architecture Blueprint for FastAPI + Google Gemini Structured JSON (Pydantic v2, 3-Model Failover & SaaS Credit Quotas)
Author-email: ShipAI Studio <shipai@users.noreply.github.com>
License: MIT
Project-URL: Homepage, https://razio05.github.io
Project-URL: Documentation, https://yahiaoui26.gumroad.com/l/fastapi-gemini-blueprint
Project-URL: CommercialBoilerplate, https://yahiaoui26.gumroad.com/l/shipai-pro/BLUEPRINT30
Project-URL: Repository, https://github.com/RAZIO05/fastapi-gemini-2026-blueprint
Keywords: fastapi,gemini,google-genai,pydantic,micro-saas,boilerplate,streamlit,llm
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2.0.0
Dynamic: license-file

# ⚡ FastAPI + Google Gemini 2026 Structured JSON Blueprint (Python 3.13 Ready)

[![CI Passing](https://github.com/RAZIO05/fastapi-gemini-2026-blueprint/actions/workflows/ci.yml/badge.svg)](https://github.com/RAZIO05/fastapi-gemini-2026-blueprint/actions)
[![Python 3.10-3.13](https://img.shields.io/badge/Python-3.10--3.13-blue.svg)](https://yahiaoui26.gumroad.com/l/fastapi-gemini-blueprint)
[![FastAPI](https://img.shields.io/badge/FastAPI-Async-009688.svg)](https://yahiaoui26.gumroad.com/l/shipai-pro)
[![Google Gemini](https://img.shields.io/badge/Google%20Gemini-3.5%20Flash%20JSON-orange.svg)](https://yahiaoui26.gumroad.com/l/shipai-pro)
[![ShipAI Pro](https://img.shields.io/badge/ShipAI%20v2.0-Commercial%20SaaS%20Engine-brightgreen.svg)](https://yahiaoui26.gumroad.com/l/shipai-pro/LAUNCH20)

<p align="center">
  <a href="https://yahiaoui26.gumroad.com/l/shipai-pro/LAUNCH20">
    <img src="https://public-files.gumroad.com/00b6jvp3mssqjd59jm1ax12xa5q9" alt="ShipAI v2.0 — FastAPI + Google Gemini Commercial Micro-SaaS Engine" width="100%" />
  </a>
</p>

> **Stop fighting unstructured LLM markdown and Python 3.13 `bcrypt` crashes.**
> This reference blueprint shows how to wire **FastAPI**, **Pydantic v2**, and the official **`google-genai` SDK** with native `response_mime_type="application/json"` and 3-model automatic failover.

---

## 🎁 Grab the Free 2026 Architecture Cheat Sheet ($0) or Full Commercial Boilerplate

* 📘 **[Download the Free 2026 Architecture Blueprint & Cheat Sheet ($0)](https://yahiaoui26.gumroad.com/l/fastapi-gemini-blueprint)**
* 🚀 **[Get ShipAI v2.0 Commercial Engine (20% OFF with code `LAUNCH20`)](https://yahiaoui26.gumroad.com/l/shipai-pro/LAUNCH20)** — Includes:
  * 💳 **SaaS Credit Wallet & HTTP 402 Guard** (`app/monetization.py`)
  * 🔑 **Live Gumroad License Key Verification API** (`/api/v1/billing/activate-license`)
  * 🎯 **5 Pre-Built Vertical Micro-SaaS Presets** (AI Startup Validator, Legal Contract Risk Auditor, OWASP Code Security Reviewer, Resume ATS Optimizer, Programmatic SEO Architect)
  * 📊 **Streamlit v2.0 Executive Dashboard** + **Docker Compose Stack**
  * 🛡️ **30-Day 100% Risk-Free Money-Back Guarantee**

---

## 1. Enforcing Strict Pydantic v2 JSON with 3-Model Gemini Failover

```python
import os, json
from google import genai
from pydantic import BaseModel
from typing import List

client = genai.Client(api_key=os.getenv("GEMINI_API_KEY"))

DEFAULT_MODELS = [
    os.getenv("GEMINI_MODEL", "gemini-3.5-flash"),
    "gemini-flash-lite-latest",
    "gemini-3.8-flash",
]

class AIStructuredResponse(BaseModel):
    status: str
    summary: str
    key_points: List[str]
    action_items: List[str]

def generate_structured_json(prompt: str, system_instruction: str) -> AIStructuredResponse:
    for model_name in DEFAULT_MODELS:
        try:
            res = client.models.generate_content(
                model=model_name,
                contents=prompt,
                config={
                    "response_mime_type": "application/json",
                    "system_instruction": system_instruction,
                },
            )
            return AIStructuredResponse(**json.loads(res.text))
        except Exception as err:
            if any(code in str(err) for code in ("404", "503", "UNAVAILABLE", "NOT_FOUND")):
                continue
            raise
```

## 2. Fixing the Python 3.12 / 3.13 `passlib[bcrypt]` 72-Byte Startup Crash

Pin `bcrypt==4.0.1` alongside `passlib[bcrypt]` in `requirements.txt` to avoid the `ValueError: password cannot be longer than 72 bytes` exception during container boot:

```txt
fastapi
uvicorn
google-genai
pydantic[email]
passlib[bcrypt]
bcrypt==4.0.1
python-jose[cryptography]
```

---

## 🚀 Want the Complete Production Micro-SaaS Repository?

Skip 35+ hours of wiring JWT auth, SaaS credit quotas, Gumroad license verification, Streamlit UI, automated tests, and Docker Compose:

👉 **[Explore the Live Interactive Demo & Get ShipAI v2.0 on Gumroad](https://yahiaoui26.gumroad.com/l/shipai-pro/LAUNCH20)**
