0

In the example below, the first part, which uses the completion API succeeds. The second part, which attempts to use the assistant API, with the same endpoint, API key and deployment name, throws a "resource not found" exception. What am I doing wrong here? 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")
    
#completion API - succeeds
response = client.chat.completions.create(
            model=deployment_name,
            messages = [{"role":"system", "content":'Write a tagline for an ice cream shop. '}])

print(response.choices[0].message.content)

# assistant API - errors out with "resource not found" 
assistant = client.beta.assistants.create(
                name = "Test OpenAI Azure Assistant",
                instructions="You are a helpful assistant.",
                model=deployment_name
            ) 

Update: tried with different Azure API versions, 2024-02-15-preview or 2024-05-01-preview. With those versions, the Chat Completion API still run just fine, while the Assistant API produces a a different error:

invalid URL (POST /v1/assistants)'

1 Answer 1

0

I tried going to assistants playground at https://oai.azure.com but when I select "Assistants (Preview) I get: enter image description here

That could be the reason for the error I'm getting. If so, the error message "resource not found" or "invalid URL" is very unhelpful.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.