-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
Problem
When trying to upload a JPG file I'm encountering invalid_request_error: "Part exceeded maximum size of 1024KB."
It looks like this gem is setting the media-type to "multipart/form-data" as expected, but then submitting UPDATE: The problem was this gem was setting an invalid file
as a string parameter instead of a file upload.Content-Disposition
part header so servers were parsing the file
param as a string instead of a file upload.
Details
- Claude API documentation says "Maximum file size: 500 MB per file".
- My file is 1.1MB
- A web search indicates this error message "Part exceeded maximum size of 1024KB" originates from Starlette, so I assume the Claude API uses Starlette.
- Can replicate with both String and StringIO values for
file
. - Can replicate this error across multiple environments (development and production).
- Can replicate with and without shorter multipart boundaries.
- Cannot replicate with cURL, meaning the problem seems to be with how this gem is sending requests.
- This is NOT a problem with extra headers like
betas: "anthropic-beta"
or params likebeta=true
.
Code
anthropic = Anthropic::Client.new
file_string = File.read('/some/path/file.jpg')
anthropic.beta.files.upload(file: file_string)
Anthropic::Errors::BadRequestError
{
:url=>"https://api.anthropic.com/v1/files?beta=true",
:status=>400,
:body=>{
:type=>"error",
:error=>{
:type=>"invalid_request_error",
:message=>"Part exceeded maximum size of 1024KB."
},
:request_id=>"req_011CSoyEPUAzWgTzPoJfESpt"
}
}
Metadata
Metadata
Assignees
Labels
No labels