Skip to content

An openai.APIConnectionError occurred calling the api #1253

@pluto-tu

Description

@pluto-tu

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

Hi ,I can call OpenAI Api interface with my Api key but calling the Api using OpenAI-python results in an error ,it error. can you show how did you solve this problem.
Api example:
`❯ curl https://api.openai.com/v1/chat/completions
-H "Content-Type: application/Json"
-H "Authorization: Bearer key"
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "how to use MySQL!"}],
"temperature": 0.7
}'

{
"id": "cxxxxxx",
"object": "chat. Completion",
"created": 1710945410,
"model": "gpt-3.5-turbo-0125",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "To use MySQL, you will need to follow xxxx"
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 282,
"total_tokens": 294
},
"system_fingerprint": "xxxx"
}`

error log is :
File "/Users/xxx/Library/Caches/pypoetry/virtualenvs/backend-FuQBPevx-py3.11/lib/python3.11/site-packages/openai/_base_client.py", line 1494, in _request
return await self._retry_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/Library/Caches/pypoetry/virtualenvs/backend-FuQBPevx-py3.11/lib/python3.11/site-packages/openai/_base_client.py", line 1563, in _retry_request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
File "/Users/xxxx/Library/Caches/pypoetry/virtualenvs/backend-FuQBPevx-py3.11/lib/python3.11/site-packages/openai/_base_client.py", line 1504, in _request
raise APIConnectionError(request=request) from err
openai.APIConnectionError: Connection error.

To Reproduce

calling the api using openapi-python

Code snippets

No response

OS

mac os

Python version

python3.11

Library version

openapi v 1.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions