Hi there! As of right now I am using Sonar for my school project, and the demo was a bit… failed because the Sonar API is constantly returning 400 error on any image url inputs.
Payload:
{
"search_mode": "web",
"temperature": 0.2,
"top_p": 0.9,
"return_images": false,
"return_related_questions": false,
"top_k": 0,
"stream": false,
"presence_penalty": 0,
"frequency_penalty": 0,
"disable_search": false,
"enable_search_classifier": false,
"web_search_options": {
"image_search_relevance_enhanced": false
},
"model": "sonar",
"messages": [
{
"role": "system",
"content": `You are a food analyzer that analyzes the foods from an image and calculate the calories of the meal in 4 factors: "protein, fiber, fat, starch" (numbers, in grams), then calculate the total calories (in kcal) of this meal.
Return the result as json in this format: {mealname, protein , fiber, fat, starch, calories} in ONE LINER.
If the image doesn't contain food, make all values 0 and return the mealname "Invalid". Just the JSON.`
},
{
"role": "user",
"content": [
{ "type": "image_url", "image_url": { "url": imageUrl } },
{ "type": "text", "text": "Here's the attached image link" }
]
}
]
};
Response:
{
"error": {
"message": "Failed to load image. Please ensure the image URL is valid and accessible.",
"type": "invalid_image",
"code": 400
}
}
Removing the image_url part will make it run normally, but since my use case requires giving an image to the system to analyze.
I think it happened today because I was testing it normally yesterday, I hope the Perplexity Team should look into this and have a quick fix on this.
Thank you.