Using Assistant API with AzureOpenAI

Is it possible to use the Assistant API with AzureOpenAI?

I am using a GPT4 model gpt-4-1106-preview deployment is US East2.
The api_version is 2022-12-01-preview

client = AzureOpenAI(
    api_key=api_key,
    api_version=api_version,
    azure_endpoint=azure_endpoint,
    azure_deployment=deployment_name
)

When I try to create an assistant, I get a “Resource not found” error. Same error if I provide the Azure OpenAI deployment name instead of the model name :

assistant = client.beta.assistants.create(
    name="Math Tutor",
    instructions="You are a personal math tutor. Write and run code to answer math questions.",
    tools=[{"type": "code_interpreter"}],
    model='gpt-4-1106-preview' 
)
---------------------------------------------------------------------------
NotFoundError                             Traceback (most recent call last)
Cell In[59], line 1
----> 1 assistant = client.beta.assistants.create(
      2     name="Math Tutor",
      3     instructions="You are a personal math tutor. Write and run code to answer math questions.",
      4     tools=[{"type": "code_interpreter"}],
      5     model='gpt-4-1106-preview' # Check the docs for the latest models
      6 )

File ~/miniforge3/envs/copilot/lib/python3.8/site-packages/openai/resources/beta/assistants/assistants.py:95, in Assistants.create(self, model, description, file_ids, instructions, metadata, name, tools, extra_headers, extra_query, extra_body, timeout)
     57 """
     58 Create an assistant with a model and instructions.
     59 
   (...)
     92   timeout: Override the client-level default timeout for this request, in seconds
     93 """
     94 extra_headers = {"OpenAI-Beta": "assistants=v1", **(extra_headers or {})}
---> 95 return self._post(
     96     "/assistants",
     97     body=maybe_transform(
     98         {
     99             "model": model,
    100             "description": description,
    101             "file_ids": file_ids,
    102             "instructions": instructions,
    103             "metadata": metadata,
    104             "name": name,
    105             "tools": tools,
    106         },
    107         assistant_create_params.AssistantCreateParams,
    108     ),
    109     options=make_request_options(
    110         extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
    111     ),
    112     cast_to=Assistant,
    113 )

File ~/miniforge3/envs/copilot/lib/python3.8/site-packages/openai/_base_client.py:1088, in SyncAPIClient.post(self, path, cast_to, body, options, files, stream, stream_cls)
   1074 def post(
   1075     self,
   1076     path: str,
   (...)
   1083     stream_cls: type[_StreamT] | None = None,
   1084 ) -> ResponseT | _StreamT:
   1085     opts = FinalRequestOptions.construct(
   1086         method="post", url=path, json_data=body, files=to_httpx_files(files), **options
   1087     )
-> 1088     return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))

File ~/miniforge3/envs/copilot/lib/python3.8/site-packages/openai/_base_client.py:853, in SyncAPIClient.request(self, cast_to, options, remaining_retries, stream, stream_cls)
    844 def request(
    845     self,
    846     cast_to: Type[ResponseT],
   (...)
    851     stream_cls: type[_StreamT] | None = None,
    852 ) -> ResponseT | _StreamT:
--> 853     return self._request(
    854         cast_to=cast_to,
    855         options=options,
    856         stream=stream,
    857         stream_cls=stream_cls,
    858         remaining_retries=remaining_retries,
    859     )

File ~/miniforge3/envs/copilot/lib/python3.8/site-packages/openai/_base_client.py:930, in SyncAPIClient._request(self, cast_to, options, remaining_retries, stream, stream_cls)
    927     if not err.response.is_closed:
    928         err.response.read()
--> 930     raise self._make_status_error_from_response(err.response) from None
    932 return self._process_response(
    933     cast_to=cast_to,
    934     options=options,
   (...)
    937     stream_cls=stream_cls,
    938 )

NotFoundError: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}
3 Likes