In the example below, the first part, which uses the completion API succeeds. The second part, which attempts to use the assistant API, throws a “resource not found” exception. How do I use the Assistant API with OpenAI Azure?
import os
import dotenv
from openai import AzureOpenAI
dotenv.load_dotenv()
client = AzureOpenAI(
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
api_version="2024-02-01",
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
)
deployment_name=os.getenv("AZURE_DEPLOYMENT_NAME")
print("Deployment name:", deployment_name)
start_phrase = 'Write a tagline for an ice cream shop. '
response = client.chat.completions.create(
model=deployment_name,
messages = [{"role":"system", "content":start_phrase}])
print(response.choices[0].message.content)
assistant = client.beta.assistants.create(
name = "Test OpenAI Azure Assistant",
instructions="You are a helpful assistant. Fact: today i June 7th 2024",
model=deployment_name
)