For those who have access to gpt-4-vision-preview, can you advise if it exists in your Playground, or is it only via API?

It’s working for me when I use “gpt-4-vision-preview” as the model.


Do we have to do this to get instant access? Can someone verify

Initially didn’t work, but then worked for me about 5 mins after topping up my account

Earlier, I didn’t have access to “gpt-4-1106-preview” or “gpt-4-vision-preview” from within Playground. I tried on both the Assistant and Chat modes, but was only getting various gpt-3 options.

So I went to my account, and purchased $5 of credit here:

(which is located in the Settings|Billing menu, where Playground is found)

Now “gpt-4-1106-preview” shows up in the Playground (both Assistant and Chat), HOWEVER, “gpt-4-vision-preview” still does not.

When I try to access “gpt-4-vision-preview” within my Python code, it now works.

1 Like

My company account experienced issues, while my private account functioned without any problems.

can you help me with that??
If possible share a sample code

I thought I didn’t have it too. It turns out it only shows up in Complete ( Legacy) and not in chat. If you go to the Playground and select Complete you should get the option for “gpt-4-vision-preview” if not you will need to add $5 to your account and wait a bit. I find it really odd that something labelled “legacy” has the latest features available. I hope this helps everyone in this thread.

1 Like

I’ve been looking for it in Chat but finally with your help found it in Complete. Thanks :pray:

1 Like

In the Playground, and while in “Assistants” mode, does anyone see “gpt-4-vision-preview” as an option?

I see gpt-4-vision-preview in Completion during Playground but trying to run the python chat completion I’m getting the following message:
The model gpt-4-vision-preview does not exist or you do not have access to it.

I topped up $30 as well.

Anyone figure it out?

1 Like

Yes… I am able to use python to run chat.completions using the gpt-4-vision-preview model. Here is the code I’m using and works:

        system_prompt = "You are an expert analyzing images."
        response = client.chat.completions.create(
            model="gpt-4-vision-preview",
            messages=[
                {
                    "role": "system",
                    "content": [
                        {"type": "text", "text": system_prompt},
                    ],
                },
                {
                    "role": "user",
                    "content": [
                        {
                            "type": "image_url",
                            "image_url": {
                                "url":"https://testimages-s3bucket.s3.amazonaws.com/testimage.png",
                            }
                        },
                    ],
                },
                {
                    "role": "user",
                    "content": [
                        {"type": "text", "text": "What do you see in this photo?"},
                    ],
                }
            ],
            max_tokens=1000,
        )

        print(response.choices[0])
1 Like

Also note that… currently, you cannot use gpt-4-vision-preview with the “assistants” API (it is not available in the Playground, and you cannot access it from your Python code)… However, you can access the gpt-4-vision-preview model with the “chat.completions” API (as shown above and below).

And for those who are looking for a base64 example…

def encode_image(image_path):
with open(image_path, “rb”) as image_file:
return base64.b64encode(image_file.read()).decode(‘utf-8’)

encoded_string = encode_image(“testimage.png”)

system_prompt = “You are an expert at analyzing images.”
response = client.chat.completions.create(
model=“gpt-4-vision-preview”,
messages=[
{
“role”: “system”,
“content”: [
{“type”: “text”, “text”: system_prompt},
],
},
{
“role”: “user”,
“content”: [
{
“type”: “image_url”,
“image_url”: {
“url”: f"data:image/jpeg;base64,{encoded_string}"
}
}
],
},
{
“role”: “user”,
“content”: [
{“type”: “text”, “text”: “What do you see in this image?”},
],
}
],
max_tokens=1000,
)

print(response.choices[0])

(Sorry… I can’t seem to get the indentation to work properly on this base64 post)

Your last version, fixed by AI, added imports, added output, formatted with Black.

import base64
from openai import OpenAI

client = OpenAI()


def encode_image(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode("utf-8")


encoded_string = encode_image("sample.png")

system_prompt = "You are an expert at analyzing images."
response = client.chat.completions.create(
    model="gpt-4-vision-preview",
    messages=[
        {
            "role": "system",
            "content": [
                {"type": "text", "text": system_prompt},
            ],
        },
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {"url": f"data:image/jpeg;base64,{encoded_string}"},
                }
            ],
        },
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Describe this art style."},
            ],
        },
    ],
    max_tokens=1000,
)

print(response.choices[0].message.content)
print(response.usage.model_dump())

text output:

The art style in the image you’ve provided appears to be digitally manipulated to resemble a painting, likely through a filter that simulates brush strokes and gives a softer, more textured appearance. The technique emphasizes color blending and has a somewhat impressionistic effect, with broad, smooth strokes that reduce detail and lend a dreamy, ethereal quality to the image. The outlines and finer details of the subjects are softened, which adds a sense of movement and fluidity, a fitting choice for depicting ballet dancers. This style may often be found in digital art applications and can be used to give photographs a more artistic and expressive feel.
response.usage.model_dump()
{‘completion_tokens’: 124, ‘prompt_tokens’: 1133, ‘total_tokens’: 1257}

for another demo image


1792 x 1024 Pixels (1.84 MPixels) (1.75)


round((response.usage.prompt_tokens*0.01 + response.usage.completion_tokens*0.03)/1000, 3)
0.015
1 Like

Pretty slick! Not sure how you did that, but thanks!

For fixing the forum post, ask an AI “format this messed up code”.

Or I ask an AI to keep your image encode function under four tiles, reducing 1133 to 793 prompt tokens.

!pip install pillow

from io import BytesIO
from PIL import Image

def encode_image(image_path):
    with Image.open(image_path) as img:
        width, height = img.size
        max_dim = max(width, height)
        if max_dim > 1024:
            scale_factor = 1024 / max_dim
            new_width = int(width * scale_factor)
            new_height = int(height * scale_factor)
            img = img.resize((new_width, new_height))
        
        buffered = BytesIO()
        img.save(buffered, format="PNG")
        img_str = base64.b64encode(buffered.getvalue()).decode('utf-8')
        return img_str
1 Like

I have it in my Completions tab as well. But how do you upload an image to the Completions page?

1 Like

See how draw-a-ui app passes PNG image in Data URL format (header+Base64) to API:

TLDraw’s fork of draw-a-ui uses same method plus extra prompt to convert screenshot to Tailwind styled web page.

It’s free to try the new image inputs playground by Knit (My personal product), it’s basically the conversation playground + gpt-4-vision image inputs. You are able to upload multiple images per message.

Enough for trying the model quickly to validate ideas.

Same, I see it in completions but no option to upload an image? And when I use my API key on an external site using GPT Vision, it works and I get charged, which means APi calls work…