[GH-ISSUE #7247] invalid image input #51116

Closed
opened 2026-04-28 18:26:07 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @ozbillwang on GitHub (Oct 17, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7247

What is the issue?

When test with OpenAI compatibility , I run the example, got this error

invalid image input

openai.BadRequestError: Error code: 400 - {'error': {'message': 'invalid image input', 'type': 'invalid_request_error', 'param': None, 'code': None}}

I can raise PR to fix, but I need know how to prepare the image "image_url": "iVBORw0KGgoAAAANSU...

ref: https://github.com/ollama/ollama/blob/main/docs/openai.md?plain=1#L40

image

OS

macOS

GPU

Apple

CPU

Intel

Ollama version

0.3.13

Originally created by @ozbillwang on GitHub (Oct 17, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7247 ### What is the issue? When test with OpenAI compatibility , I run the example, got this error > invalid image input >openai.BadRequestError: Error code: 400 - {'error': {'message': 'invalid image input', 'type': 'invalid_request_error', 'param': None, 'code': None}} I can raise PR to fix, but I need know how to prepare the image `"image_url": "iVBORw0KGgoAAAANSU...` ref: https://github.com/ollama/ollama/blob/main/docs/openai.md?plain=1#L40 <img width="903" alt="image" src="https://github.com/user-attachments/assets/32e9cc3c-6185-48b2-b16d-18c4aa28313b"> ### OS macOS ### GPU Apple ### CPU Intel ### Ollama version 0.3.13
GiteaMirror added the bug label 2026-04-28 18:26:07 -05:00
Author
Owner

@rick-github commented on GitHub (Oct 18, 2024):

The image_url is missing a DataURI prefix, ie

"image_url":"data:image/png;base64,iVBORw0KGgoAAAAN..."

See OpenAI doc.

<!-- gh-comment-id:2421053959 --> @rick-github commented on GitHub (Oct 18, 2024): The `image_url` is missing a DataURI prefix, ie ``` "image_url":"data:image/png;base64,iVBORw0KGgoAAAAN..." ``` See [OpenAI doc](https://platform.openai.com/docs/guides/vision/uploading-base64-encoded-images).
Author
Owner

@ozbillwang commented on GitHub (Oct 18, 2024):

thanks, it works

ChatCompletion(id='chatcmpl-417', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=" The image shows a playful and whimsical cartoon of what seems to be an anthropomorphic character resembling a dog. It is not a pangolin, as it has human-like arms and legs, with the paw motion suggesting it's running or dancing. This character is likely a stylized mascot or a cute representation drawn in a playful comic book style. The background is nondescript and plain, putting the focus on this amusing figure. ", refusal=None, role='assistant', function_call=None, tool_calls=None))], created=1729221570, model='llava', object='chat.completion', service_tier=None, system_fingerprint='fp_ollama', usage=CompletionUsage(completion_tokens=104, prompt_tokens=1, total_tokens=105, completion_tokens_details=None, prompt_tokens_details=None))

let me raise the PR to fix

<!-- gh-comment-id:2421220968 --> @ozbillwang commented on GitHub (Oct 18, 2024): thanks, it works >ChatCompletion(id='chatcmpl-417', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=" The image shows a playful and whimsical cartoon of what seems to be an anthropomorphic character resembling a dog. It is not a pangolin, as it has human-like arms and legs, with the paw motion suggesting it's running or dancing. This character is likely a stylized mascot or a cute representation drawn in a playful comic book style. The background is nondescript and plain, putting the focus on this amusing figure. ", refusal=None, role='assistant', function_call=None, tool_calls=None))], created=1729221570, model='llava', object='chat.completion', service_tier=None, system_fingerprint='fp_ollama', usage=CompletionUsage(completion_tokens=104, prompt_tokens=1, total_tokens=105, completion_tokens_details=None, prompt_tokens_details=None)) let me raise the PR to fix
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#51116