微软的Azure页面 : https://learn.microsoft.com/zh-cn/azure/ai-services/openai/concepts/models
调用代码:https://learn.microsoft.com/zh-cn/azure/ai-services/openai/how-to/switching-endpoints
openai说明: https://platform.openai.com/docs/guides/vision
一、服务器区域选择与购买 (略)
不同区域的服务器开通不同模型 美国西部
二、上传本地图片解析
先安装openai
pip install -U openai
代码 + 自己api
api_key=“yourkey”
azure_endpoint=“xxxx/chat/completions?api-version=2023-07-01-preview”
api_version=“2023-12-01-preview”,
'''
https://platform.openai.com/docs/guides/vision
https://learn.microsoft.com/zh-cn/azure/ai-services/openai/concepts/models
https://learn.microsoft.com/zh-cn/azure/ai-services/openai/how-to/chatgpt?tabs=python&pivots=programming-language-chat-completions
https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/gpt-with-vision
'''
from openai import AzureOpenAI
api_key="yourkey"
import base64
azure_endpoint="xxxx/chat/completions?api-version=2023-07-01-preview"
client = AzureOpenAI(
api_key=api_key,
api_version="2023-12-01-preview",
azure_endpoint=azure_endpoint
)
# Function to encode the image
def encode_image(image_path):
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode('utf-8'