Skip to content

bug: UserContent::document_url(url, media_type) makes OpenAI throw 400 bad request #1429

@danechitoaie

Description

@danechitoaie

Using UserContent::document_url(url, media_type) with a PDF file throws the error bellow:

{
    "error": {
        "message": "Mutually exclusive parameters: 'input[1].content[0]'. Ensure you are only providing one of: 'file_id' or 'filename'.",
        "type": "invalid_request_error",
        "param": "input[1].content[0]",
        "code": "mutually_exclusive_parameters"
    }
}

Seems to be that the JSON sent to OpenAI is:

...
"content": [
                {
                    "file_url": "https://....../abc.pdf",
                    "filename": "document.pdf",
                    "type": "input_file"
                }
            ],
...

Notice the extra "filename": "document.pdf",.

If I send the same request from Postman to OpenAI without the "filename": "document.pdf", it works.

rig-core = { version = "0.31.0", features = ["derive"] }

Also Anthropic doesn't seem to suport URLs at all for PDFs, they only want data in base64.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions