Skip to content

fix(models): pass file metadata tuple to Azure for PDF uploads - #6548

Open
SHAI-nikhil-chaudhary wants to merge 1 commit into
google:mainfrom
SHAI-nikhil-chaudhary:fix-litellm-azure-pdf-upload
Open

fix(models): pass file metadata tuple to Azure for PDF uploads#6548
SHAI-nikhil-chaudhary wants to merge 1 commit into
google:mainfrom
SHAI-nikhil-chaudhary:fix-litellm-azure-pdf-upload

Conversation

@SHAI-nikhil-chaudhary

Copy link
Copy Markdown

Description

Fixes #6539.

When using inline PDF attachments with Azure deployments (azure/<deployment>), litellm.acreate_file was receiving only anonymous raw bytes. Azure requires strict file metadata (filename and MIME type) for context stuffing, leading to an invalid_request_error rejecting the upload with an unsupported MIME type of None.

This PR updates the file argument passed to litellm.acreate_file for _FILE_ID_REQUIRED_PROVIDERS to use a standard HTTP multipart tuple: (filename, data, mime_type).

Changes Made

  • Added import mimetypes to dynamically generate a fallback filename (e.g., document.pdf) based on the extracted mime_type.
  • Updated the file payload in litellm.acreate_file to pass the tuple format expected by the underlying API clients, preserving metadata during upload.

Testing

Successfully tested using the network-free reproduction script provided in the original issue. The payload properly formats as ('document.pdf', b'%PDF-1.4\n', 'application/pdf') instead of b'%PDF-1.4\n'.

@google-cla

google-cla Bot commented Aug 1, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models [Component] This issue is related to model support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] LiteLlm uploads PDFs to Azure without filename or MIME metadata

3 participants