OpenAI API curl

Jmnote (토론 | 기여)님의 2024년 1월 4일 (목) 10:47 판 (새 문서: ==개요== ;OpenAPI API curl <syntaxhighlight lang='console'> testuser@localhost:~$ export OPENAI_API_KEY='' testuser@localhost:~$ curl https://api.openai.com/v1/chat/completions -H...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

OpenAPI API curl
testuser@localhost:~$ export OPENAI_API_KEY=''
testuser@localhost:~$ curl https://api.openai.com/v1/chat/completions -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."}]}'
{
    "error": {
        "message": "You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.",
        "type": "invalid_request_error",
        "param": null,
        "code": null
    }
}
testuser@localhost:~$ export OPENAI_API_KEY='sk-moqUsWYAuw9yzb1dCfh3E5GjlnIKpMrt70vxuOPRTVt24Xcd'
testuser@localhost:~$ curl https://api.openai.com/v1/chat/completions -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."}]}'
{
    "error": {
        "message": "You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.",
        "type": "invalid_request_error",
        "param": null,
        "code": null
    }
}

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}