better-judge-10532
10/20/2025, 11:20 PMwide-umbrella-5226
10/20/2025, 11:42 PMwide-umbrella-5226
10/20/2025, 11:42 PMbetter-judge-10532
10/21/2025, 12:30 AMbetter-judge-10532
10/21/2025, 12:35 AMwide-umbrella-5226
10/21/2025, 12:56 AMwide-umbrella-5226
10/21/2025, 12:57 AMwide-umbrella-5226
10/21/2025, 12:57 AMbetter-judge-10532
10/21/2025, 12:59 AMwide-umbrella-5226
10/21/2025, 12:59 AMwide-umbrella-5226
10/21/2025, 1:08 AMwide-umbrella-5226
10/21/2025, 1:08 AMbetter-judge-10532
10/21/2025, 3:39 AMbetter-judge-10532
10/21/2025, 3:40 AMwide-umbrella-5226
10/21/2025, 1:08 PMjavascript
const url = 'https://api.openai.com/v1/chat/completions';
const headers = {
'Authorization': 'Bearer YOUR-KEY-HERE', // replace with your OpenAI API key
'Content-Type': 'application/json',
};
const imageUrl = `${event.payload.imageUrl}`;
const userPrompt = `Please transcribe or describe the text content visible in this image. If the image contains text in another language, keep the original language.`;
const data = {
"model": "gpt-4o-mini",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": userPrompt
},
{
"type": "image_url",
"image_url": {
"url": imageUrl
}
}
]
}
],
"max_tokens": 1000
};
// Retry function for 429 errors
const retryRequest = async (requestFn, maxRetries = 3) => {
for (let i = 0; i <= maxRetries; i++) {
const response = await requestFn();
if (response.status !== 429 || i === maxRetries) {
return response;
}
const delay = Math.pow(2, i) * 1000;
await new Promise(resolve => setTimeout(resolve, delay));
}
};
const response = await retryRequest(() => axios.post(url, data, { headers }));
const generatedMessage = response.data.choices[0].message.content;
workflow.transcription = generatedMessage;wide-umbrella-5226
10/21/2025, 1:08 PMwide-umbrella-5226
10/21/2025, 1:08 PMwide-umbrella-5226
10/21/2025, 1:08 PMbetter-judge-10532
10/21/2025, 9:57 PM