Here is an example of node js code to use a reference of an image in restful call. You can pass in a url and we used it and can confirm working. The same can be done by passing a base64 encoded image data string.
const { OpenAIClient, AzureKeyCredential } = require("@azure/openai");
async function CompletionApi(prompt) {
const options = {
api_version: "2023-12-01-preview"
};
const client = new OpenAIClient(
`https://xxxx-openai.openai.azure.com`,
new AzureKeyCredential("<add key>"),
options
);
const deploymentName = 'completions';
const result = await client.getChatCompletions(deploymentName, prompt);
console.log(JSON.stringify(result, null, 2));
return ;
}
(async () => {
const prompt = [
{ "role": "system", "content": "You are a helpful assistant." },
{
"role": "user", "content": [
{
"type": "text",
"text": "Describe this picture:"
},
{
"type": "image_url",
"imageUrl": {
"url": `<image url>`
}
}
]
}
];
const response = await CompletionApi(prompt);
console.log(response);
})();