Skip to content

[BUG] Base64-encoded string throws exception while invoking image analysis #708

@justinyoo

Description

@justinyoo

Describe the bug

Unhandled exception. System.ClientModel.ClientResultException: HTTP 400 (invalid_request_error: invalid_value)
Parameter: input

The image data you provided does not represent a valid image. Please check your input and try again with one of the supported image formats: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].

Steps to reproduce

  1. Run this code, https://github.com/justinyoo/openai-dotnet/blob/docs/images-vision/docs/guides/images-vision/responses/analyze_images_passing_base64_string.cs
  2. See the error below:
Unhandled exception. System.ClientModel.ClientResultException: HTTP 400 (invalid_request_error: invalid_value)
Parameter: input

The image data you provided does not represent a valid image. Please check your input and try again with one of the supported image formats: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'].
   at OpenAI.ClientPipelineExtensions.ProcessMessage(ClientPipeline pipeline, PipelineMessage message, RequestOptions options)
   at OpenAI.Responses.OpenAIResponseClient.CreateResponse(BinaryContent content, RequestOptions options)
   at OpenAI.Responses.OpenAIResponseClient.CreateResponse(IEnumerable`1 inputItems, ResponseCreationOptions options, CancellationToken cancellationToken)
   at Program.<Main>$(String[] args) in C:\Users\justi\dev\gh\openai-dotnet\docs\guides\images-vision\responses\analyze_images_passing_base64_string.cs:line 43
   at Program.<Main>(String[] args)

Code snippets

Here's the code snippet link: https://github.com/justinyoo/openai-dotnet/blob/docs/images-vision/docs/guides/images-vision/responses/analyze_images_passing_base64_string.cs

OS

Windows

.NET version

.NET 10 RC1

Library version

2.4.0

Metadata

Metadata

Assignees

Labels

area: imagesThis item is related to Images.issue-addressedWorkflow: The OpenAI maintainers believe the issue to be addressed and ready to close.questionCategory: The issue is seeking information about the library or its usage.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions