I am able to run the model without any issues using the vanilla openai sdk:
Works fine:
...
from openai import AzureOpenAI
client = AzureOpenAI(
azure_endpoint=endpoint,
api_key=api_key,
api_version=api_version,
)
messages = [{"role": "user", "content": "hello"}]
completion = client.chat.completions.create(
temperature=0.0,
model=deployment_name,
timeout=30,
messages=messages,
)
msg = completion.choices[0].message.content
print(msg)
But when I try to run it using the Agents sdk:
...
client = AsyncAzureOpenAI(
azure_endpoint=endpoint,
api_key=api_key,
api_version=api_version,
azure_deployment=deployment_name
)
set_default_openai_client(client)
agent = Agent(
name="Assistant",
instructions="You are a helpful assistant",
)
result = Runner.run_sync(agent, "Hello")
print(result.final_output)
I run into the following error:
openai.NotFoundError: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}
[non-fatal] Tracing client error 401: {
"error": {
"message": "Incorrect API key provided: ******************************. You can find your API key at https://platform.openai.com/account/api-keys.",
"type": "invalid_request_error",
"param": null,
"code": "invalid_api_key"
}
}
The key is obviously not wrong since its working with the first code. Any ideas?