My prompt for generating alt text is 8500 tokens. Is that right?

Hi, I’ve been using ChatGPT to help me make a Wordpress plugin that automatically adds alt-text to images when I upload them.

I think I’ve done everything I should have to reduce the size of the image being passed through - they’re 512px wide webp files. But each request is 8.5k tokens and from reading the documentation that seems too high. Maybe I’m misunderstanding the docs.

If I’m not and instead I’m doing something stupid I’d be very grateful for your help.

Here’s the extract of the php function that sends the request to the API:

function generate_alt_text_using_openai($image_url) {
    $api_key = get_option('openai_api_key');
    $request_body = json_encode(array(
        'model' => 'gpt-4o-mini',
       'messages' => [
           [
               'role' => 'user',
               'content' => [
                   [
                         'type' => 'text',
                         'text' => 'Please generate an alt text for the image:'
                   ],
                   [
                         'type' => 'image_url',
                         'image_url' => [
                             'url' => $image_url
                         ]
                   ]
               ]
            ]
        ],
        'max_tokens' => 500,
    ));

it is expected for mini when used for vision

1 Like

If this is correct, that sucks, was planning on taking advantage of that to start using vision as the current price is not practical.

Thanks @supershaneski. Sorry I didn’t turn up that thread by myself. The docs could definitely do with being updated as they’re obviously speaking to the previous situation.

For my purposes getting the prompt down to 8500 from 25500 is something of a win and I’m probably happy to bear the costs for my purposes.