You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 183ed90
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+13-9Lines changed: 13 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
[](https://render.com/deploy?repo=https://github.com/Jemade/API-WRAPPER)
4
4
5
-
A production-oriented API gateway and reverse proxy built in Python with FastAPI, PostgreSQL, and Redis that controls, observes, and standardizes traffic between client applications and upstream Large Language Model providers (OpenAI and Anthropic). It provides API-key authentication with hashed credentials, distributed sliding-window rate limiting, exponential backoff retries for transient upstream failures, normalized response structures, HMAC-SHA256-signed webhook delivery, and structured JSON logging with correlation IDs.
5
+
A production-oriented API gateway and reverse proxy built in Python with FastAPI, PostgreSQL, and Redis that controls, observes, and standardizes traffic between client applications and upstream Large Language Model providers (Google Gemini, OpenAI, and Anthropic). It provides API-key authentication with hashed credentials, distributed sliding-window rate limiting, exponential backoff retries for transient upstream failures, normalized response structures, HMAC-SHA256-signed webhook delivery, and structured JSON logging with correlation IDs.
6
6
7
7
---
8
8
@@ -11,7 +11,7 @@ A production-oriented API gateway and reverse proxy built in Python with FastAPI
11
11
Connecting client applications directly to third-party LLM providers creates serious production risks: client code becomes tightly coupled to vendor-specific SDK formats, rate limits cannot be enforced across multiple consumers, upstream network hiccups or temporary 5xx errors cause user-facing failures, and auditing token usage across teams requires combing through third-party billing dashboards.
12
12
13
13
I built this gateway as a centralized control plane to solve these problems:
14
-
1.**Vendor Decoupling**: Clients consume a single, normalized API format regardless of whether the underlying model is hosted by OpenAI or Anthropic.
14
+
1.**Vendor Decoupling**: Clients consume a single, normalized API format regardless of whether the underlying model is hosted by Google Gemini, OpenAI, or Anthropic.
15
15
2.**Resiliency**: Transient network drops and upstream 5xx outages are automatically absorbed using exponential backoff retries before reaching the user.
16
16
3.**Usage Governance & Security**: Distributed sliding-window rate limiting prevents noisy neighbors or runaway loops from blowing through API budgets, and credentials are stored securely as cryptographic hashes.
17
17
4.**End-to-End Observability**: Correlation IDs propagate through every HTTP hop, database audit log, and structured JSON log event.
-**Provider Abstraction**: Unified adapter interface supporting OpenAI (`gpt-4o`, `o1`, etc.) and Anthropic (`claude-3-5-sonnet`, etc.) with normalized response shapes.
57
+
-**Provider Abstraction**: Unified adapter interface supporting Google Gemini (`gemini-3.6-flash`, `gemini-flash-latest`, etc.), OpenAI (`gpt-4o`, `o1`, etc.), and Anthropic (`claude-3-5-sonnet`, etc.) with normalized response shapes.
56
58
-**API Key Authentication**: Constant-time verification against SHA-256 hashed keys stored in PostgreSQL. Raw keys are never stored.
57
59
-**Distributed Rate Limiting**: Atomic Redis sliding-window counter per API key with configurable quotas and documented failure policies (`fail_open` vs `fail_closed`).
58
60
-**Resilient Retries**: `tenacity`-powered exponential backoff for transient failures (timeouts, connection resets, 500, 502, 503, 504) while immediately failing on client errors (400, 422).
@@ -91,7 +93,7 @@ curl -i -X POST http://localhost:8080/v1/generate \
91
93
-H "X-Request-ID: req_custom_trace_123" \
92
94
-H "Content-Type: application/json" \
93
95
-d '{
94
-
"model": "gpt-4o",
96
+
"model": "gemini-3.6-flash",
95
97
"messages": [
96
98
{"role": "system", "content": "You are a concise engineering tutor."},
97
99
{"role": "user", "content": "What is an idempotency key?"}
@@ -110,14 +112,14 @@ curl -i -X POST http://localhost:8080/v1/generate \
110
112
```json
111
113
{
112
114
"request_id": "req_custom_trace_123",
113
-
"provider": "openai",
114
-
"model": "gpt-4o",
115
+
"provider": "gemini",
116
+
"model": "gemini-3.6-flash",
115
117
"content": "An idempotency key is a unique token generated by a client to ensure that an API request can be safely retried without performing the same operation multiple times, preventing duplicate transactions.",
0 commit comments