[已解决] 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

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. 在左侧菜单中,点击 “高级系统设置”。

  1. 在 “系统属性” 对话框中,点击 “高级” 选项卡,然后点击下方的 “环境变量” 按钮。

  1. 在 “环境变量” 对话框中,点击 “新建”(在 “用户变量” 部分下),然后输入以下信息:
  • 变量名:OPENAI_API_KEY
  • 变量值:[你的 OpenAI API 密钥]

  1. 点击 “确定” 保存设置。

解决


目录
相关文章
|
4月前
|
JSON 应用服务中间件 API
利用Grafana的API Key+Nginx反向代理实现Grafana免登录访问
利用Grafana的API Key+Nginx反向代理实现Grafana免登录访问
110 1
|
3月前
|
安全 网络安全 API
python调用openai api报错self._sslobj.do_handshake()OSError: [Errno 0] Error
python调用openai api报错self._sslobj.do_handshake()OSError: [Errno 0] Error
78 1
python调用openai api报错self._sslobj.do_handshake()OSError: [Errno 0] Error
|
1天前
|
API Python
记录openai官网关于Setup your API key for a single project(为单个项目设置API 可以)的错误(2023/11/24)
记录openai官网关于Setup your API key for a single project(为单个项目设置API 可以)的错误(2023/11/24)
11 0
|
1天前
|
开发工具 git
If you are using the git profile, you need to set a Git URI in your configuration. If you are using
If you are using the git profile, you need to set a Git URI in your configuration. If you are using
7 0
|
2天前
|
API Android开发 开发者
failed to set system property error code: 0x18
failed to set system property error code: 0x18
6 1
|
8天前
|
人工智能 JavaScript API
[译][AI OpenAI-doc] 助手 API Beta
助手 API 允许你在自己的应用程序中构建 AI 助手。助手具有指令,并可以利用模型、工具和文件来响应用户的查询。目前,助手 API 支持三种类型的工具:代码解释器、文件搜索和函数调用。
|
15天前
|
人工智能 API Python
【AI大模型应用开发】1.1 Prompt Engineering(提示词工程)- 用OpenAI API实战,优化方法论总结
【AI大模型应用开发】1.1 Prompt Engineering(提示词工程)- 用OpenAI API实战,优化方法论总结
20 0
|
20天前
|
JSON Java API
在 Spring Boot 中使用 OpenAI ChatGPT API
在 Spring Boot 中使用 OpenAI ChatGPT API
52 1
|
28天前
|
安全 API
OpenAI邮箱API发送邮件注意事项
使用OpenAI邮箱API需注意API密钥安全,避免泄露;确保邮件内容合法合规,不发送垃圾邮件;设置正确发件人信息,防止被视为垃圾邮件;确认收件人信息准确;控制发送频率;保持内容格式规范;记录发送日志;并先进行发送测试。遵循这些提示可确保邮件发送顺利。
|
4月前
|
存储 API 开发工具
如何使用Python SDK与OpenAI Assistants API构建助手?
在这篇文章中,我们将介绍如何使用Python SDK构建最基本的Assistant,你只需要在代码中添加你自己的OpenAI API密钥即可。
123 0