POC: I’ve successfully created a custom GPT through the web interface using GPT-4 which is highly effective in interpreting meal images and determining the ingredients among other things. So the proof is that openai is capable of what I need to implement.
Now attempting to implement this in my own code using the OpenAI APIs has hit a bottle neck. When I pass the image_url with my base64 image thought the user message into the payload and post, I receive the response:
Request too large for gpt-4-turbo-preview in organization org-{mine} on tokens per min (TPM): Limit 30000, Requested 37349. The input or output tokens must be reduced in order to run successfully. Visit https://platform.openai.com/account/rate-limits to learn more
This is even after resizing the image down considerably.
Resizing below say 600px wide for example on most images gets around this issue with the tokens below the 30k limit, yet this presents another issue:
The image is too low in resolution for the analysis to be accurate. The response itself often replies with this complaint or simply returns inaccurate information.
I’ve tried a variety of models that support image analysis and even those that don’t without any success.
So my question is:
Am I missing something? I tried editing the limits to higher values in the organisation setup.
I’ve only recently setup my account so even though I’ve added Credits I’m apparently on the ‘Free tier’ and the next tier is ‘usage tier 1’.
Do I have to wait or use this up first? How can I advance to a practical level of usage if I want to get his app out in 1 weeks time?
Thanks in advance for your thoughts and what you’ve experienced.
PS: I’m aware of other questions related eg: “hitting-rate-limit-on-gpt-4-vision-preview-with-first-query/479464” but my question is how to speed up this process. I’m wanting to use the platform commercially but these seems to be a barrier to real use-cases?
PS2: I just took out the image and the prompt_tokens have dropped considerably.
usage: { prompt_tokens: 176, completion_tokens: 46, total_tokens: 222 },
There is something wrong with how the tokens are being calculated for my image.
Here’s the javascript that brings in the image:
const response = await fetch(
'https://www.domain.com/pesto-chicken-omelette-3.jpg'
, {mode: 'no-cors'});
const imgBuffer = await response.buffer();
const resized = await sharp(imgBuffer).resize({width: 600}).toBuffer();
const base64image = `data:image/jpg;base64,`+resized.toString('base64');
console.log('Response Blob ', base64image );
Now the chat completions:
Note: I’m using the official npm package openai
const completion = await openai.chat.completions.create({
model: 'gpt-4-turbo',
temperature: 0.6,
messages: [
<my under 10 lines of system, content rules>
{ role: 'system', content: base64image }, // the user provided image
]
});
According to the token calculatores, this should not be exceeding 30K tokens. It should be under 700.