Azure 服务模型:https://learn.microsoft.com/zh-cn/azure/ai-services/openai/concepts/models
SDK REST case:https://learn.microsoft.com/zh-cn/azure/ai-services/openai/gpt-v-quickstart?tabs=image%2Ccommand-line&pivots=rest-api
GPT4 限流:https://platform.openai.com/docs/guides/rate-limits/usage-tiers
version:https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/preview
预览和废弃版本:https://learn.microsoft.com/zh-cn/azure/ai-services/openai/api-version-deprecation
https://platform.openai.com/docs/api-reference/chat/create
https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat
https://platform.openai.com/docs/guides/tools
// api-version=2024-03-01-preview 要根据azure 版本更新,新版本一般比旧版本版本强
async azureGpt4V (imageUrl: string, systemRole: string, promptStr: string) {
const requestParam = {
messages: [
{ role: 'system', content: systemRole },
{
role: 'user', content: [
{
type: 'text',
text: promptStr,
},
{
type: 'image_url',
image_url: { url: `data:image/png;base64,${await imageUrlToBase64(imageUrl)}` },
},
],
},
],
max_tokens: 2000,
};
console.log(util.inspect(requestParam, false, null, true /* enable colors */));
const headers = { 'Content-Type': 'application/json', 'api-key': xxx};
const gptV4Result: any = await got.post('<https://aiyong-zw.openai.azure.com/openai/deployments/gpt-4-vision/chat/completions?api-version=2024-03-01-preview>', {
json: requestParam,
headers,
})
.json();
console.log(util.inspect(gptV4Result, false, null, true /* enable colors */));
return gptV4Result?.choices[0]?.message?.content;
}