DJ1001/sha256
0
Shakker AI Proxy
将 Shakker.ai 的 Stable Diffusion 图片生成能力封装成 OpenAI 兼容 API,支持流式输出。
模型
occult— illust-OccultSemi-realisticILstarry— Ace Starry Night Glint
部署到 Hugging Face Spaces
1. 创建 Space
- 访问 https://huggingface.co/new-space
- 填写 Space 名称
- SDK 选择 Docker
- 点击 Create Space
2. 上传代码
将本仓库代码推送到 Space 的 Git 仓库,或直接上传文件。
3. 配置 Secrets
在 Space 的 Settings → Repository Secrets 中添加:
4. 等待构建
Space 会自动构建 Docker 镜像并启动服务,构建日志可在 Builder 页面查看。
API 使用
列出模型
curl https://your-space-name.hf.space/v1/models \
-H "Authorization: Bearer your-api-key"生成图片
curl https://your-space-name.hf.space/v1/chat/completions \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "occult",
"messages": [{"role": "user", "content": "1girl, cat ears, sunset"}]
}'OpenAI 客户端调用
from openai import OpenAI
client = OpenAI(
base_url="https://your-space-name.hf.space/v1",
api_key="your-api-key"
)
response = client.chat.completions.create(
model="occult",
messages=[{"role": "user", "content": "1girl, cat ears, sunset"}]
)
print(response.choices[0].message.content)本地开发
# 1. 复制环境变量模板
cp .env.example .env
# 编辑 .env 填入真实值
# 2. Docker 启动
docker compose up -d
# 3. 或直接 Python 启动
pip install -r requirements.txt
python main.py