nya-proxy 0.0.4__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Nya Foundation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.4
2
+ Name: nya-proxy
3
+ Version: 0.0.4
4
+ Summary: A lightweight, flexible API proxy with dynamic token rotation, load balancing, and rate limiting capabilities.
5
+ Author-email: "Nya Foundation Team (k3scat)" <k3scat@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Nya-Foundation/nyaproxy
8
+ Project-URL: Bug Tracker, https://github.com/Nya-Foundation/nyaproxy/issues
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: fastapi>=0.95.0
21
+ Requires-Dist: uvicorn>=0.22.0
22
+ Requires-Dist: httpx>=0.24.0
23
+ Requires-Dist: nekoconf>=0.1.4
24
+ Requires-Dist: jinja2>=3.1.2
25
+ Requires-Dist: setuptools>=42.0.0
26
+ Requires-Dist: watchfiles>=0.18.0
27
+ Requires-Dist: brotli>=1.0.9
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
30
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
31
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
32
+ Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
33
+ Requires-Dist: aioresponses>=0.7.4; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ # 🐾 NyaProxy - Universal API Proxy
37
+
38
+ [![PyPI version](https://img.shields.io/pypi/v/nya-proxy.svg)](https://pypi.org/project/nya-proxy/)
39
+ [![Python versions](https://img.shields.io/pypi/pyversions/nya-proxy.svg)](https://pypi.org/project/nya-proxy/)
40
+ [![License](https://img.shields.io/github/license/Nya-Foundation/nyaproxy.svg)](https://github.com/Nya-Foundation/nyaproxy/blob/main/LICENSE)
41
+ [![Code Coverage](https://codecov.io/gh/Nya-Foundation/nyaproxy/branch/main/graph/badge.svg)](https://codecov.io/gh/Nya-Foundation/nyaproxy)
42
+ [![CI/CD](https://github.com/Nya-Foundation/nyaproxy/actions/workflows/publish.yml/badge.svg)](https://github.com/Nya-Foundation/nyaproxy/actions/workflows/publish.yml)
43
+ [![Docker](https://img.shields.io/docker/pulls/k3scat/nya-proxy)](https://hub.docker.com/r/k3scat/nya-proxy)
44
+
45
+ <img src="https://raw.githubusercontent.com/Nya-Foundation/NyaProxy/main/images/banner.png" alt="NyaProxy Banner"/>
46
+
47
+ *Your Swiss Army Knife for API Proxy Management*
48
+
49
+ ## 🌟 Core Capabilities
50
+ | Feature | Description | Config Reference |
51
+ |-----------------------|-----------------------------------------------------------------------------|---------------------------|
52
+ | 🔄 Token Rotation | Automatic key cycling across multiple providers | `variables.keys` |
53
+ | ⚖️ Load Balancing | 5 strategies: Round Robin, Random, Least Connections, Fastest Response, Weighted | `load_balancing_strategy` |
54
+ | 🚦 Rate Limiting | Granular controls per endpoint/key with smart queuing | `rate_limit` |
55
+ | 🕵️ Request Masking | Dynamic header substitution across multiple identity providers | `headers` + `variables` |
56
+ | 📊 Real-time Metrics | Interactive dashboard with request analytics and system health | `dashboard.enabled` |
57
+
58
+ ## 🚀 Installation
59
+
60
+ ### Docker (Production)
61
+ ```bash
62
+ docker run -d \
63
+ -p 8080:8080 \
64
+ -v ${PWD}/config.yaml:/app/config.yaml \
65
+ -v nya-proxy-logs:/app/logs \
66
+ k3scat/nya-proxy:latest
67
+ ```
68
+
69
+ ### PyPI (Development)
70
+ ```bash
71
+ pip install nya-proxy
72
+ nyaproxy --config config.yaml --log-level debug
73
+ ```
74
+
75
+ ## 📡 Service Endpoints
76
+
77
+ | Service | Endpoint | Description |
78
+ |------------|-----------------------------------|------------------------------------|
79
+ | API Proxy | `http://localhost:8080/api/<endpoint_name>` | Main proxy endpoint for API requests |
80
+ | Dashboard | `http://localhost:8080/dashboard` | Real-time metrics and monitoring |
81
+ | Config UI | `http://localhost:8080/config` | Visual configuration interface |
82
+
83
+ **Note**: Replace `8080` with your configured port if different
84
+
85
+ ## 🔧 API Configuration
86
+
87
+ ### OpenAI-Compatible APIs (Gemini, Anthropic, etc)
88
+ ```yaml
89
+ gemini:
90
+ name: Google Gemini API
91
+ endpoint: https://generativelanguage.googleapis.com/v1beta/openai
92
+ aliases:
93
+ - /gemini
94
+ key_variable: keys
95
+ headers:
96
+ Authorization: 'Bearer ${{keys}}'
97
+ variables:
98
+ keys:
99
+ - your_gemini_key_1
100
+ - your_gemini_key_2
101
+ load_balancing_strategy: least_requests
102
+ rate_limit:
103
+ endpoint_rate_limit: 75/d # Total endpoint limit
104
+ key_rate_limit: 5/m # Per-key limit
105
+ rate_limit_paths:
106
+ - "/v1/chat/*" # Apply limits to specific paths
107
+ - "/v1/images/*"
108
+ ```
109
+
110
+ ### Generic REST APIs
111
+ ```yaml
112
+ novelai:
113
+ name: NovelAI API
114
+ endpoint: https://image.novelai.net
115
+ aliases:
116
+ - /novelai
117
+ key_variable: tokens
118
+ headers:
119
+ Authorization: 'Bearer ${{tokens}}'
120
+ variables:
121
+ tokens:
122
+ - your_novelai_token_1
123
+ - your_novelai_token_2
124
+ load_balancing_strategy: round_robin
125
+ rate_limit:
126
+ endpoint_rate_limit: 10/s
127
+ key_rate_limit: 2/s
128
+ ```
129
+
130
+ ## 🖥️ Management Interfaces
131
+
132
+ ### Real-time Metrics Dashboard
133
+ <img src="https://raw.githubusercontent.com/Nya-Foundation/NyaProxy/main/images/dashboard_ui.png" width="800" alt="Dashboard UI"/>
134
+
135
+ Monitor at `http://localhost:8080/dashboard`:
136
+ - Request volumes and response times
137
+ - Rate limit status and queue depth
138
+ - Key usage and performance metrics
139
+ - Error rates and status codes
140
+
141
+ ### Visual Configuration Interface
142
+ <img src="https://raw.githubusercontent.com/Nya-Foundation/NyaProxy/main/images/config_ui.png" width="800" alt="Configuration UI"/>
143
+
144
+ Manage at `http://localhost:8080/config`:
145
+ - Live configuration editing
146
+ - Syntax validation
147
+ - Variable management
148
+ - Rate limit adjustments
149
+ - Auto reload on save
150
+
151
+ ## 🛡️ Advanced Reference Architecture (Advanced Deployment)
152
+ ```mermaid
153
+ graph TD
154
+ A[Client] --> B[Nginx]
155
+ B --> C[NyaProxy]
156
+ C --> D[Auth Service]
157
+ D --> E[API Providers]
158
+ F[Monitoring] --> D
159
+ ```
160
+
161
+ ## 🌌 Future Roadmap
162
+
163
+ ```mermaid
164
+ graph LR
165
+ A[Q3 2025] --> B[🔄 Smart Request Routing]
166
+ A --> C[📡 gRPC/WebSocket Support]
167
+ B --> D[📈 Auto-scaling Rules]
168
+ C --> E[📊 Protocol Analytics]
169
+ F[Q4 2025] --> G[🧩 Plugin System]
170
+ F --> H[🔍 Custom Metrics API]
171
+ ```
172
+
173
+ ## ❤️ Community
174
+
175
+ [![Discord](https://img.shields.io/discord/1365929019714834493)](https://discord.gg/jXAxVPSs7K)
176
+
177
+ *Need enterprise support? Contact [k3scat@gmail.com](mailto:k3scat@gmail.com)*
178
+
179
+ ## 📈 Project Growth
180
+
181
+ [![Star History Chart](https://api.star-history.com/svg?repos=Nya-Foundation/NyaProxy&type=Date)](https://star-history.com/#Nya-Foundation/NyaProxy&Date)
@@ -0,0 +1,146 @@
1
+ # 🐾 NyaProxy - Universal API Proxy
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/nya-proxy.svg)](https://pypi.org/project/nya-proxy/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/nya-proxy.svg)](https://pypi.org/project/nya-proxy/)
5
+ [![License](https://img.shields.io/github/license/Nya-Foundation/nyaproxy.svg)](https://github.com/Nya-Foundation/nyaproxy/blob/main/LICENSE)
6
+ [![Code Coverage](https://codecov.io/gh/Nya-Foundation/nyaproxy/branch/main/graph/badge.svg)](https://codecov.io/gh/Nya-Foundation/nyaproxy)
7
+ [![CI/CD](https://github.com/Nya-Foundation/nyaproxy/actions/workflows/publish.yml/badge.svg)](https://github.com/Nya-Foundation/nyaproxy/actions/workflows/publish.yml)
8
+ [![Docker](https://img.shields.io/docker/pulls/k3scat/nya-proxy)](https://hub.docker.com/r/k3scat/nya-proxy)
9
+
10
+ <img src="https://raw.githubusercontent.com/Nya-Foundation/NyaProxy/main/images/banner.png" alt="NyaProxy Banner"/>
11
+
12
+ *Your Swiss Army Knife for API Proxy Management*
13
+
14
+ ## 🌟 Core Capabilities
15
+ | Feature | Description | Config Reference |
16
+ |-----------------------|-----------------------------------------------------------------------------|---------------------------|
17
+ | 🔄 Token Rotation | Automatic key cycling across multiple providers | `variables.keys` |
18
+ | ⚖️ Load Balancing | 5 strategies: Round Robin, Random, Least Connections, Fastest Response, Weighted | `load_balancing_strategy` |
19
+ | 🚦 Rate Limiting | Granular controls per endpoint/key with smart queuing | `rate_limit` |
20
+ | 🕵️ Request Masking | Dynamic header substitution across multiple identity providers | `headers` + `variables` |
21
+ | 📊 Real-time Metrics | Interactive dashboard with request analytics and system health | `dashboard.enabled` |
22
+
23
+ ## 🚀 Installation
24
+
25
+ ### Docker (Production)
26
+ ```bash
27
+ docker run -d \
28
+ -p 8080:8080 \
29
+ -v ${PWD}/config.yaml:/app/config.yaml \
30
+ -v nya-proxy-logs:/app/logs \
31
+ k3scat/nya-proxy:latest
32
+ ```
33
+
34
+ ### PyPI (Development)
35
+ ```bash
36
+ pip install nya-proxy
37
+ nyaproxy --config config.yaml --log-level debug
38
+ ```
39
+
40
+ ## 📡 Service Endpoints
41
+
42
+ | Service | Endpoint | Description |
43
+ |------------|-----------------------------------|------------------------------------|
44
+ | API Proxy | `http://localhost:8080/api/<endpoint_name>` | Main proxy endpoint for API requests |
45
+ | Dashboard | `http://localhost:8080/dashboard` | Real-time metrics and monitoring |
46
+ | Config UI | `http://localhost:8080/config` | Visual configuration interface |
47
+
48
+ **Note**: Replace `8080` with your configured port if different
49
+
50
+ ## 🔧 API Configuration
51
+
52
+ ### OpenAI-Compatible APIs (Gemini, Anthropic, etc)
53
+ ```yaml
54
+ gemini:
55
+ name: Google Gemini API
56
+ endpoint: https://generativelanguage.googleapis.com/v1beta/openai
57
+ aliases:
58
+ - /gemini
59
+ key_variable: keys
60
+ headers:
61
+ Authorization: 'Bearer ${{keys}}'
62
+ variables:
63
+ keys:
64
+ - your_gemini_key_1
65
+ - your_gemini_key_2
66
+ load_balancing_strategy: least_requests
67
+ rate_limit:
68
+ endpoint_rate_limit: 75/d # Total endpoint limit
69
+ key_rate_limit: 5/m # Per-key limit
70
+ rate_limit_paths:
71
+ - "/v1/chat/*" # Apply limits to specific paths
72
+ - "/v1/images/*"
73
+ ```
74
+
75
+ ### Generic REST APIs
76
+ ```yaml
77
+ novelai:
78
+ name: NovelAI API
79
+ endpoint: https://image.novelai.net
80
+ aliases:
81
+ - /novelai
82
+ key_variable: tokens
83
+ headers:
84
+ Authorization: 'Bearer ${{tokens}}'
85
+ variables:
86
+ tokens:
87
+ - your_novelai_token_1
88
+ - your_novelai_token_2
89
+ load_balancing_strategy: round_robin
90
+ rate_limit:
91
+ endpoint_rate_limit: 10/s
92
+ key_rate_limit: 2/s
93
+ ```
94
+
95
+ ## 🖥️ Management Interfaces
96
+
97
+ ### Real-time Metrics Dashboard
98
+ <img src="https://raw.githubusercontent.com/Nya-Foundation/NyaProxy/main/images/dashboard_ui.png" width="800" alt="Dashboard UI"/>
99
+
100
+ Monitor at `http://localhost:8080/dashboard`:
101
+ - Request volumes and response times
102
+ - Rate limit status and queue depth
103
+ - Key usage and performance metrics
104
+ - Error rates and status codes
105
+
106
+ ### Visual Configuration Interface
107
+ <img src="https://raw.githubusercontent.com/Nya-Foundation/NyaProxy/main/images/config_ui.png" width="800" alt="Configuration UI"/>
108
+
109
+ Manage at `http://localhost:8080/config`:
110
+ - Live configuration editing
111
+ - Syntax validation
112
+ - Variable management
113
+ - Rate limit adjustments
114
+ - Auto reload on save
115
+
116
+ ## 🛡️ Advanced Reference Architecture (Advanced Deployment)
117
+ ```mermaid
118
+ graph TD
119
+ A[Client] --> B[Nginx]
120
+ B --> C[NyaProxy]
121
+ C --> D[Auth Service]
122
+ D --> E[API Providers]
123
+ F[Monitoring] --> D
124
+ ```
125
+
126
+ ## 🌌 Future Roadmap
127
+
128
+ ```mermaid
129
+ graph LR
130
+ A[Q3 2025] --> B[🔄 Smart Request Routing]
131
+ A --> C[📡 gRPC/WebSocket Support]
132
+ B --> D[📈 Auto-scaling Rules]
133
+ C --> E[📊 Protocol Analytics]
134
+ F[Q4 2025] --> G[🧩 Plugin System]
135
+ F --> H[🔍 Custom Metrics API]
136
+ ```
137
+
138
+ ## ❤️ Community
139
+
140
+ [![Discord](https://img.shields.io/discord/1365929019714834493)](https://discord.gg/jXAxVPSs7K)
141
+
142
+ *Need enterprise support? Contact [k3scat@gmail.com](mailto:k3scat@gmail.com)*
143
+
144
+ ## 📈 Project Growth
145
+
146
+ [![Star History Chart](https://api.star-history.com/svg?repos=Nya-Foundation/NyaProxy&type=Date)](https://star-history.com/#Nya-Foundation/NyaProxy&Date)
@@ -0,0 +1,48 @@
1
+ """
2
+ NyaProxy - A cute and simple low-level API proxy with dynamic token rotation.
3
+ """
4
+
5
+
6
+ __version__ = "0.0.4"
7
+
8
+
9
+
10
+ from .common.models import NyaRequest
11
+ from .common.utils import format_elapsed_time
12
+ from .core.handler import NyaProxyCore
13
+ from .core.header_processor import HeaderProcessor
14
+ from .core.request_executor import RequestExecutor
15
+ from .core.response_processor import ResponseProcessor
16
+ from .dashboard.api import DashboardAPI
17
+
18
+ # Import key components for easier access
19
+ from .server.config import ConfigError, ConfigManager
20
+ from .server.logger import setup_logger
21
+ from .services.key_manager import KeyManager
22
+ from .services.load_balancer import LoadBalancer
23
+ from .services.metrics import MetricsCollector
24
+ from .services.rate_limiter import RateLimiter
25
+ from .services.request_queue import RequestQueue
26
+
27
+ # Define __all__ to control what is imported with "from nya_proxy import *"
28
+ __all__ = [
29
+ # Core application
30
+ "ConfigManager",
31
+ "ConfigError",
32
+ "DashboardAPI",
33
+ "HeaderProcessor",
34
+ "KeyManager",
35
+ "LoadBalancer",
36
+ "MetricsCollector",
37
+ "NyaRequest",
38
+ "NyaProxyCore",
39
+ "RateLimiter",
40
+ "RequestExecutor",
41
+ "RequestQueue",
42
+ "ResponseProcessor",
43
+ # Utilities
44
+ "format_elapsed_time",
45
+ "setup_logger",
46
+ # Version
47
+ "__version__",
48
+ ]
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.4
2
+ Name: nya-proxy
3
+ Version: 0.0.4
4
+ Summary: A lightweight, flexible API proxy with dynamic token rotation, load balancing, and rate limiting capabilities.
5
+ Author-email: "Nya Foundation Team (k3scat)" <k3scat@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Nya-Foundation/nyaproxy
8
+ Project-URL: Bug Tracker, https://github.com/Nya-Foundation/nyaproxy/issues
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: fastapi>=0.95.0
21
+ Requires-Dist: uvicorn>=0.22.0
22
+ Requires-Dist: httpx>=0.24.0
23
+ Requires-Dist: nekoconf>=0.1.4
24
+ Requires-Dist: jinja2>=3.1.2
25
+ Requires-Dist: setuptools>=42.0.0
26
+ Requires-Dist: watchfiles>=0.18.0
27
+ Requires-Dist: brotli>=1.0.9
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
30
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
31
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
32
+ Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
33
+ Requires-Dist: aioresponses>=0.7.4; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ # 🐾 NyaProxy - Universal API Proxy
37
+
38
+ [![PyPI version](https://img.shields.io/pypi/v/nya-proxy.svg)](https://pypi.org/project/nya-proxy/)
39
+ [![Python versions](https://img.shields.io/pypi/pyversions/nya-proxy.svg)](https://pypi.org/project/nya-proxy/)
40
+ [![License](https://img.shields.io/github/license/Nya-Foundation/nyaproxy.svg)](https://github.com/Nya-Foundation/nyaproxy/blob/main/LICENSE)
41
+ [![Code Coverage](https://codecov.io/gh/Nya-Foundation/nyaproxy/branch/main/graph/badge.svg)](https://codecov.io/gh/Nya-Foundation/nyaproxy)
42
+ [![CI/CD](https://github.com/Nya-Foundation/nyaproxy/actions/workflows/publish.yml/badge.svg)](https://github.com/Nya-Foundation/nyaproxy/actions/workflows/publish.yml)
43
+ [![Docker](https://img.shields.io/docker/pulls/k3scat/nya-proxy)](https://hub.docker.com/r/k3scat/nya-proxy)
44
+
45
+ <img src="https://raw.githubusercontent.com/Nya-Foundation/NyaProxy/main/images/banner.png" alt="NyaProxy Banner"/>
46
+
47
+ *Your Swiss Army Knife for API Proxy Management*
48
+
49
+ ## 🌟 Core Capabilities
50
+ | Feature | Description | Config Reference |
51
+ |-----------------------|-----------------------------------------------------------------------------|---------------------------|
52
+ | 🔄 Token Rotation | Automatic key cycling across multiple providers | `variables.keys` |
53
+ | ⚖️ Load Balancing | 5 strategies: Round Robin, Random, Least Connections, Fastest Response, Weighted | `load_balancing_strategy` |
54
+ | 🚦 Rate Limiting | Granular controls per endpoint/key with smart queuing | `rate_limit` |
55
+ | 🕵️ Request Masking | Dynamic header substitution across multiple identity providers | `headers` + `variables` |
56
+ | 📊 Real-time Metrics | Interactive dashboard with request analytics and system health | `dashboard.enabled` |
57
+
58
+ ## 🚀 Installation
59
+
60
+ ### Docker (Production)
61
+ ```bash
62
+ docker run -d \
63
+ -p 8080:8080 \
64
+ -v ${PWD}/config.yaml:/app/config.yaml \
65
+ -v nya-proxy-logs:/app/logs \
66
+ k3scat/nya-proxy:latest
67
+ ```
68
+
69
+ ### PyPI (Development)
70
+ ```bash
71
+ pip install nya-proxy
72
+ nyaproxy --config config.yaml --log-level debug
73
+ ```
74
+
75
+ ## 📡 Service Endpoints
76
+
77
+ | Service | Endpoint | Description |
78
+ |------------|-----------------------------------|------------------------------------|
79
+ | API Proxy | `http://localhost:8080/api/<endpoint_name>` | Main proxy endpoint for API requests |
80
+ | Dashboard | `http://localhost:8080/dashboard` | Real-time metrics and monitoring |
81
+ | Config UI | `http://localhost:8080/config` | Visual configuration interface |
82
+
83
+ **Note**: Replace `8080` with your configured port if different
84
+
85
+ ## 🔧 API Configuration
86
+
87
+ ### OpenAI-Compatible APIs (Gemini, Anthropic, etc)
88
+ ```yaml
89
+ gemini:
90
+ name: Google Gemini API
91
+ endpoint: https://generativelanguage.googleapis.com/v1beta/openai
92
+ aliases:
93
+ - /gemini
94
+ key_variable: keys
95
+ headers:
96
+ Authorization: 'Bearer ${{keys}}'
97
+ variables:
98
+ keys:
99
+ - your_gemini_key_1
100
+ - your_gemini_key_2
101
+ load_balancing_strategy: least_requests
102
+ rate_limit:
103
+ endpoint_rate_limit: 75/d # Total endpoint limit
104
+ key_rate_limit: 5/m # Per-key limit
105
+ rate_limit_paths:
106
+ - "/v1/chat/*" # Apply limits to specific paths
107
+ - "/v1/images/*"
108
+ ```
109
+
110
+ ### Generic REST APIs
111
+ ```yaml
112
+ novelai:
113
+ name: NovelAI API
114
+ endpoint: https://image.novelai.net
115
+ aliases:
116
+ - /novelai
117
+ key_variable: tokens
118
+ headers:
119
+ Authorization: 'Bearer ${{tokens}}'
120
+ variables:
121
+ tokens:
122
+ - your_novelai_token_1
123
+ - your_novelai_token_2
124
+ load_balancing_strategy: round_robin
125
+ rate_limit:
126
+ endpoint_rate_limit: 10/s
127
+ key_rate_limit: 2/s
128
+ ```
129
+
130
+ ## 🖥️ Management Interfaces
131
+
132
+ ### Real-time Metrics Dashboard
133
+ <img src="https://raw.githubusercontent.com/Nya-Foundation/NyaProxy/main/images/dashboard_ui.png" width="800" alt="Dashboard UI"/>
134
+
135
+ Monitor at `http://localhost:8080/dashboard`:
136
+ - Request volumes and response times
137
+ - Rate limit status and queue depth
138
+ - Key usage and performance metrics
139
+ - Error rates and status codes
140
+
141
+ ### Visual Configuration Interface
142
+ <img src="https://raw.githubusercontent.com/Nya-Foundation/NyaProxy/main/images/config_ui.png" width="800" alt="Configuration UI"/>
143
+
144
+ Manage at `http://localhost:8080/config`:
145
+ - Live configuration editing
146
+ - Syntax validation
147
+ - Variable management
148
+ - Rate limit adjustments
149
+ - Auto reload on save
150
+
151
+ ## 🛡️ Advanced Reference Architecture (Advanced Deployment)
152
+ ```mermaid
153
+ graph TD
154
+ A[Client] --> B[Nginx]
155
+ B --> C[NyaProxy]
156
+ C --> D[Auth Service]
157
+ D --> E[API Providers]
158
+ F[Monitoring] --> D
159
+ ```
160
+
161
+ ## 🌌 Future Roadmap
162
+
163
+ ```mermaid
164
+ graph LR
165
+ A[Q3 2025] --> B[🔄 Smart Request Routing]
166
+ A --> C[📡 gRPC/WebSocket Support]
167
+ B --> D[📈 Auto-scaling Rules]
168
+ C --> E[📊 Protocol Analytics]
169
+ F[Q4 2025] --> G[🧩 Plugin System]
170
+ F --> H[🔍 Custom Metrics API]
171
+ ```
172
+
173
+ ## ❤️ Community
174
+
175
+ [![Discord](https://img.shields.io/discord/1365929019714834493)](https://discord.gg/jXAxVPSs7K)
176
+
177
+ *Need enterprise support? Contact [k3scat@gmail.com](mailto:k3scat@gmail.com)*
178
+
179
+ ## 📈 Project Growth
180
+
181
+ [![Star History Chart](https://api.star-history.com/svg?repos=Nya-Foundation/NyaProxy&type=Date)](https://star-history.com/#Nya-Foundation/NyaProxy&Date)
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ nya_proxy/__init__.py
5
+ nya_proxy.egg-info/PKG-INFO
6
+ nya_proxy.egg-info/SOURCES.txt
7
+ nya_proxy.egg-info/dependency_links.txt
8
+ nya_proxy.egg-info/entry_points.txt
9
+ nya_proxy.egg-info/requires.txt
10
+ nya_proxy.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ nyaproxy = nya_proxy.server.app:main
@@ -0,0 +1,15 @@
1
+ fastapi>=0.95.0
2
+ uvicorn>=0.22.0
3
+ httpx>=0.24.0
4
+ nekoconf>=0.1.4
5
+ jinja2>=3.1.2
6
+ setuptools>=42.0.0
7
+ watchfiles>=0.18.0
8
+ brotli>=1.0.9
9
+
10
+ [dev]
11
+ pytest>=7.0.0
12
+ pytest-asyncio>=0.21.0
13
+ pytest-cov>=4.0.0
14
+ pytest-mock>=3.10.0
15
+ aioresponses>=0.7.4
@@ -0,0 +1 @@
1
+ nya_proxy
@@ -0,0 +1,89 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "nya-proxy"
7
+ version = "0.0.4"
8
+ description = "A lightweight, flexible API proxy with dynamic token rotation, load balancing, and rate limiting capabilities."
9
+ readme = "README.md"
10
+ authors = [
11
+ {name = "Nya Foundation Team (k3scat)", email = "k3scat@gmail.com"},
12
+ ]
13
+ license = "MIT"
14
+ license-files = ["LICENSE"]
15
+
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.8",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ ]
26
+ requires-python = ">=3.8"
27
+ dependencies = [
28
+ "fastapi>=0.95.0",
29
+ "uvicorn>=0.22.0",
30
+ "httpx>=0.24.0",
31
+ "nekoconf>=0.1.4",
32
+ "jinja2>=3.1.2",
33
+ "setuptools>=42.0.0",
34
+ "watchfiles>=0.18.0",
35
+ "brotli>=1.0.9",
36
+ ]
37
+
38
+ [project.optional-dependencies]
39
+ dev = [
40
+ "pytest>=7.0.0",
41
+ "pytest-asyncio>=0.21.0",
42
+ "pytest-cov>=4.0.0",
43
+ "pytest-mock>=3.10.0",
44
+ "aioresponses>=0.7.4",
45
+ ]
46
+
47
+ [tool.pytest.ini_options]
48
+ testpaths = ["tests"]
49
+ python_files = ["test_*.py"]
50
+ addopts = "-v --cov=nya_proxy --cov-report=term-missing"
51
+ asyncio_mode = "auto"
52
+
53
+ [tool.coverage.run]
54
+ source = ["nya_proxy"]
55
+ omit = ["tests/*"]
56
+
57
+ [tool.coverage.report]
58
+ exclude_lines = [
59
+ "pragma: no cover",
60
+ "def __repr__",
61
+ "if self.debug:",
62
+ "raise NotImplementedError",
63
+ "if __name__ == .__main__.:",
64
+ "pass",
65
+ "raise ImportError"
66
+ ]
67
+
68
+ [project.urls]
69
+ "Homepage" = "https://github.com/Nya-Foundation/nyaproxy"
70
+ "Bug Tracker" = "https://github.com/Nya-Foundation/nyaproxy/issues"
71
+
72
+ [project.scripts]
73
+ nyaproxy = "nya_proxy.server.app:main"
74
+
75
+ [tool.setuptools]
76
+ packages = ["nya_proxy"]
77
+ package-dir = {"nya_proxy" = "nya_proxy"}
78
+
79
+ [tool.semantic_release]
80
+ tag_format = "v{version}"
81
+ version_variables = ["nya_proxy/__init__.py:__version__"]
82
+ build_command = "python -m pip install build && python -m build"
83
+ commit_parser = "conventional"
84
+ commit_message = "chore(release): bump version to v{version} [skip ci]"
85
+ commit_author = "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
86
+
87
+ [tool.semantic_release.publish]
88
+ dist_glob_patterns = ["dist/*"]
89
+ upload_to_vcs_release = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+