Skip to content

Chat Completion with Image Input is not working #3

@IvanVohmin

Description

@IvanVohmin

I was trying to use an image input in my chat completion, but it appears its not working at all.
My code:


client = OpenAIUnofficial()
response = client.chat.completions.create(
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What's in this image?"},
            {
                "type": "image_url",
                "image_url": {
                    "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
                }
            },
        ],
    }],
    model="gpt-4o-mini-2024-07-18"
)
print("Response:", response.choices[0].message.content)``` 


and console return this error: 


```File "C:\Users\~\AppData\Local\Programs\Python\Python310\lib\site-packages\openai_unofficial\main.py", line 256, in create
    response = self.api_handler._make_request(
  File "C:\Users\~\AppData\Local\Programs\Python\Python310\lib\site-packages\openai_unofficial\main.py", line 65, in _make_request
    getattr(e.response, 'json', lambda: None)())
  File "C:\Users\~\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 
0)```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions