🤖 AI Proxy 接口说明

本服务为透明代理,不存储任何 API Key,请在请求头中携带对应平台的鉴权信息。

⚠️ 安全提醒: 请勿在前端页面直接暴露你的 API Key。建议在你自己的服务端调用本代理,由服务端持有 Key,前端只调用你的服务端。

1. 调用格式

https://fansa91.workers.dev/{平台名}/{接口路径}

示例:https://fansa91.workers.dev/openai/v1/chat/completions

2. 请求头鉴权

请在 HTTP Header 中携带对应平台的 Key:

Authorization: Bearer <你的 API Key>

部分平台使用不同字段:

3. 支持的平台

平台代号上游地址类型
阿里云通义千问qwendashscope.aliyuncs.com国内
月之暗面 (Moonshot)moonshotapi.moonshot.cn国内
智谱 AIzhipuopen.bigmodel.cn国内
MiniMaxminimaxapi.minimaxi.com国内
百度千帆 (Qianfan)baiduqianfan.baidubce.com国内
OpenAIopenaiapi.openai.com海外
Anthropic (Claude)anthropicapi.anthropic.com海外
Google Geminigooglegenerativelanguage.googleapis.com海外
Perplexityperplexityapi.perplexity.ai海外
xAI (Grok)xaiapi.x.ai海外
DeepSeekdeepseekapi.deepseek.com海外
Groqgroqapi.groq.com海外
Together AItogetherapi.together.xyz海外
Coherecohereapi.cohere.ai海外
Mistral AImistralapi.mistral.ai海外
Replicatereplicateapi.replicate.com海外
HuggingFacehuggingfaceapi-inference.huggingface.co海外

4. 调用示例

OpenAI(兼容格式)

curl -X POST https://fansa91.workers.dev/openai/v1/chat/completions   -H "Content-Type: application/json"   -H "Authorization: Bearer sk-your-openai-key"   -d '{"model":"gpt-3.5-turbo","messages":[{"role":"user","content":"你好"}]}'

通义千问

curl -X POST https://fansa91.workers.dev/qwen/chat/completions   -H "Content-Type: application/json"   -H "Authorization: Bearer sk-your-qwen-key"   -d '{"model":"qwen-turbo","messages":[{"role":"user","content":"你好"}]}'

Anthropic (Claude)

curl -X POST https://fansa91.workers.dev/anthropic/v1/messages   -H "Content-Type: application/json"   -H "x-api-key: sk-ant-your-key"   -H "anthropic-version: 2023-06-01"   -d '{"model":"claude-3-haiku-20240307","max_tokens":100,"messages":[{"role":"user","content":"你好"}]}'

5. 注意事项