Spaces:
Running
Running
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,175 +1 @@
|
|
| 1 |
-
|
| 2 |
-
title: Oh My API
|
| 3 |
-
emoji: 🐾
|
| 4 |
-
colorFrom: pink
|
| 5 |
-
colorTo: purple
|
| 6 |
-
sdk: docker
|
| 7 |
-
pinned: true
|
| 8 |
-
license: mit
|
| 9 |
-
---
|
| 10 |
-
|
| 11 |
-
<div align="center">
|
| 12 |
-
<br/>
|
| 13 |
-
|
| 14 |
-
```
|
| 15 |
-
██████╗ ██╗ ██╗ ███╗ ███╗██╗ ██╗ █████╗ ██████╗ ██╗
|
| 16 |
-
██╔═══██╗██║ ██║ ████╗ ████║╚██╗ ██╔╝ ██╔══██╗██╔══██╗██║
|
| 17 |
-
██║ ██║███████║ ██╔████╔██║ ╚████╔╝ ███████║██████╔╝██║
|
| 18 |
-
██║ ██║██╔══██║ ██║╚██╔╝██║ ╚██╔╝ ██╔══██║██╔═══╝ ██║
|
| 19 |
-
╚██████╔╝██║ ██║ ██║ ╚═╝ ██║ ██║ ██║ ██║██║ ██║
|
| 20 |
-
╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝
|
| 21 |
-
```
|
| 22 |
-
|
| 23 |
-
**统一 AI API 代理网关**
|
| 24 |
-
|
| 25 |
-
[](.)
|
| 26 |
-
[](.)
|
| 27 |
-
[](.)
|
| 28 |
-
[](.)
|
| 29 |
-
|
| 30 |
-
<br/>
|
| 31 |
-
|
| 32 |
-
> 一个运行在 HuggingFace Space 上的高性能 AI API 代理,<br/>
|
| 33 |
-
> 统一接入 Claude · Gemini · OpenAI · Codex · Vertex AI
|
| 34 |
-
|
| 35 |
-
<br/>
|
| 36 |
-
|
| 37 |
-
</div>
|
| 38 |
-
|
| 39 |
-
---
|
| 40 |
-
|
| 41 |
-
## ⚡ 支持的模型
|
| 42 |
-
|
| 43 |
-
| 提供商 | 支持模型 | 接入方式 |
|
| 44 |
-
|--------|----------|----------|
|
| 45 |
-
| 🟣 **Anthropic Claude** | Claude 4.5 / 4.6 全系列 | API Key |
|
| 46 |
-
| 🔵 **Google Gemini** | Gemini 3.1 Pro / Flash | API Key |
|
| 47 |
-
| 🟢 **OpenAI** | GPT-5.1 / GPT-5.2 | API Key |
|
| 48 |
-
| 🟡 **Vertex AI** | Gemini on Vertex | 服务账号 |
|
| 49 |
-
| ⚪ **OpenAI-compat** | 任意兼容 OpenAI 格式的服务 | API Key |
|
| 50 |
-
|
| 51 |
-
---
|
| 52 |
-
|
| 53 |
-
## 🚀 快速接入
|
| 54 |
-
|
| 55 |
-
将你的 API Base URL 替换为本 Space 地址即可:
|
| 56 |
-
|
| 57 |
-
```bash
|
| 58 |
-
# 原始请求
|
| 59 |
-
curl https://api.anthropic.com/v1/messages ...
|
| 60 |
-
|
| 61 |
-
# 替换为本代理
|
| 62 |
-
curl https://[user_name]-[space_name].hf.space/v1/messages \
|
| 63 |
-
-H "x-api-key: 你的访问密钥" \
|
| 64 |
-
-H "Content-Type: application/json" \
|
| 65 |
-
-d '{"model": "claude-4-6-sonnet", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'
|
| 66 |
-
```
|
| 67 |
-
|
| 68 |
-
### Python 示例
|
| 69 |
-
|
| 70 |
-
```python
|
| 71 |
-
import anthropic
|
| 72 |
-
|
| 73 |
-
client = anthropic.Anthropic(
|
| 74 |
-
api_key="你的访问密钥",
|
| 75 |
-
base_url="https://[user_name]-[space_name].hf.space",
|
| 76 |
-
)
|
| 77 |
-
|
| 78 |
-
message = client.messages.create(
|
| 79 |
-
model="claude-4-6-sonnet",
|
| 80 |
-
max_tokens=1024,
|
| 81 |
-
messages=[{"role": "user", "content": "你好!"}]
|
| 82 |
-
)
|
| 83 |
-
print(message.content)
|
| 84 |
-
```
|
| 85 |
-
|
| 86 |
-
### OpenAI SDK 兼容
|
| 87 |
-
|
| 88 |
-
```python
|
| 89 |
-
from openai import OpenAI
|
| 90 |
-
|
| 91 |
-
client = OpenAI(
|
| 92 |
-
api_key="你的访问密钥",
|
| 93 |
-
base_url="https://[user_name]-[space_name].hf.space/openai",
|
| 94 |
-
)
|
| 95 |
-
|
| 96 |
-
response = client.chat.completions.create(
|
| 97 |
-
model="gpt-5.1",
|
| 98 |
-
messages=[{"role": "user", "content": "你好!"}]
|
| 99 |
-
)
|
| 100 |
-
```
|
| 101 |
-
|
| 102 |
-
---
|
| 103 |
-
|
| 104 |
-
## 🏗️ 技术架构
|
| 105 |
-
|
| 106 |
-
```
|
| 107 |
-
┌─────────────────────────────────────────────────────┐
|
| 108 |
-
│ HuggingFace Space │
|
| 109 |
-
│ │
|
| 110 |
-
│ Client Request │
|
| 111 |
-
│ │ │
|
| 112 |
-
│ ▼ │
|
| 113 |
-
│ ┌─────────────┐ ┌──────────────────────┐ │
|
| 114 |
-
│ │ │ │ Supabase PostgreSQL │ │
|
| 115 |
-
│ │ CLIProxyAPI │◄──────►│ Token Store │ │
|
| 116 |
-
│ │ :7860 │ │ Config Store │ │
|
| 117 |
-
│ │ │ └──────────────────────┘ │
|
| 118 |
-
│ └──────┬──────┘ │
|
| 119 |
-
│ │ │
|
| 120 |
-
└──────────┼──────────────────────────────────────────┘
|
| 121 |
-
│
|
| 122 |
-
┌──────┴───────┐
|
| 123 |
-
│ │
|
| 124 |
-
▼ ▼
|
| 125 |
-
Anthropic Google
|
| 126 |
-
Claude API Gemini API
|
| 127 |
-
```
|
| 128 |
-
|
| 129 |
-
---
|
| 130 |
-
|
| 131 |
-
## ⚙️ 部署配置
|
| 132 |
-
|
| 133 |
-
### 必需环境变量
|
| 134 |
-
|
| 135 |
-
在 HuggingFace Space **Settings → Secrets** 中配置:
|
| 136 |
-
|
| 137 |
-
| 变量名 | 说明 | 示例 |
|
| 138 |
-
|--------|------|------|
|
| 139 |
-
| `PGSTORE_DSN` | PostgreSQL 连接字符串 | `postgresql://user:pass@host:6543/postgres?sslmode=require` |
|
| 140 |
-
| `MANAGEMENT_PASSWORD` | 管理后台密码 | `your-secure-password` |
|
| 141 |
-
|
| 142 |
-
## 🔑 添加 API Key
|
| 143 |
-
|
| 144 |
-
服务启动后,通过管理接口添加你的 API Key:
|
| 145 |
-
|
| 146 |
-
```bash
|
| 147 |
-
# 添加 Claude Key
|
| 148 |
-
curl -X POST https://[user_name]-[space_name].hf.space/management/clients \
|
| 149 |
-
-H "Authorization: Bearer $MANAGEMENT_PASSWORD" \
|
| 150 |
-
-H "Content-Type: application/json" \
|
| 151 |
-
-d '{
|
| 152 |
-
"name": "my-client",
|
| 153 |
-
"claude-keys": ["sk-ant-api03-xxxxx"]
|
| 154 |
-
}'
|
| 155 |
-
|
| 156 |
-
# 添加 Gemini Key
|
| 157 |
-
curl -X POST https://[user_name]-[space_name].hf.space/management/clients \
|
| 158 |
-
-H "Authorization: Bearer $MANAGEMENT_PASSWORD" \
|
| 159 |
-
-H "Content-Type: application/json" \
|
| 160 |
-
-d '{
|
| 161 |
-
"name": "my-client",
|
| 162 |
-
"gemini-keys": ["AIzaSy-xxxxx"]
|
| 163 |
-
}'
|
| 164 |
-
```
|
| 165 |
-
|
| 166 |
-
---
|
| 167 |
-
|
| 168 |
-
<div align="center">
|
| 169 |
-
<br/>
|
| 170 |
-
|
| 171 |
-
Built with ❤️ · Powered by [CLIProxyAPI](https://github.com/eceasy/cli-proxy-api) · Hosted on [HuggingFace](https://huggingface.co)
|
| 172 |
-
|
| 173 |
-
<br/>
|
| 174 |
-
|
| 175 |
-
</div>
|
|
|
|
| 1 |
+
测试
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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