An AI service proxy server with support for custom forwarding interfaces, featuring a clean architecture and flexible configuration system after refactoring.
- proxy module: Unified proxy system supporting custom forwarding interfaces and headers
- user module: User-related mock endpoints
- telemetry module: Telemetry data collection endpoints
The new proxy system supports:
- Custom forwarding endpoints via YAML configuration files
- Custom request and response headers per endpoint
- Multiple response types: JSON, SSE, streaming, HTML
- Dynamic route registration
endpoints:
- path: "/api/provider/openai/v1/chat/completions"
target_url: "https://api.openai.com/v1/chat/completions"
method: "POST"
response_type: "stream"
custom_headers: {}
forward_request_headers:
- "authorization"
- "content-type"
forward_response_headers:
- "content-type"
enabled: trueHOST: Server bind hostPORT: Server portAMP_API_KEY: AMP service authentication keyRUST_LOG: Log level
cargo run- Edit the
proxy_config.yamlfile - Add new endpoint configuration
- Restart the server
path: Local route pathtarget_url: Target forwarding URLmethod: HTTP method (GET, POST, PUT, DELETE)response_type: Response type (json, sse, stream, html)custom_headers: Custom request headersforward_request_headers: List of request headers to forwardforward_response_headers: List of response headers to forwardenabled: Whether this endpoint is enabled
/api/provider/openai/v1/chat/completions- OpenAI compatible interface/api/provider/anthropic/v1/messages- Anthropic compatible interface/api/tab/llm-proxy- LLM proxy interface
GET /api/user- Get user informationGET /api/connections- Get connection listPOST /api/threads/sync- Sync conversationsPOST /api/internal- Internal interface
POST /api/telemetry- Send telemetry data
cargo buildcargo testcargo check- Configurable Proxying: Easy setup of custom forwarding endpoints
- Header Management: Flexible request and response header configuration
- Multiple Response Types: Support for JSON, SSE, streaming, and HTML responses
- Clean Architecture: Modular design with clear separation of concerns
- Mock Endpoints: Built-in user and telemetry simulation endpoints
- Environment Configuration: Easy setup through environment variables
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2025 YougLin
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.