diff --git a/app/core/auth.py b/app/core/auth.py index 9a07f5a..7c96460 100644 --- a/app/core/auth.py +++ b/app/core/auth.py @@ -22,14 +22,9 @@ async def verify_api_key( """ 验证 Bearer Token - 如果 config.toml 中未配置 api_key,则跳过验证。 - 如果配置了 api_key,则必须提供正确的 Authorization: Bearer 。 + 如果 config.toml 中未配置 api_key,则使用默认密钥 "grok2api"。 """ - api_key = get_config("app.api_key", "") - - # 如果未配置 API Key,直接放行 - if not api_key: - return None + api_key = get_config("app.api_key", "grok2api") if not auth: raise HTTPException( diff --git a/readme.md b/readme.md index 9fad490..976ffa2 100644 --- a/readme.md +++ b/readme.md @@ -188,7 +188,7 @@ curl http://localhost:8000/v1/images/generations \ | :-------------------- | :--------------------------- | :----------- | :--------------------------------------------------- | :-------------------------------------------------------- | | **app** | `app_url` | 应用地址 | 当前 Grok2API 服务的外部访问 URL,用于文件链接访问。 | `http://127.0.0.1:8000` | | | `app_key` | 后台密码 | 登录 Grok2API 服务管理后台的密码,请妥善保管。 | `grok2api` | -| | `api_key` | API 密钥 | 调用 Grok2API 服务所需的 Bearer Token,请妥善保管。 | `""` | +| | `api_key` | API 密钥 | 调用 Grok2API 服务所需的 Bearer Token,请妥善保管。 | `grok2api` | | | `image_format` | 图片格式 | 生成的图片格式(url 或 base64)。 | `url` | | | `video_format` | 视频格式 | 生成的视频格式(仅支持 url)。 | `url` | | **grok** | `temporary` | 临时对话 | 是否启用临时对话模式。 | `true` |