前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >[已解决] openai.error.AuthenticationError: No API key provided. You can set your API key in code using

[已解决] openai.error.AuthenticationError: No API key provided. You can set your API key in code using

作者头像
Maynor
发布2023-10-17 08:54:11
5190
发布2023-10-17 08:54:11
举报

openai.error.AuthenticationError: No API key provided. You can set your API key in code using ‘openai.api_key = ’, or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with ‘openai.api_key_path = ’. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details.

问题

Python环境没有设置OPENAI_API_KEY

思路

在 Windows 系统中,设置环境变量有两种主要方法:通过系统属性设置和使用 PowerShell 或命令提示符。

通过系统属性设置环境变量
  1. 右键点击 “计算机” 或 “此电脑”,然后点击 “属性”。
  2. 在左侧菜单中,点击 “高级系统设置”。
img
img
  1. 在 “系统属性” 对话框中,点击 “高级” 选项卡,然后点击下方的 “环境变量” 按钮。
img
img
  1. 在 “环境变量” 对话框中,点击 “新建”(在 “用户变量” 部分下),然后输入以下信息:
  • 变量名:OPENAI_API_KEY
  • 变量值:[你的 OpenAI API 密钥]
img
img
  1. 点击 “确定” 保存设置。
解决
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2023-10-16,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • openai.error.AuthenticationError: No API key provided. You can set your API key in code using ‘openai.api_key = ’, or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with ‘openai.api_key_path = ’. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details.
  • 问题
  • 思路
    • 通过系统属性设置环境变量
      • 解决
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档