petervandijck's avatar

OpenAI: referencing uploaded files

I am using https://github.com/openai-php/laravel/ I successfully upload a file and keep it's openAI ID stored:

$response = OpenAI::files()->upload([
                'purpose' => 'assistants',
                'file' => fopen(storage_path('app/' . $path), 'r'),
            ]);

Then I want to reference that file in my openAI call like this:

$response = OpenAI::chat()->create([
                'model' => 'gpt-4',
                'messages' => [
                    ['role' => 'system', 'content' => 'You are an AI assistant tasked with analyzing documents and extracting key insights.'],
                    ['role' => 'user', 'content' => 'Please analyze the content of the attached document and provide key insights. Return the results as a JSON object.'],
                ],
                'file_ids' => [$document->openai_id],
            ]);

This gets me the error: OpenAI API error {"document_id":11,"message":"Unrecognized request argument supplied: file_ids","code":0}

Am I doing this totally wrong? Does the package support referencing file IDs?

0 likes
0 replies

Please or to participate in this conversation.