Quickstart cURL command prompt API tutorial Copy3 returning errors

In the quickstart for API usage for cURL, if anybody is following the tut and is confused when, after setting their env variable with setx, their command prompt’s response to “echo %OPENAI_API_KEY%” is just “%OPENAI_API_KEY%” , it appears that what the guide says about “current session” is referring to future sessions- all you have to do is start a new cmd prompt and “echo %OPENAI_API_KEY%” will properly display your API key.

Where I’m stuck now is that when I copy the command from the tut

curl -H “Content-Type: application/json” -H “Authorization: Bearer $OPENAI_API_KEY” -d ‘{
“model”: “gpt-3.5-turbo”,
“messages”: [
{
“role”: “system”,
“content”: “You are a poetic assistant, skilled in explaining complex programming concepts with creative flair.”
},
{
“role”: “user”,
“content”: “Compose a poem that explains the concept of recursion in programming.”
}
]
}’"

and paste it into the command prompt, it’s making a series of errors, almost as if things aren’t spaced properly or it isn’t parsing the whole command at once, it’s like it’s trying each piece one command at a time:

"C:\Users\SCMza>curl -H “Content-Type: application/json” -H “Authorization: Bearer $OPENAI_API_KEY” -d '{
{
“error”: {
“message”: "Incorrect API key provided: $OPENAI_***_KEY. You can find your API key at ",
“type”: “invalid_request_error”,
“param”: null,
“code”: “invalid_api_key”
}
}

C:\Users\SCMza> “model”: “gpt-3.5-turbo”,
‘“model”:’ is not recognized as an internal or external command,
operable program or batch file.

C:\Users\SCMza> “messages”: [
‘“messages”:’ is not recognized as an internal or external command,
operable program or batch file.

C:\Users\SCMza> {
‘{’ is not recognized as an internal or external command,
operable program or batch file.

C:\Users\SCMza> “role”: “system”,
‘“role”:’ is not recognized as an internal or external command,
operable program or batch file."

Etc. Etc.

I just wanted to bring it to leadership’s attention that if the intention of the quickstart was for me to just be able to paste several commands into command prompt and get a result with this cURL, that (at least for me) I’m not getting the intended result.

I will get on cgpt4 and see if it can help me figure out what is wrong

Thanks, Zach

[edit, it made me remove the URL links to post this]

Amazing! Cgpt4 provided the corrected code if one is using cURL from the command prompt:

“curl (endpoint) ^
-H “Content-Type: application/json” ^
-H “Authorization: Bearer %OPENAI_API_KEY%” ^
-d “{”“model””: ““gpt-3.5-turbo””, ““messages””: [{““role””: ““system””, ““content””: ““You are a poetic assistant, skilled in explaining complex programming concepts with creative flair.””}, {““role””: ““user””, ““content””: ““Compose a poem that explains the concept of recursion in programming.””}]}"
"

I would request that the Quickstart for the cURL section be updated with the correct command, as what is provided for Copy3 is not what one should paste into the command prompt.