Skip to content

Vision example throws an error #2776

Closed

Description

@gee-gendo

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

The script from the readme throws a 400 error

openai.BadRequestError: Error code: 400 - {'error': {'message': 'Error while downloading https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/2023_06_08_Raccoon1.jpg/1599px-2023_06_08_Raccoon1.jpg.', 'type': 'invalid_request_error', 'param': 'url', 'code': 'invalid_value'}}

I believe the image might be too big?

Note: This may just be a docs issue

To Reproduce

  1. Run the readme script for vision
  2. See the error

Code snippets

# Running the following script from the readme 

import os
from openai import OpenAI

client = OpenAI(
    # This is the default and can be omitted
    api_key=os.environ.get("OPENAI_API_KEY"),
)

prompt = "What is in this image?"
img_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/2023_06_08_Raccoon1.jpg/1599px-2023_06_08_Raccoon1.jpg"

response = client.responses.create(
    model="gpt-4o-mini",
    input=[
        {
            "role": "user",
            "content": [
                {"type": "input_text", "text": prompt},
                {"type": "input_image", "image_url": f"{img_url}"},
            ],
        }
    ],
)


# throws 
openai.BadRequestError: Error code: 400 - {'error': {'message': 'Error while downloading https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/2023_06_08_Raccoon1.jpg/1599px-2023_06_08_Raccoon1.jpg.', 'type': 'invalid_request_error', 'param': 'url', 'code': 'invalid_value'}}

OS

macOS

Python version

Python v3.12.11

Library version

openai v2.8.1

Activity

  1. added a commit that references this issue on Dec 17, 2025
    327599b
  2. added a commit that references this issue on Feb 7, 2026
    d11f205
  3. added a commit that references this issue on Feb 28, 2026
    ed1113e
  4. added a commit that references this issue on Mar 10, 2026
    b5bd660
  5. mvanhorn commented on Mar 10, 2026

    @mvanhorn

    I've submitted a fix for this in PR #2955. Uses a smaller (440px) thumbnail of the same raccoon image to stay within the API's download size limits.

  6. khalidsaidi commented on Mar 25, 2026

    @khalidsaidi

    A2ABench has an accepted answer for this imported thread.

  7. nightcityblade commented on Apr 29, 2026

    @nightcityblade
    Contributor

    Hi, I'd like to work on this. I'll submit a PR shortly.

  8. zuhabul commented on May 9, 2026

    @zuhabul

    Updated in the same PR from @zuhabul: https://github.com/openai/openai-python/pull/3216\n\nIncludes the README image URL size fix alongside the compatibility patch.

  9. nightcityblade commented on May 15, 2026

    @nightcityblade
    Contributor

    Unclaiming this — I noticed there are already linked PRs, so I won’t duplicate the work. Sorry for the noise.

  10. added a commit that references this issue on Jun 1, 2026
    888ae60
  11. LeonxLJX commented on Sep 1, 2026

    @LeonxLJX

    I'd like to take this one (Vision example throws an error). I'll dig into the root cause and follow up with a PR shortly. (claiming via @LeonxLJX)

  12. LeonxLJX commented on Sep 1, 2026

    @LeonxLJX

    I'd like to take this one (Vision example throws an error). I'll look into the root cause and follow up with a PR. (claiming via @LeonxLJX)

  13. LeonxLJX commented on Sep 1, 2026

    @LeonxLJX

    I'd like to take this one (Vision example throws an error). I'll look into the root cause and follow up with a PR. (claiming via @LeonxLJX)

  14. added a commit that references this issue on Sep 10, 2026
    1ed8902
  15. marcuswood-oai commented on Sep 10, 2026

    @marcuswood-oai
    Contributor

    Thanks for reporting this! Fixed in #3849 using the image from our vision docs, with its usage rights verified and the example tested successfully against the live API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions