|
4 | 4 | <div align="center"> |
5 | 5 | <h1>Serverless API Proxy</h1> |
6 | 6 | <p>Serverless API Proxy: Multi-API Proxy Gateway Based on Vercel Routes, Cloudflare Workers, and Netlify Redirects</p> |
| 7 | +[](https://github.com/lopinx/serverless-api-proxy/releases) |
| 8 | +[](https://github.com/lopinx/serverless-api-proxy/stargazers) |
| 9 | +[](https://github.com/lopinx/serverless-api-proxy/network/members) |
| 10 | +[](https://github.com/lopinx/serverless-api-proxy/issues) |
| 11 | +[](https://github.com/lopinx/serverless-api-proxy/blob/main/LICENSE) |
7 | 12 | </div> |
8 | 13 |
|
9 | 14 | ## Notice |
|
12 | 17 |
|
13 | 18 | ## Support |
14 | 19 |
|
15 | | -- openai |
16 | | -- gemini |
17 | | -- groq |
18 | | -- claude |
19 | | -- cohere |
20 | | -- huggingface.co |
21 | | -- Fireworks AI |
22 | | -- ... |
| 20 | +- openai、gemini、claude、xAI、groq、llama and so on... |
23 | 21 |
|
24 | 22 | ## How to deploy |
25 | 23 |
|
|
31 | 29 |
|
32 | 30 | [](https://deploy.workers.cloudflare.com/?url=https://github.com/lopinx/serverless-api-proxy) |
33 | 31 |
|
34 | | -### Netlify |
35 | | - |
36 | | -[](https://app.netlify.com/start/deploy?repository=https://github.com/lopinx/serverless-api-proxy) |
37 | | - |
38 | | -## How to use |
39 | | - |
40 | | -### Configure proxy address |
| 32 | +#### **Environment Variables List** |
41 | 33 |
|
42 | | -``` |
43 | | -# openai |
44 | | -https://self.domain/openai/ |
45 | | -
|
46 | | -# gemini |
47 | | -https://self.domain/gemini/ |
| 34 | +| Variable Name | Type | Required/Optional | Description | Example Value/Format | Security Recommendations | |
| 35 | +| ------------------ | ---------- | ----------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------- | |
| 36 | +| **ADMIN_USERNAME** | String | Required | Admin dashboard login username | `admin` (strongly recommend changing) | Use a strong username and avoid default values | |
| 37 | +| **ADMIN_PASSWORD** | Secret | Required | Admin dashboard login password | `admin` (strongly recommend changing to a strong password) | Encrypt storage and use complex character combinations | |
| 38 | +| **SESSION_SECRET** | Secret | Required | Session cookie signing secret | `$qA,.3!_I1^0AQ5rZm3!z-S3^(IgF$A8` (default value, must be changed in production) | Generate a long random string and encrypt it | |
| 39 | +| **API_ENDPOINTS** | JSON/Array | Optional | Static API endpoint configuration (used if KV is not configured) | `[["/openai", "https://api.openai.com/v1"], ["/gemini", "https://generativelanguage.googleapis.com"]]` | Mutually exclusive with KV configuration. Static configurations cannot be modified via the admin dashboard | |
48 | 40 |
|
49 | | -# groq |
50 | | -https://self.domain/groq/ |
| 41 | +### **KV Namespace Binding Variables** |
51 | 42 |
|
52 | | -# claude |
53 | | -https://self.domain/claude/ |
| 43 | +| Variable Name | Type | Required/Optional | Description | Associated Step | |
| 44 | +| ----------------- | ------------ | ----------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | |
| 45 | +| **API_ENDPOINTS** | KV Reference | Optional | Bind to Cloudflare KV Namespace to store dynamic API endpoint configurations | Bind to the `Namespace Name` of KV Namespace (must match `env.API_ENDPOINTS` in code) | |
54 | 46 |
|
55 | | -# cohere |
56 | | -https://self.domain/cohere/ |
| 47 | +### Netlify |
57 | 48 |
|
58 | | -# huggingface |
59 | | -https://self.domain/huggingface/ |
| 49 | +[](https://app.netlify.com/start/deploy?repository=https://github.com/lopinx/serverless-api-proxy) |
60 | 50 |
|
61 | | -# fireworks |
62 | | -https://self.domain/fireworks/ |
63 | | -``` |
| 51 | +## How to use |
64 | 52 |
|
65 | | -| Name | Original API | Proxy API | Use Example | |
66 | | -| :---: | :--- | :--- | :--- | |
67 | | -| OpenAI API | <https://api.openai.com/v1> | `/openai/v1` | `/openai/v1/chat/completions` | |
68 | | -| Gemini API | <https://generativelanguage.googleapis.com/v1> | `/gemini/v1` | `/gemini/v1/models/gemini-pro:generateContent?key=AIzaSyBbBDDvGwJqKjsmE6CpNheqmzp30bz9saI` | |
69 | | -| Gemini API | <https://generativelanguage.googleapis.com/v1beta> | `/gemini/v1beta` | `/gemini/v1beta/models/gemini-pro:generateContent?key=AIzaSyBbBDDvGwJqKjsmE6CpNheqmzp30bz9saI` | |
70 | | -| Groq API | <https://api.groq.com/groq/openai/v1> | `/groq/openai/v1` | `/groq/openai/v1/chat/completions` | |
71 | | -| Claude API | <https://api.anthropic.com/v1> | `/claude/v1` | `/claude/v1/completions` | |
72 | | -| Cohere API | <https://api.cohere.ai/v1> | `/cohere/v1` | `/cohere/v1/chat/completions` | |
73 | | -| Huggingface API | <https://api-inference.huggingface.co> | `/huggingface` | `/huggingface/models/meta-llama/Llama-3.1-70B-Instruct/v1/chat/completions` | |
74 | | -| Fireworks API | <https://api.fireworks.ai/v1> | `/fireworks/v1` | `/fireworks/v1/chat/completions` | |
| 53 | +### Configure proxy address |
75 | 54 |
|
| 55 | +| Provider | Identifier | API Endpoint | Documentation Link | Compatibility | |
| 56 | +| ---------------- | ---------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | |
| 57 | +| Amazon Bedrock | aws-bedrock | https://bedrock-runtime.us-east-1.amazonaws.com | [docs](https://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/what-is-bedrock.html) | Non OpenAI Compatible | |
| 58 | +| Anthropic | anthropic | https://api.anthropic.com/v1 | [docs](https://docs.anthropic.com/en/api/openai-sdk) | OpenAI Compatible | |
| 59 | +| Azure OpenAI | azure-openai | https://{RESOURCE_NAME}.openai.azure.com | [docs](https://github.com/openai/openai-python?tab=readme-ov-file#microsoft-azure-openai) | OpenAI Compatible | |
| 60 | +| Cartesia | cartesia | https://api.cartesia.ai | [docs](https://docs.cartesia.ai/2025-04-16/use-the-api/api-conventions) | Non OpenAI Compatible | |
| 61 | +| Cerebras | cerebras-ai | https://api.cerebras.ai/v1 | [docs](https://inference-docs.cerebras.ai/resources/openai) | OpenAI Compatible | |
| 62 | +| Cohere | cohere | https://api.cohere.ai | [docs](https://docs.cohere.com/docs/compatibility-api) | OpenAI Compatible (https://api.cohere.ai/compatibility/v1) | |
| 63 | +| DeepSeek | deepseek | https://api.deepseek.com | [docs](https://api-docs.deepseek.com/zh-cn/api/deepseek-api) | OpenAI Compatible | |
| 64 | +| Google AI Studio | google-ai-studio | https://generativelanguage.googleapis.com | [docs](https://ai.google.dev/gemini-api/docs) | /v1beta/models/{model}:generateContent | |
| 65 | +| Google Vertex AI | google-vertex-ai | https://us-east1-aiplatform.googleapis.com | [docs](https://cloud.google.com/vertex-ai/generative-ai/docs/start/express-mode/vertex-ai-express-mode-api-reference) | /v1beta1/{model}:generateContent | |
| 66 | +| Grok | grok | https://api.x.ai/v1 | [docs](https://docs.x.ai/docs/guides/chat) | OpenAI Compatible | |
| 67 | +| Groq | groq | https://api.groq.com/openai/v1 | [docs](https://console.groq.com/docs/overview) | OpenAI Compatible | |
| 68 | +| HuggingFace | huggingface | https://router.huggingface.co/hf-inference/models/Qwen/Qwen3-235B-A22B/v1 | [docs](https://huggingface.co/docs/inference-providers/providers/hf-inference) | OpenAI Compatible | |
| 69 | +| Mistral AI | mistral | https://api.mistral.ai/v1 | [docs](https://docs.mistral.ai/capabilities/completion/) | OpenAI Compatible | |
| 70 | +| OpenAI | openai | https://api.openai.com/v1 | [docs](https://platform.openai.com/docs/api-reference) | OpenAI Compatible | |
| 71 | +| OpenRouter | openrouter | https://openrouter.ai/api/v1 | [docs](https://openrouter.ai/docs/api-reference/overview) | OpenAI Compatible | |
| 72 | +| Perplexity | perplexity-ai | https://api.perplexity.ai | [docs](https://docs.perplexity.ai/api-reference/chat-completion) | OpenAI Compatible | |
| 73 | +| Replicate | replicate | https://api.replicate.com/v1 | [docs](https://replicate.com/docs/reference/http) | OpenAI Compatible | |
| 74 | +| Workers AI | workers-ai | https://api.cloudflare.com/client/v4/accounts/[account_id]/ai | [docs](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) | OpenAI Compatible | |
| 75 | +| Github AI | github-ai | https://models.github.ai/inference | [docs](https://learn.microsoft.com/zh-cn/python/api/overview/azure/ai-inference-readme?view=azure-python-preview) | OpenAI Compatible | |
76 | 76 |
|
77 | 77 | ### API Usage |
78 | 78 |
|
79 | | -``` python |
| 79 | +```python |
80 | 80 | import random |
81 | 81 | import re |
82 | 82 |
|
@@ -116,4 +116,4 @@ def gentext(): |
116 | 116 |
|
117 | 117 | ## Vercel Region List |
118 | 118 |
|
119 | | -https://vercel.com/docs/edge-network/regions#region-list |
| 119 | +https://vercel.com/docs/edge-network/regions#region-list |
0 commit comments