Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

title Oh My API
emoji 🐾
colorFrom pink
colorTo purple
sdk docker
pinned true
license mit

 ██████╗ ██╗  ██╗      ███╗   ███╗██╗   ██╗      █████╗ ██████╗ ██╗
██╔═══██╗██║  ██║      ████╗ ████║╚██╗ ██╔╝     ██╔══██╗██╔══██╗██║
██║   ██║███████║      ██╔████╔██║ ╚████╔╝      ███████║██████╔╝██║
██║   ██║██╔══██║      ██║╚██╔╝██║  ╚██╔╝       ██╔══██║██╔═══╝ ██║
╚██████╔╝██║  ██║      ██║ ╚═╝ ██║   ██║        ██║  ██║██║     ██║
 ╚═════╝ ╚═╝  ╚═╝      ╚═╝     ╚═╝   ╚═╝        ╚═╝  ╚═╝╚═╝     ╚═╝

统一 AI API 代理网关

Version SDK Status License


一个运行在 HuggingFace Space 上的高性能 AI API 代理,
统一接入 Claude · Gemini · OpenAI · Codex · Vertex AI



⚡ 支持的模型

提供商 支持模型 接入方式
🟣 Anthropic Claude Claude 4.5 / 4.6 全系列 API Key
🔵 Google Gemini Gemini 3.1 Pro / Flash API Key
🟢 OpenAI GPT-5.1 / GPT-5.2 API Key
🟡 Vertex AI Gemini on Vertex 服务账号
OpenAI-compat 任意兼容 OpenAI 格式的服务 API Key

🚀 快速接入

将你的 API Base URL 替换为本 Space 地址即可:

# 原始请求
curl https://api.anthropic.com/v1/messages ...

# 替换为本代理
curl https://[user_name]-[space_name].hf.space/v1/messages \
  -H "x-api-key: 你的访问密钥" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-4-6-sonnet", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'

Python 示例

import anthropic

client = anthropic.Anthropic(
    api_key="你的访问密钥",
    base_url="https://[user_name]-[space_name].hf.space",
)

message = client.messages.create(
    model="claude-4-6-sonnet",
    max_tokens=1024,
    messages=[{"role": "user", "content": "你好!"}]
)
print(message.content)

OpenAI SDK 兼容

from openai import OpenAI

client = OpenAI(
    api_key="你的访问密钥",
    base_url="https://[user_name]-[space_name].hf.space/openai",
)

response = client.chat.completions.create(
    model="gpt-5.1",
    messages=[{"role": "user", "content": "你好!"}]
)

🏗️ 技术架构

┌─────────────────────────────────────────────────────┐
│                HuggingFace Space                     │
│                                                     │
│   Client Request                                    │
│        │                                            │
│        ▼                                            │
│   ┌─────────────┐                                   │
│   │             │                                   │
│   │ CLIProxyAPI │                                   │
│   │  :7860      │                                   │
│   │             │                                   │
│   └──────┬──────┘                                   │
│          │                                          │
└──────────┼──────────────────────────────────────────┘
           │
    ┌──────┴───────┐
    │              │
    ▼              ▼
 Anthropic      Google
 Claude API     Gemini API

⚙️ 部署配置

必需环境变量

在 HuggingFace Space Settings → Secrets 中配置:

变量名 说明 示例
MANAGEMENT_PASSWORD 管理后台密码 your-secure-password

🔑 添加 API Key

服务启动后,通过管理接口添加你的 API Key:

# 添加 Claude Key
curl -X POST https://[user_name]-[space_name].hf.space/management/clients \
  -H "Authorization: Bearer $MANAGEMENT_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-client",
    "claude-keys": ["sk-ant-api03-xxxxx"]
  }'

# 添加 Gemini Key  
curl -X POST https://[user_name]-[space_name].hf.space/management/clients \
  -H "Authorization: Bearer $MANAGEMENT_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-client",
    "gemini-keys": ["AIzaSy-xxxxx"]
  }'


Built with ❤️ · Powered by CLIProxyAPI · Hosted on HuggingFace


About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages