{"id":31640365,"url":"https://github.com/faithererer/siliconflow-img-proxy","last_synced_at":"2026-04-15T20:03:37.375Z","repository":{"id":317034856,"uuid":"1065711931","full_name":"faithererer/siliconflow-img-proxy","owner":"faithererer","description":"将硅基流动的生图接口转为openai兼容格式，包括聊天","archived":false,"fork":false,"pushed_at":"2025-09-28T11:21:49.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-28T12:39:20.189Z","etag":null,"topics":["ai","cloudflare","fuckmylife","proxy"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/faithererer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-28T09:25:16.000Z","updated_at":"2025-09-28T11:21:52.000Z","dependencies_parsed_at":"2025-09-28T12:39:23.058Z","dependency_job_id":null,"html_url":"https://github.com/faithererer/siliconflow-img-proxy","commit_stats":null,"previous_names":["faithererer/siliconflow-img-proxy"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/faithererer/siliconflow-img-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faithererer%2Fsiliconflow-img-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faithererer%2Fsiliconflow-img-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faithererer%2Fsiliconflow-img-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faithererer%2Fsiliconflow-img-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/faithererer","download_url":"https://codeload.github.com/faithererer/siliconflow-img-proxy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/faithererer%2Fsiliconflow-img-proxy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278708135,"owners_count":26031959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","cloudflare","fuckmylife","proxy"],"created_at":"2025-10-07T02:22:49.800Z","updated_at":"2025-10-07T02:22:53.592Z","avatar_url":"https://github.com/faithererer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# siliconflow-img-proxy\n\n将 硅基流动生图 API 转成 OpenAI 兼容接口，可用于 Cherry Studio、OneAPI/NewAPI 等聚合平台，直接在聊天里以 Markdown 形式显示图片。\n\n`/v1/images/generations`：OpenAI 兼容生图\n\n`/v1/chat/completions`：Markdown 图片输出（`![image](URL)` 或 data:URI）\n\n独立访问鉴权：ALLOW_CLIENT_KEY(S)（与上游 SILICONFLOW_API_KEY 完全分离）\n\n可配置 /v1/models：通过环境变量提供模型清单\n\n多图：`n` 顺序多次；或 `sf_batch_size`（若上游模型支持批量）\n\n自定义参数：`sf_seed、sf_num_steps、sf_guidance_scale、sf_cfg、sf_negative_prompt、sf_image_size、sf_batch_size` 和官方文档一致\n\n# 部署\n\n\n# 🔐 环境变量\n\n\n| 变量名                                      | 是否必填 | 说明                                                                                                                               |\n| ---------------------------------------- | ---- | -------------------------------------------------------------------------------------------------------------------------------- |\n| `SILICONFLOW_API_KEY`                    | ✅    | 上游硅基流动 Bearer Key（仅服务端使用，客户端不能覆盖）                                                                                                |\n| `SF_BASE`                                | 选填   | 上游地址，默认 `https://api.siliconflow.cn/v1`                                                                                          |\n| `PROVIDER_LABEL`                         | 选填   | `/v1/chat` 顶层 `provider` 字段，默认 `SiliconFlow`                                                                                     |\n| `ALLOW_CLIENT_KEY` / `ALLOW_CLIENT_KEYS` | ✅*   | **代理访问密钥**（一个或多个，逗号/空白分隔）。任一存在即开启鉴权；未配置则公开（不建议）。                                                                                 |\n| `MODELS_JSON`                            | 选填   | `/v1/models` 的 JSON 数组，如：`[{\"id\":\"Qwen/Qwen-Image\"},{\"id\":\"Kwai-Kolors/Kolors\"}]`，也可用 `[\"Qwen/Qwen-Image\",\"Kwai-Kolors/Kolors\"]` |\n| `MODELS`                                 | 选填   | `/v1/models` 的逗号/空白分隔清单，如：`Qwen/Qwen-Image, Kwai-Kolors/Kolors`                                                                  |\n# 🧪 API\n## 1) 生成图片（OpenAI 兼容）\n\n`POST /v1/images/generations`\n\n```bash\ncurl -X POST \"https://\u003cworker\u003e/v1/images/generations\" \\\n  -H \"Authorization: Bearer \u003cproxy_key\u003e\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"Qwen/Qwen-Image\",\n    \"prompt\": \"a vintage camera on a wooden desk, warm light\",\n    \"size\": \"1024x1024\",\n    \"n\": 2,\n    \"response_format\": \"url\",\n    \"sf_seed\": 1234567890,\n    \"sf_num_steps\": 28,\n    \"sf_guidance_scale\": 7.5,\n    \"sf_cfg\": 3.5,\n    \"sf_negative_prompt\": \"low quality\",\n    \"sf_batch_size\": 2\n  }'\n\n```\n\n多图策略\n\n若设置 sf_batch_size 且模型支持批量，且 n=1：一次批量返回多张；\n\n否则按 n 次数顺序多次调用上游返回多张。\n\n\n\n## 2) 聊天出图（Markdown 渲染）\n\n`POST /v1/chat/completions`\n\n多轮对话：总是取 messages 中最新的 user 消息为 prompt\n\n输出：message.content 为 Markdown 图片\n\nresponse_format=url：`![image](https://...)`\n\nresponse_format=b64_json：`![image](data:image/png;base64,...)`\n```bash\ncurl -X POST \"https://\u003cworker\u003e/v1/chat/completions\" \\\n  -H \"Authorization: Bearer \u003cproxy_key\u003e\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"Qwen/Qwen-Image\",\n    \"messages\": [\n      {\"role\":\"system\",\"content\":\"You are a helpful AI.\"},\n      {\"role\":\"user\",\"content\":\"画两张蓝色机器人，木质桌面，冷色调\"}\n    ],\n    \"n\": 2,\n    \"size\": \"1024x1024\"\n  }'\n\n```\n\n\n## GET /v1/models\n通过`MODELS`等环境变量配置\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaithererer%2Fsiliconflow-img-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffaithererer%2Fsiliconflow-img-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffaithererer%2Fsiliconflow-img-proxy/lists"}