#8928 OpenAI ChatGPT: Missing credentials. Please pass an `api_key`, `workload_identity`, `admin_api_key`, or set the `OPENAI_

2602**219 Posted at: 9 hours ago

OpenAI ChatGPT: Missing credentials. Please pass an api_key, workload_identity, admin_api_key, or set the OPENAI_API_KEY or OPENAI_ADMIN_KEY environment variable.,
Traceback (most recent call last):
File "videotrans\translator\_base.py", line 82, in run
File "videotrans\translator\_base.py", line 165, in _run_srt
File "tenacity\__init__.py", line 338, in wrapped_f
File "tenacity\__init__.py", line 477, in call
File "tenacity\__init__.py", line 378, in iter
File "tenacity\__init__.py", line 421, in exc_check
tenacity.RetryError: RetryError[]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "videotrans\util\TestSrtTrans.py", line 19, in run
File "videotrans\translator\_runner.py", line 71, in run
File "videotrans\translator\_base.py", line 85, in run
File "tenacity\__init__.py", line 480, in call
File "videotrans\translator\_openaicompat.py", line 99, in _item_task
File "videotrans\translator\_openaicompat.py", line 38, in _create_completion
File "openai\_client.py", line 194, in init
openai.OpenAIError: Missing credentials. Please pass an api_key, workload_identity, admin_api_key, or set the OPENAI_API_KEY or OPENAI_ADMIN_KEY environment variable.


=
system:Windows-10-10.0.19045-SP0
version:v4.19
frozen:True
language:zh_CN
root_dir:D:/翻译配音软件

3 Replies

#1 DeepSeek reply at 9 hours ago

这是因为所选翻译渠道为 OpenAI ChatGPT,但软件中该渠道的 API Key 未填写(或填写后未保存成功),导致 openai 客户端初始化时找不到凭证,直接抛出 Missing credentials。

解决方案

  1. 打开顶部菜单 翻译设置 → OpenAI ChatGPT。
  2. 在设置窗口中填写:

    • API 地址:使用官方接口填 https://api.openai.com/v1;使用中转/兼容接口则填对方提供的完整地址(通常以 /v1 结尾)。
    • API Key:填写以 sk- 开头的密钥(中转站提供的 key 也填此处)。
  3. 点击 保存,再点击窗口内的 测试 按钮,确认能正常返回翻译结果。
  4. 回到主界面重新选择该渠道并执行。
  5. 若不想用 OpenAI,可将翻译渠道换成 DeepSeek(物美价廉,中文效果好)或免费的 Microsoft(免费),同样需先在 翻译设置 → DeepSeek 中填写密钥。

常见排查点

  • 填写后未点保存即关闭窗口,配置不生效(配置持久化在 videotrans/params.json)。
  • 使用了国内直连且未填代理,官方 api.openai.com 无法访问,需在主界面右侧 网络代理 填 http://127.0.0.1:端口。
  • 若确认密钥已正确填写仍报此错,可删除 videotrans/params.json 后重启软件重新填写(注意会清空其他已保存密钥,建议先备份)。

请查阅相关文档:

#2 2602**219 reply at 9 hours ago

key密钥在哪获得

#3 DeepSeek reply at 9 hours ago

本软件的密钥均需到对应服务商官网自行注册并申请,软件不会内置或代发密钥。以下是常用渠道的获取地址:

翻译渠道密钥获取地址说明
OpenAI ChatGPThttps://platform.openai.com/api-keys注册 OpenAI 账号,进入 API Keys 页面点击 Create new secret key,生成以 sk- 开头的密钥。国内需科学上网且需绑卡充值
DeepSeek(最推荐)https://platform.deepseek.com/手机号注册后登录,进入 API keys 页面创建密钥;支持自定义充值(最低 1 元),价格低、中文翻译质量好,国内直连无需代理
智谱 AIhttps://open.bigmodel.cn/注册后在控制台创建 API Key,有免费额度
阿里百炼https://www.aliyun.com/product/bailian开通百炼服务后在控制台创建 API Key
硅基流动https://cloud.siliconflow.cn/注册后创建密钥,部分模型有免费额度
302.AIhttps://302.ai注册后获取 appkey,按量付费
DeepLhttps://www.deepl.com需国际信用卡开通 DeepL API 服务

获取后的填写方法:打开软件顶部菜单 翻译设置 → 选择对应渠道 → 把密钥粘贴到 API Key(或密钥)输入框 → 点击 保存,切勿直接关闭窗口,否则不会生效。

若你用的是第三方中转/兼容接口,密钥由该中转站提供,API 地址也要填对方给的地址,而不是官方地址。

请查阅相关文档:

Thinking...
Post Your Reply
If you have more than 50 messages, you will no longer receive an automatic reply. Please ask a new question!
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update.

Dondate via ko-fi.com

Related resource