client icon indicating copy to clipboard operation
client copied to clipboard

[Bug]: Image read?

Open striderxfossility opened this issue 10 months ago • 3 comments

Description

I get:

Undefined array key "choices"

Steps To Reproduce

$completion = $this->client->chat()->create([
                'model' => 'llama-3.3-70b-instruct',
                'messages' => [
                    [
                        'role' => 'system',
                        'content' => [
                            [
                                'type' => 'text',
                                'text' => 'You are a helpful assistant.'
                            ]
                        ]
                    ],
                    [
                        'role' => 'user',
                        'content' => [
                            [
                                'type' => 'text',
                                'text' => "What's in this image?"
                            ],
                            [
                                'type' => 'image_url',
                                'image_url' => [
                                    'url' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg',
                                ],
                            ],
                        ],
                    ]
                ],
                'max_tokens' => 2000,
                'temperature' => 0.5,
                'stream' => false
            ]);

OpenAI PHP Client Version

v0.11.0

PHP Version

8.3.16

Notes

No response

striderxfossility avatar Mar 15 '25 14:03 striderxfossility

After debugging i found out that the model is returning:

array:5 [▼ // vendor/openai-php/client/src/Responses/Chat/CreateResponse.php:48
  "object" => "error"
  "message" => "Unknown image model type: llama"
  "type" => "BadRequestError"
  "param" => null
  "code" => 400
]

striderxfossility avatar Mar 15 '25 14:03 striderxfossility

But when i remove the array

[
                                'type' => 'image_url',
                                'image_url' => [
                                    'url' => 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg',
                                ],
                            ],

i works as suspected

striderxfossility avatar Mar 15 '25 14:03 striderxfossility

modal pixtral-12b-2409 is working, but i know that llama-3.3-70b-instruct also supports images.

because i have a JS poc that works with that model. for now i use pixtral

striderxfossility avatar Mar 15 '25 14:03 striderxfossility

https://github.com/iBotPeaches/openai-php-laravel-test/commit/cab73a3d163114858bb03ee0aafb575af1ef2337

➜  openai-test git:(master) ✗ php artisan app:chat-image-test
OpenAI\Responses\Chat\CreateResponse {#663
  +id: "chatcmpl-C6wYwcMvIXKjm1o3DwCSy2Ji1AHpd"
  +object: "chat.completion"
  +created: 1755771118
  +model: "gpt-4o-2024-08-06"
  +systemFingerprint: "fp_80956533cb"
  +choices: array:1 [
    0 => OpenAI\Responses\Chat\CreateResponseChoice {#659
      +index: 0
      +message: OpenAI\Responses\Chat\CreateResponseMessage {#654
        +role: "assistant"
        +content: "The image shows a scenic landscape with a wooden boardwalk path running through a field of lush green grass. The sky is blue with scattered clouds, creating a serene and peaceful atmosphere. There are some trees and bushes in the background."
        +annotations: []
        +toolCalls: []
        +functionCall: null
        +audio: null
      }
      +logprobs: null
      +finishReason: "stop"
    }
  ]

Sorry for delay, going through old issues and tested your sample. I don't see an issue and it seems you were trying different supported/unsupported models. So closing this.

iBotPeaches avatar Aug 21 '25 10:08 iBotPeaches