Forum Discussion
Lakshmi_145
Mar 25, 2025Iron Contributor
Format for sending images to Azure OpenAI
Hi,
I logged into Azure OpenAI Studio and tried to send an image in the OpenAI chat. The image was successfully sent, and OpenAI provided a correct response based on the error message in the image.
While checking the backend code for sending the image to the OpenAI client, I couldn't find the exact format required for the image URL. What should be the format of image url. I have tried it out by sending as base 64 and i didnt get any proper response.
// Initialize the AzureOpenAIClient
var azureClient = new AzureOpenAIClient(new Uri(endpoint), credential);
// Initialize the ChatClient with the specified deployment name
ChatClient chatClient = azureClient.GetChatClient("gpt-4o");
// Create a list of chat messages
var messages = new List<ChatMessage>
{
new UserChatMessage("
image_url
"),
new AssistantChatMessage("The error message \"We couldn't upload your data. This request is not authorized to perform this operation\" indicates that you do not have the necessary permissions to upload files to the Azure Blob Storage. Here are steps you can follow to resolve this issue:
1. **Check Your Permissions**:
- Ensure that you have the correct pe
Could you please confirm whether this functionality can also be used with the 'On Your Data' feature. If the text in the image is stored within documents in a specific index, can we use the image to retrieve relevant solutions from the index?
- Sayali-MSFT
Microsoft
Lakshmi_145, Thank you for your inquiry about your Teams app development issue!
We are checking the issue. We will get back to you shortly.
- ItsBhattiBrass Contributor
To send images to Azure OpenAI, follow these steps:
Use the appropriate API endpoint for image processing.
Send a POST request.
Include these headers:
Content-Type: application/json
Authorization: Bearer <your-key>
In the body, encode the image in base64 and send it in the JSON format:
"data": "<base64-image-data>"
Replace <your-key> with your Azure API key.
- Nivedipa-MSFT
Microsoft
Lakshmi_145 - Could you please confirm if your issue is resolved with above suggestion or are you still looking for any help?