Skip to content

Attach image to a chat? #451

Answered by matt-o-matic
matt-o-matic asked this question in Q&A
Discussion options

You must be logged in to vote

As it turns out I was wrong in my approach. When using GPT-4o you can simply add images to your user content.

$createParms = [
   'model'=>'gpt-4o',
   'messages'=>[
      ['role'=>'system', 'content'=>'Your system message like you are a helpful AI assistant to do X',
      ['role'=>'user', 'content'=>[
         ['type'=>'text', 'text'=>'Plain text here, if any'],
         ['type'=>'image_url', 'image_url'=>['url'=>'<<<INSERT URL OR BASE64 ENCODED DATA HERE>>>'] ],
         ['type'=>'image_url', 'image_url'=>['url'=>'<<<INSERT URL OR BASE64 ENCODED DATA HERE>>>'] ],
      ],
   ],
];

$result = $client->chat()->create($createParms);

Basically enter whatever would be in the src attribute…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by matt-o-matic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant