Skip to content

Commit d15be60

Browse files
committed
docs(README): 更新文档并添加环境变量说明
- 在 README 和 README_CN 文件中添加了环境变量列表和 KV Namespace 绑定变量说明 - 更新了支持的 API 服务列表 - 移除了旧的 API 地址配置示例 - 在 netlify.toml 中添加了根路径和 robots.txt 的重定向规则 - 更新了 package.json 文件,增加了 ESLint 和 Prettier 配置 - 删除了 public 目录下的 index.html 和 robots.txt 文件
1 parent ff2cb3a commit d15be60

File tree

15 files changed

+1457
-239
lines changed

15 files changed

+1457
-239
lines changed

.github/workflows/delopy.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Deploy Cloudflare Worker
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: 16
19+
20+
- name: Install wrangler
21+
run: npm install -g wrangler
22+
23+
- name: Publish Worker
24+
env:
25+
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
26+
ADMIN_USERNAME: ${{ secrets.ADMIN_USERNAME }}
27+
ADMIN_PASSWORD: ${{ secrets.ADMIN_PASSWORD }}
28+
SESSION_SECRET: ${{ secrets.SESSION_SECRET }}
29+
API_ENDPOINTS: ${{ secrets.API_ENDPOINTS }}
30+
run: |
31+
wrangler config -t $CF_API_TOKEN
32+
wrangler publish \
33+
--var ADMIN_USERNAME=$ADMIN_USERNAME \
34+
--var ADMIN_PASSWORD=$ADMIN_PASSWORD \
35+
--var SESSION_SECRET=$SESSION_SECRET \
36+
--var API_ENDPOINTS=$API_ENDPOINTS

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.vercel
22
.wrangler
33
node_modules/
4-
package-lock.json
4+
package-lock.json
5+
src/.worker*
6+
.dev.vars

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5",
4+
"printWidth": 80,
5+
"tabWidth": 2,
6+
"semi": true
7+
}

README.md

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
<div align="center">
55
<h1>Serverless API Proxy</h1>
66
<p>Serverless API Proxy: Multi-API Proxy Gateway Based on Vercel Routes, Cloudflare Workers, and Netlify Redirects</p>
7+
[![GitHub release](https://img.shields.io/github/release/lopinx/serverless-api-proxy.svg)](https://github.com/lopinx/serverless-api-proxy/releases)
8+
[![GitHub stars](https://img.shields.io/github/stars/lopinx/serverless-api-proxy)](https://github.com/lopinx/serverless-api-proxy/stargazers)
9+
[![GitHub forks](https://img.shields.io/github/forks/lopinx/serverless-api-proxy)](https://github.com/lopinx/serverless-api-proxy/network/members)
10+
[![GitHub issues](https://img.shields.io/github/issues/lopinx/serverless-api-proxy)](https://github.com/lopinx/serverless-api-proxy/issues)
11+
[![GitHub license](https://img.shields.io/github/license/lopinx/serverless-api-proxy)](https://github.com/lopinx/serverless-api-proxy/blob/main/LICENSE)
712
</div>
813

914
## Notice
@@ -12,14 +17,7 @@
1217

1318
## Support
1419

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...
2321

2422
## How to deploy
2523

@@ -31,52 +29,54 @@
3129

3230
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/lopinx/serverless-api-proxy)
3331

34-
### Netlify
35-
36-
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](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**
4133

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 |
4840

49-
# groq
50-
https://self.domain/groq/
41+
### **KV Namespace Binding Variables**
5142

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) |
5446

55-
# cohere
56-
https://self.domain/cohere/
47+
### Netlify
5748

58-
# huggingface
59-
https://self.domain/huggingface/
49+
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/lopinx/serverless-api-proxy)
6050

61-
# fireworks
62-
https://self.domain/fireworks/
63-
```
51+
## How to use
6452

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
7554

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 |
7676

7777
### API Usage
7878

79-
``` python
79+
```python
8080
import random
8181
import re
8282

@@ -116,4 +116,4 @@ def gentext():
116116

117117
## Vercel Region List
118118

119-
https://vercel.com/docs/edge-network/regions#region-list
119+
https://vercel.com/docs/edge-network/regions#region-list

0 commit comments

Comments
 (0)