-
-
Notifications
You must be signed in to change notification settings - Fork 177
Open
Description
Hi,
How could I possibly send a base64 encoded image to gpt 4o using the API? Currently for sending text requests and getting responses from ChatGPT I have this function:
//Method to send text requests to chatgpt
public async void AskChatGPT(string newText)
{
debugText.SetText("AskChatGpt called!");
Debug.Log("AskChatGPT function called with input: " + newText);
ChatMessage newMessage = new ChatMessage();
newMessage.Content = newText;
newMessage.Role = "user";
messages.Add(newMessage);
CreateChatCompletionRequest request = new CreateChatCompletionRequest();
request.Messages = messages;
request.Model = "gpt-4o";
var response = await openAI.CreateChatCompletion(request);
if (response.Choices != null && response.Choices.Count > 0)
{
var chatResponse = response.Choices[0].Message;
messages.Add(chatResponse);
Debug.Log(chatResponse.Content);
waitingForResponse = true;
OnResponse.Invoke(chatResponse.Content);
Debug.Log("Reponse Finished");
waitingForResponse = false;
}
}
I have the images already encoded as base64, but would appreciate some insights on how to feed it to gpt 4o using the APIs and specify what we are sending is an Image data.
Metadata
Metadata
Assignees
Labels
No labels