Skip to content

Image Example - base64 and URL pair incomplete code snippet #1684

@CNX-Inc

Description

@CNX-Inc

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

NOTE: This is an issue with the _documentation_ of the python library not the *functionality*

It seems like one of the example code snippets is incomplete/incorrect

More specifically, the example states: The Chat Completions API is capable of taking in and processing multiple image inputs in both base64 encoded format or as an image URL.

However, the code itself shows only the image URL reference (twice):

    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "What are in these images? Is there any difference between them?",
        },
        {
          "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",
          },
        },
        {
          "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",
          },
        },
      ],
    }
  ],```

### To Reproduce

Read the python documentation at: https://platform.openai.com/docs/guides/vision/multiple-image-inputs

### Code snippets

```Python
I suspect the code example should be something like:

=[
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "What are in these images? Is there any difference between them?",
        },
        {
          "type": "image_url",
          "image_url": {
            "url": f"data:image/jpeg;base64,{base64_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",
          },
        },
      ],
    }
  ],

Note the change of one of the Wikimedia URLS to: `"url": f"data:image/jpeg;base64,{base64_image}"`

OS

Any

Python version

Any

Library version

Any

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