8000 [Bug]: Can't add a file in base64 using input_file option as in OpenAI Documentation · Issue #595 · openai-php/client · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: Can't add a file in base64 using input_file option as in OpenAI Documentation #595
Closed as not planned
@laurent-qantum

Description

@laurent-qantum

Description

According to OpenAI Documentation, it is possible to add a PDF file content in base64 format to a chat request.
https://platform.openai.com/docs/guides/pdf-files?api-mode=responses

I tried the following syntax :
$gpt->client->chat()->create([
'model' => 'gpt-4o',
'response_format' => array('type'=>'json_object'),
'messages' => [
['role' => 'user', 'content' => $prompt],
['role' => 'user', 'content' => [
'type' => 'input_file',
'filename' => $filename,
'file_data' => 'data:application/pdf;base64,'.$base64_content
] ]
],
]);

And it gives this critical error:

Fatal error: Uncaught OpenAI\Exceptions\ErrorException: Invalid type for 'messages[1].content': expected one of a string or array of objects, but got an object instead. in...

Can you explain me why?

Steps To Reproduce

Try the provided code

OpenAI PHP Client Version

0.10.3

PHP Version

8.3.19

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0