# Sonar returns 400 when receiving image inputs

**URL:** <https://community.perplexity.ai/t/sonar-returns-400-when-receiving-image-inputs/3061>\
**Category:** General\
**Tags:** sonar-api\
**Created:** [December 13, 2025, 1:41am UTC](https://community.perplexity.ai/t/sonar-returns-400-when-receiving-image-inputs/3061 "2025-12-13T01:41:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hieutrungmc](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/hieutrungmc/32/1231_2.png) [@hieutrungmc](https://community.perplexity.ai/u/hieutrungmc)\
**Post date:** [December 13, 2025, 1:41am UTC](https://community.perplexity.ai/t/sonar-returns-400-when-receiving-image-inputs/3061/1 "2025-12-13T01:41:01Z")

</div>

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:

```json

{
      "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:

```json
{
  "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.

---

<div class="post-metadata">

**Author:** ![Ali\_Sadeghi](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/ali_sadeghi/32/2179_2.png) [@Ali\_Sadeghi](https://community.perplexity.ai/u/Ali_Sadeghi)\
**Post date:** [December 18, 2025, 8:19pm UTC](https://community.perplexity.ai/t/sonar-returns-400-when-receiving-image-inputs/3061/2 "2025-12-18T20:19:18Z")

</div>

I have the same problem with “sonar-pro” model! ☹

❌ Perplexity API Error 400 {“error”:{“message”:“Failed to load image. Please ensure the image URL is valid and accessible.”,“type”:“invalid\_image”,“code”:400}}

---

<div class="post-metadata">

**Author:** ![hieutrungmc](https://sea1.discourse-cdn.com/flex001/user_avatar/community.perplexity.ai/hieutrungmc/32/1231_2.png) [@hieutrungmc](https://community.perplexity.ai/u/hieutrungmc)\
**Post date:** [December 24, 2025, 2:55pm UTC](https://community.perplexity.ai/t/sonar-returns-400-when-receiving-image-inputs/3061/3 "2025-12-24T14:55:42Z")

</div>

Seems like everyone is getting this error, I’ve found a temporary workaround for this: Convert your image into a base64 image link and pass it into the url field instead of the image https url like in this section: [Base64 Encoded Image Data](https://docs.perplexity.ai/guides/image-attachments#2-base64-encoded-image-data)
