API 接口说明

项目概述

这是一个基于 FastAPI 实现的通义千问 API 代理服务器,用于转发和处理与通义千问 API 的通信。

主要功能

环境要求

安装步骤

  1. 克隆项目到本地
  2. 安装依赖:
    pip install -r requirements.txt
  3. 使用 Docker(可选):
    docker build -t qwen-api-proxy .
    docker run -p 8000:8000 qwen-api-proxy

运行服务

python qwen.py

或使用 uvicorn:

uvicorn qwen:app --host 0.0.0.0 --port 8000

服务将在 http://localhost:8000 上运行。

错误处理

获取 API Key

  1. 访问 https://chat.qwenlm.ai/ 并登录
  2. 打开浏览器开发者工具(通常按 F12)
  3. 切换到"应用程序"选项卡
  4. 在左侧菜单中选择"Cookies" -> "https://chat.qwenlm.ai"
  5. 找到名称为"token"的cookie
  6. 复制其值,这就是你的API Key

许可证

本项目采用 MIT License 开源许可证。

GET
/api/models
获取可用模型列表
请求头需要包含 Authorization: Bearer {api_key}
POST
/api/chat/completions
与模型进行对话
请求头需要包含 Authorization: Bearer {api_key}
支持流式响应(stream: true)