Use VS to test the AzureOpenai API. It doesn't work, but it can be used in Azure and on the AMA client?
鱼 张
5
Reputation points
Use VScode to test the AzureOpenai API, but it can be used in Azure and on the AMA client? code show as below:
#Note: The openai-python library support for Azure OpenAI is in preview.
import os
import openai
openai.api_type = "azure"
openai.api_base = "https://?????.openai.azure.com/"
openai.api_version = "2023-03-15-preview"
openai.api_key = os.getenv("OPENAI_API_KEY")
response = openai.ChatCompletion.create(
engine="abc123",
messages = [{"role":"system","content":"You are an AI assistant that helps people find information."},{"role":"user","content":"你好"},{"role":"assistant","content":"您好!有什么我可以为您效劳的吗?"}],
temperature=0.7,
max_tokens=800,
top_p=0.95,
frequency_penalty=0,
presence_penalty=0,
stop=None)
Here I am hidden, my KEY, prompts the following error:
raise openai.error.AuthenticationError(
openai.error.AuthenticationError: No API key provided. You can set your API key in code using 'openai.api_key =
<API-KEY>', or you can set the environment variable OPENAI_API_KEY=<API-KEY>). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = <PATH>'. You can generate API keys in the
OpenAI web interface. See https://platform.openai.com/account/api-keys for details.
Please some great god to guide me.
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,081 questions
Sign in to answer