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