在Windows中使用OpenAI API键的问题

发布于 2025-02-08 04:00:51 字数 570 浏览 2 评论 0原文

我必须在自定义数据集中微调OpenAI模型。我以JSONL格式创建了数据集。我在Windows命令行上使用以下命令:

设置OpenAI_API_KEY =< api键>

openai tools fine_tunes.prepare_data -f“ train_data.jsonl”

给我一些更新JSONL文件的建议。之后,我运行以下命令来微调“居里”模型。

OpenAI API FINE_TUNES.CREATE'openai.api_key =< api键>' -t“ train_data.jsonl” -m“ curie”

,但我会得到以下问题:

←[91merror:←[0m不正确的API密钥提供:“ SK -IQJX ********** ******************************************。您可以在https://beta.openai.com上找到API键。 (HTTP状态代码:401)

任何人都可以帮助我解决这个问题。

I have to fine-tune the OpenAI model on my custom dataset. I have created the dataset in jsonl format. I use the following commands on windows command line:

set OPENAI_API_KEY=<API key>

openai tools fine_tunes.prepare_data -f "train_data.jsonl"

The above commands run successfully and give me some suggestions for updating jsonl file. After this, I run the following command to fine-tune the 'curie' model.

openai api fine_tunes.create 'openai.api_key = <API key>' -t "train_data.jsonl" -m "curie"

But I am getting following issue:

←[91mError:←[0m Incorrect API key provided: "sk-iQJX*****************************************mux". You can find your API key at https://beta.openai.com. (HTTP status code: 401)

Can anybody help me out with this issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

虚拟世界 2025-02-15 04:00:51

在Windows命令提示符中使用以下内容

openai --api-key <OPENAI_API_KEY> api fine_tunes.create -t "[yourfilelocationhere]" -m [modelhere] --suffix "[optional]"

Use the following in the windows command prompt

openai --api-key <OPENAI_API_KEY> api fine_tunes.create -t "[yourfilelocationhere]" -m [modelhere] --suffix "[optional]"
抽个烟儿 2025-02-15 04:00:51

这是较早版本的OpenAI CLI的常见问题。如果还没有,请确保您通过执行

pip install --upgrade openai

一个可能的解决方法来升级到最近的版本,就是使用Python脚本来完成您在CLI中通常会做的事情。

# To train a model:
import os
import openai
os.environ["OPENAI_API_KEY"] = "sk-iQJX*****************************************mux"
os.system("openai api fine_tunes.create -t train_data.jsonl -m curie")

This is a common issue with an earlier version of the openai's CLI. If you haven't already, make sure you upgrade to the most recent version by doing

pip install --upgrade openai

One possible workaround is to just use a python script to do what you would normally do in the CLI.

# To train a model:
import os
import openai
os.environ["OPENAI_API_KEY"] = "sk-iQJX*****************************************mux"
os.system("openai api fine_tunes.create -t train_data.jsonl -m curie")
皇甫轩 2025-02-15 04:00:51

在命令行中分配API键时,请勿使用以下双引号,例如:

api_key = ab-123123123123123123231

这将解决问题

When assigning the API key in command line, dont use double quotes like:

API_KEY=ab-123123123123123231

This will solve the issue

吹梦到西洲 2025-02-15 04:00:51

嗨,此代码将解决问题。在这种情况下,请确保在= OpenAi_Api_Key之前正确设置环境变量:

Get-ExecutionPolicy
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
$headers = @{
"Authorization" = "Bearer $env:OPENAI_API_KEY"
"model" = "text-davinci-002"
}
Invoke-WebRequest -Uri "https://api.openai.com/v1/models" -Headers  $headers
Get-ChildItem Env:OPENAI_API_KEY

最好,Alexis

Hi this code will solve the problem. Make sure you set your environment variable properly before =OPENAI_API_KEY in this case:

Get-ExecutionPolicy
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
$headers = @{
"Authorization" = "Bearer $env:OPENAI_API_KEY"
"model" = "text-davinci-002"
}
Invoke-WebRequest -Uri "https://api.openai.com/v1/models" -Headers  $headers
Get-ChildItem Env:OPENAI_API_KEY

Best, Alexis

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文