python调用Azure OpenAI的gpt4o大模型api示例代码

代码语言:python

所属分类:其他

代码描述:python调用Azure OpenAI的gpt4o大模型api示例代码,注意要下载安装最新的openai库,pip install openai

代码标签: python 调用 Azure OpenAI gpt4o 大模型 api 示例 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

#!/usr/local/python3/bin/python3
# -*- coding: utf-8 -*
#安装依赖 pip install openai
import os
from openai import AzureOpenAI

client = AzureOpenAI(
  azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"), 
  api_key=os.getenv("AZURE_OPENAI_API_KEY"),  
  api_version="2024-02-01"
)

response = client.chat.completions.create(
    model="gpt-4o", # model = "deployment_name".
    messages=[
        {"role": "system", "content".........完整代码请登录后点击上方下载按钮下载查看

网友评论0