Skip to content

[BUG] AzureOpenAIClient does not accept PDF files (returns 400 invalid_value), but OpenAIClient accepts PDF file #51873

@lucianteodorescu-milestone

Description

Library name and version

Azure.AI.OpenAI 2.3.0-beta.1

Describe the bug

The file is added in the list of ChatMessage using

var document = BinaryData.FromBytes(File.ReadAllBytes("C:\\OpenAIFiles\\myTestPdfFileName.pdf"));
 new UserChatMessage(ChatMessageContentPart.CreateFilePart(document, "application/pdf", "myTestPdfFileName.pdf"))

When using OpenAIClient client from OpenAI 2.3.0 package, the PDF is read and everything works as expected.

But when I use AzureOpenAIClient from Azure.AI.OpenAI 2.3.0-beta.1, it returns:

"HTTP 400 (invalid_request_error: invalid_value)
Parameter: messages[2].content[0].type
Invalid Value: 'file'. This model does not support file content types."

at OpenAI.ClientPipelineExtensions.ProcessMessageAsync(ClientPipeline pipeline, PipelineMessage message, RequestOptions options)
at OpenAI.Chat.ChatClient.CompleteChatAsync(BinaryContent content, RequestOptions options)
at OpenAI.Chat.ChatClient.CompleteChatAsync(IEnumerable`1 messages, ChatCompletionOptions options, CancellationToken cancellationToken)

Expected behavior

using AzureOpenAIClient should be able to process the PDF files just as OpenAI's OpenAIClient does.

Actual behavior

using AzureOpenAIClient returns 400 invalid_value when PDF files are used.

Reproduction Steps

use Azure.AI.OpenAI nuget, with chat completion client (any supported model).
add a PDF file as part of the input ChatMessage list.
call client.CompleteChat(messages) or await client.CompleteChatAsync(messages)

Environment

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue is related to a non-management packageOpenAIService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions