当您在使用 API 时遇到 “Invalid API Key” 或 “Authentication failed” 错误,通常不是 key 本身的问题,而是 Base URL 配置不匹配。

常见原因

1. Base URL 未配置或配置错误

这是最常见的原因。如果您使用了 weelinking 的 API Key,必须配合 weelinking 的 Base URL 使用。 错误示例: 使用了 weelinking 的 Key (sk-...),但请求发往了 OpenAI 官方地址 (https://api.openai.com/v1)。 正确配置:
  • Base URL: https://api.weelinking.com/v1

2. 客户端默认设置

很多开源软件(如 LangChain, OpenAI Python SDK)默认连接官方服务器。您需要显式指定 base_url 参数。

解决方法

代码中修改

Python (OpenAI SDK):
from openai import OpenAI

client = OpenAI(
    api_key="your-weelinking-key",
    base_url="https://api.weelinking.com/v1"  # 必须指定
)
Node.js:
const OpenAI = require('openai');

const client = new OpenAI({
  apiKey: 'your-weelinking-key',
  baseURL: 'https://api.weelinking.com/v1' // 必须指定
});

环境变量修改

如果您无法修改代码,可以设置环境变量:
export OPENAI_API_BASE="https://api.weelinking.com/v1"

快速测试

使用 curl 命令测试您的 key 是否有效:
curl https://api.weelinking.com/v1/models \
  -H "Authorization: Bearer sk-your-key-here"
如果此命令返回模型列表,说明 key 是有效的,问题在于您的软件配置。