codex-proxy 3.1.0__tar.gz → 5.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codex_proxy-5.0.0/.dockerignore +14 -0
- codex_proxy-5.0.0/CHANGELOG.md +185 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/CONTRIBUTING.md +9 -4
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/Dockerfile +2 -1
- codex_proxy-5.0.0/PKG-INFO +483 -0
- codex_proxy-5.0.0/README.md +445 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/pyproject.toml +9 -2
- codex_proxy-5.0.0/src/codex_proxy/__init__.py +3 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/src/codex_proxy/__main__.py +7 -2
- codex_proxy-5.0.0/src/codex_proxy/auth.py +252 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/src/codex_proxy/circuit_breaker.py +1 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/src/codex_proxy/compaction.py +1 -1
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/src/codex_proxy/config.py +217 -19
- codex_proxy-5.0.0/src/codex_proxy/cost.py +146 -0
- codex_proxy-5.0.0/src/codex_proxy/dashboard.py +282 -0
- codex_proxy-5.0.0/src/codex_proxy/db/__init__.py +73 -0
- codex_proxy-5.0.0/src/codex_proxy/db/crud_analytics.py +127 -0
- codex_proxy-5.0.0/src/codex_proxy/db/crud_budgets.py +140 -0
- codex_proxy-5.0.0/src/codex_proxy/db/crud_keys.py +109 -0
- codex_proxy-5.0.0/src/codex_proxy/db/crud_logs.py +80 -0
- codex_proxy-5.0.0/src/codex_proxy/db/crud_plugins.py +119 -0
- codex_proxy-5.0.0/src/codex_proxy/db/crud_providers.py +206 -0
- codex_proxy-5.0.0/src/codex_proxy/db/crud_users.py +76 -0
- codex_proxy-5.0.0/src/codex_proxy/db/engine.py +48 -0
- codex_proxy-5.0.0/src/codex_proxy/db/migrations.py +51 -0
- codex_proxy-5.0.0/src/codex_proxy/db/models.py +210 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/src/codex_proxy/key_rotation.py +5 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/src/codex_proxy/providers.py +20 -0
- codex_proxy-5.0.0/src/codex_proxy/rate_limiter.py +45 -0
- codex_proxy-5.0.0/src/codex_proxy/router.py +199 -0
- codex_proxy-5.0.0/src/codex_proxy/server.py +1476 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/src/codex_proxy/store.py +8 -1
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/src/codex_proxy/tui.py +6 -7
- codex_proxy-5.0.0/tests/test_auth_cost_router.py +387 -0
- codex_proxy-5.0.0/tests/test_db.py +332 -0
- codex_proxy-5.0.0/tests/test_edge_cases.py +142 -0
- codex_proxy-5.0.0/tests/test_rate_limiter.py +66 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/tests/test_server.py +1 -1
- codex_proxy-5.0.0/tests/test_server_features.py +153 -0
- codex_proxy-3.1.0/.dockerignore +0 -6
- codex_proxy-3.1.0/CHANGELOG.md +0 -74
- codex_proxy-3.1.0/PKG-INFO +0 -25
- codex_proxy-3.1.0/README.md +0 -520
- codex_proxy-3.1.0/src/codex_proxy/__init__.py +0 -3
- codex_proxy-3.1.0/src/codex_proxy/server.py +0 -647
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/.github/workflows/ci.yml +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/.github/workflows/release.yml +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/.gitignore +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/.pre-commit-config.yaml +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/CODE_OF_CONDUCT.md +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/LICENSE +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/assets/tui-dashboard.png +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/docker-compose.yml +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/src/codex_proxy/plugins.py +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/src/codex_proxy/plugins_builtin.py +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/src/codex_proxy/translator.py +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/tests/conftest.py +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/tests/test_circuit_breaker.py +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/tests/test_compaction.py +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/tests/test_config.py +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/tests/test_key_rotation.py +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/tests/test_plugins.py +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/tests/test_providers.py +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/tests/test_store.py +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/tests/test_translator.py +0 -0
- {codex_proxy-3.1.0 → codex_proxy-5.0.0}/tests/test_tui.py +0 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [5.0.0] - 2026-06-07
|
|
9
|
+
|
|
10
|
+
### Added — v5 Gateway Platform
|
|
11
|
+
|
|
12
|
+
**Database Layer**
|
|
13
|
+
- Async SQLAlchemy database with 13 tables (users, api_keys, providers, provider_keys, models, routing_rules, request_logs, budgets, cost_alerts, plugin_registry, plugin_instances, sessions, _schema_version)
|
|
14
|
+
- SQLite (default) or PostgreSQL (via asyncpg) backend
|
|
15
|
+
- Version-based migrations system
|
|
16
|
+
- 7 CRUD modules for all entities
|
|
17
|
+
|
|
18
|
+
**Multi-Provider Support**
|
|
19
|
+
- `[[providers]]` TOML array — configure multiple providers in one instance
|
|
20
|
+
- Per-provider clients, adapters, key rotators
|
|
21
|
+
- Model-to-provider resolution across all providers
|
|
22
|
+
- `/models` endpoint aggregates models from all providers
|
|
23
|
+
|
|
24
|
+
**JWT Authentication**
|
|
25
|
+
- POST `/auth/login`, `/auth/signup`, `/auth/refresh`, GET `/auth/me`
|
|
26
|
+
- Password hashing with bcrypt (SHA-256 fallback)
|
|
27
|
+
- JWT access + refresh tokens (PyJWT with stdlib HMAC-SHA256 fallback)
|
|
28
|
+
- Admin user auto-seeded on first startup
|
|
29
|
+
- Budget endpoints: GET/PUT `/auth/budget`
|
|
30
|
+
|
|
31
|
+
**Smart Router**
|
|
32
|
+
- 4 routing strategies: `fallback` (config order), `cost` (cheapest), `latency` (fastest), `weighted` (load balanced)
|
|
33
|
+
- Rolling latency tracker with per-provider health detection
|
|
34
|
+
- Unhealthy providers automatically skipped
|
|
35
|
+
- GET `/api/router/status` for detailed metrics
|
|
36
|
+
|
|
37
|
+
**Cost Tracking**
|
|
38
|
+
- Per-model pricing: input_price_per_million, output_price_per_million
|
|
39
|
+
- 25+ built-in model prices (GLM, GPT, Claude, Gemini, DeepSeek, Llama, etc.)
|
|
40
|
+
- Automatic cost calculation on every request (DB lookup → KNOWN_PRICING fallback → $0)
|
|
41
|
+
- Prices auto-seeded to DB on startup (idempotent)
|
|
42
|
+
- Cost aggregation analytics: GET `/api/stats`, `/api/usage`
|
|
43
|
+
|
|
44
|
+
**Budget Enforcement**
|
|
45
|
+
- Daily and monthly spend limits per user
|
|
46
|
+
- Requests blocked with 429 when budget exceeded
|
|
47
|
+
- Alert threshold notifications
|
|
48
|
+
- Budget status and alerts via API
|
|
49
|
+
|
|
50
|
+
**Web Dashboard**
|
|
51
|
+
- Embedded HTML+CSS+JS dashboard at GET `/dashboard`
|
|
52
|
+
- Dark theme, auto-refresh every 10 seconds
|
|
53
|
+
- Stats cards (requests, success rate, uptime, total cost)
|
|
54
|
+
- Cost breakdown table with visual bars
|
|
55
|
+
- Provider cards with model tags
|
|
56
|
+
- Router status with latency and health info
|
|
57
|
+
|
|
58
|
+
**v5 Config Sections** (all disabled by default for v4 compat)
|
|
59
|
+
- `[database]` — persistent storage settings
|
|
60
|
+
- `[auth]` — JWT authentication settings
|
|
61
|
+
- `[router]` — smart routing settings
|
|
62
|
+
- `[dashboard]` — web dashboard settings
|
|
63
|
+
|
|
64
|
+
**New Dependencies**
|
|
65
|
+
- `sqlalchemy>=2.0`, `aiosqlite>=0.20` (core)
|
|
66
|
+
- Optional: `asyncpg>=0.29` (postgres), `bcrypt>=4.0`, `PyJWT>=2.8`, `cryptography>=42.0` (enterprise)
|
|
67
|
+
|
|
68
|
+
**Testing**
|
|
69
|
+
- 270+ tests (up from 217): 20 DB tests, 33 auth/cost/router tests
|
|
70
|
+
- All existing v4 tests pass unchanged — zero regressions
|
|
71
|
+
|
|
72
|
+
### Changed
|
|
73
|
+
- Description updated: "LLM Gateway Platform — multi-provider proxy with smart routing, cost analytics, and web dashboard"
|
|
74
|
+
- `_log_request()` now calculates real costs and resolves provider_id from DB
|
|
75
|
+
- `/status` endpoint includes v5 features, auth, and router status
|
|
76
|
+
- Startup output shows all providers and v5 mode
|
|
77
|
+
|
|
78
|
+
### Backward Compatibility
|
|
79
|
+
- All v5 features **disabled by default** — v4 config works as-is with zero changes
|
|
80
|
+
- No breaking changes to existing API endpoints or behavior
|
|
81
|
+
|
|
82
|
+
## [4.0.0] - 2026-06-07
|
|
83
|
+
|
|
84
|
+
### Fixed
|
|
85
|
+
|
|
86
|
+
- **`__main__.py`**: `--port 0` and `--host ""` no longer silently ignored (`is not None` check)
|
|
87
|
+
- **`store.py`**: Removed production `assert` that could silently crash with `-O` flag
|
|
88
|
+
- **`compaction.py`**: Compaction notice now says "dropped" instead of misleading "summarized"
|
|
89
|
+
- **`tui.py`**: Success rate now correct after first request (off-by-one fix)
|
|
90
|
+
- **`circuit_breaker.py`**: `get_status()` now includes `last_failure_time` field
|
|
91
|
+
- **`Dockerfile`**: Binds to `0.0.0.0` for container networking
|
|
92
|
+
|
|
93
|
+
### Changed
|
|
94
|
+
|
|
95
|
+
- Removed duplicate `_mask_key()` from `server.py` — single source in `key_rotation.py`
|
|
96
|
+
- `KeyRotator` now exposes `key_count` property (no more `_keys` access)
|
|
97
|
+
- `ResponseStore` now exposes `clear()` method (no more `_store` access)
|
|
98
|
+
- `server.py` no longer accesses private `_keys` on `KeyRotator`
|
|
99
|
+
- `tui.py` no longer accesses private `_store` on `ResponseStore`
|
|
100
|
+
- `tui.py` no longer shadows `state_colors` variable name
|
|
101
|
+
- Hardcoded `MAX_RETRIES`, `RETRY_DELAY`, httpx timeouts are now configurable via config
|
|
102
|
+
- Example config URL corrected to `ZiryaNoov/codex-proxy`
|
|
103
|
+
|
|
104
|
+
### Added
|
|
105
|
+
|
|
106
|
+
- **CORS middleware** — configurable via `cors_origins` in `[server]` config
|
|
107
|
+
- **Admin authentication** — optional Bearer token on `/reload` and `/status` endpoints
|
|
108
|
+
- **Rate limiting** — per-client sliding window rate limiter (`[rate_limit]` config section)
|
|
109
|
+
- **Request size limits** — configurable `max_request_body_bytes` (default 10MB)
|
|
110
|
+
- **Configurable timeouts** — `connect_timeout`, `read_timeout`, `max_retries`, `retry_delay`
|
|
111
|
+
- **Provider adapters** for Together AI and Fireworks AI (11 adapters total)
|
|
112
|
+
- **`rate_limiter.py`** — new module with `RateLimiter` class
|
|
113
|
+
- **217 tests** (up from 184) with new test files:
|
|
114
|
+
- `test_rate_limiter.py` — rate limiter unit tests
|
|
115
|
+
- `test_server_features.py` — rate limiting, admin auth, request size integration tests
|
|
116
|
+
- `test_edge_cases.py` — compaction edge cases, config TOML, provider adapter registry
|
|
117
|
+
- `pyproject.toml` now includes `readme = "README.md"` for PyPI
|
|
118
|
+
|
|
119
|
+
## [3.1.0] - 2026-06-01
|
|
120
|
+
|
|
121
|
+
### Added
|
|
122
|
+
- Dynamic, unified configuration and service reloading across HTTP and TUI (`reload_config_internal`).
|
|
123
|
+
- Instant, non-blocking Unix/macOS keyboard input using `termios`/`tty` cbreak mode.
|
|
124
|
+
|
|
125
|
+
## [2.0.1] - 2026-05-31
|
|
126
|
+
|
|
127
|
+
### Fixed
|
|
128
|
+
|
|
129
|
+
- **Compaction config threading**: `max_messages` and `keep_last` from config.toml
|
|
130
|
+
are now correctly passed to the compaction engine (were previously hardcoded)
|
|
131
|
+
- **Circuit breaker type annotation**: `AppState.circuit_breaker` now correctly
|
|
132
|
+
typed as `CircuitBreaker | None`
|
|
133
|
+
- **Circuit breaker coverage**: Now protects streaming HTTP and WebSocket paths
|
|
134
|
+
(was only protecting non-streaming HTTP)
|
|
135
|
+
- **Config reload**: `/reload` now recreates circuit breaker with new config values
|
|
136
|
+
- **Example config**: `codex-proxy --init` now generates `[circuit_breaker]` and
|
|
137
|
+
`[compaction]` sections
|
|
138
|
+
|
|
139
|
+
### Added
|
|
140
|
+
|
|
141
|
+
- `--print-config` now shows circuit_breaker and compaction settings
|
|
142
|
+
- MIT `LICENSE` file
|
|
143
|
+
|
|
144
|
+
## [2.0.0] - 2026-05-31
|
|
145
|
+
|
|
146
|
+
### Added
|
|
147
|
+
|
|
148
|
+
- **6 new provider adapters** for broader LLM ecosystem support:
|
|
149
|
+
- Anthropic — `x-api-key` header and `anthropic-version` handling
|
|
150
|
+
- Gemini — Google's OpenAI-compatible endpoint
|
|
151
|
+
- DeepSeek — stream_options stripping
|
|
152
|
+
- Mistral — OpenAI-compatible with stream_options handling
|
|
153
|
+
- Cohere — OpenAI-compatible endpoint
|
|
154
|
+
- NVIDIA — NIM OpenAI-compatible endpoint
|
|
155
|
+
- **Circuit breaker** for upstream resilience — protects against failing providers
|
|
156
|
+
with configurable failure threshold, recovery timeout, and half-open state
|
|
157
|
+
- **Context compaction** for long conversations — automatically trims message
|
|
158
|
+
history to fit within limits while preserving system prompts and recent context
|
|
159
|
+
- **CI/CD pipeline** (GitHub Actions) — automated lint, test, and release workflows
|
|
160
|
+
- **Docker Compose** support — one-command containerized deployment with health checks
|
|
161
|
+
- **Pre-commit hooks** — Ruff linting and formatting on every commit
|
|
162
|
+
- **112+ tests** covering translator, config, store, server, providers, circuit
|
|
163
|
+
breaker, and compaction modules
|
|
164
|
+
- **CONTRIBUTING.md** — development setup, code style, PR process, and commit conventions
|
|
165
|
+
- **CODE_OF_CONDUCT.md** — community guidelines
|
|
166
|
+
- **Issue templates** and **PR template** for structured contributions
|
|
167
|
+
|
|
168
|
+
## [1.0.0] - 2026-05-19
|
|
169
|
+
|
|
170
|
+
### Added
|
|
171
|
+
|
|
172
|
+
- Core **Responses API to Chat Completions** protocol translation
|
|
173
|
+
- **Streaming SSE** support with real-time token delivery
|
|
174
|
+
- **WebSocket** support with full Realtime API envelope handling
|
|
175
|
+
- **Reasoning/thinking token** passthrough from supported models
|
|
176
|
+
- **Tool calls** — full function calling support (definitions + results)
|
|
177
|
+
- **Multi-turn conversations** via `previous_response_id` with in-memory response store
|
|
178
|
+
- **Multi-provider** backend — switch between Z.AI, Groq, Together AI, OpenRouter,
|
|
179
|
+
Ollama, Fireworks, and more with a single config change
|
|
180
|
+
- **Usage tracking** — captures token counts from streaming responses
|
|
181
|
+
- **Auto-retry** — one retry on 5xx/transport errors for non-streaming requests
|
|
182
|
+
- **TOML configuration** file with env var and CLI flag overrides
|
|
183
|
+
- **FastAPI** server with `/responses`, `/models`, `/health`, `/status`, and `/reload` endpoints
|
|
184
|
+
- **Dockerfile** for containerized deployment
|
|
185
|
+
- **CLI** with `--init`, `--print-config`, `--port`, `--host`, and `--config` options
|
|
@@ -54,7 +54,7 @@ pytest tests/test_translator.py -v
|
|
|
54
54
|
pytest tests/ -v --tb=short
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
The test suite uses **pytest** with
|
|
57
|
+
The test suite uses **pytest** with 217+ tests covering the translator, config, store, server, providers, circuit breaker, compaction, rate limiter, and admin auth modules.
|
|
58
58
|
|
|
59
59
|
## Project Structure
|
|
60
60
|
|
|
@@ -67,10 +67,15 @@ codex-proxy/
|
|
|
67
67
|
translator.py # Responses API <-> Chat Completions
|
|
68
68
|
config.py # TOML config loading
|
|
69
69
|
store.py # In-memory response store
|
|
70
|
-
providers.py # Provider-specific adapters
|
|
70
|
+
providers.py # Provider-specific adapters (11 providers)
|
|
71
71
|
circuit_breaker.py # Upstream resilience
|
|
72
72
|
compaction.py # Context compaction
|
|
73
|
-
|
|
73
|
+
key_rotation.py # Multi-key round-robin pool
|
|
74
|
+
plugins.py # Hook-based plugin system
|
|
75
|
+
plugins_builtin.py # Built-in plugins (LoggingPlugin)
|
|
76
|
+
rate_limiter.py # Per-client sliding window rate limiter
|
|
77
|
+
tui.py # Rich TUI dashboard
|
|
78
|
+
tests/ # Test suite (217+ tests)
|
|
74
79
|
.github/workflows/ # CI/CD pipelines
|
|
75
80
|
```
|
|
76
81
|
|
|
@@ -118,7 +123,7 @@ Common types: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`, `ci`, `perf`
|
|
|
118
123
|
|
|
119
124
|
## Reporting Issues
|
|
120
125
|
|
|
121
|
-
- Use [GitHub Issues](https://github.com/
|
|
126
|
+
- Use [GitHub Issues](https://github.com/ZiryaNoov/codex-proxy/issues) for bugs and feature requests
|
|
122
127
|
- Include your Python version, OS, and relevant config (redact API keys)
|
|
123
128
|
- For bugs, provide steps to reproduce and any error output
|
|
124
129
|
|