Using Azure OpenAI Client with Assistants: Does It Work?

I started to work with Assistants. I use my Azure account.
I got error even in first tutorial Tutorial Creating Assistants
OpenAI python lib version: ‘1.23.6’

Initialize client

client = openai.AzureOpenAI(
    azure_endpoint=os.getenv('AZURE_OPENAI_ENDPOINT'),
    api_key=os.getenv('AZURE_OPENAI_API_KEY'),
    api_version=os.getenv('AZURE_OPENAI_API_VERSION'),
)


Define assistant

assistant = client.beta.assistants.create(
  name="Data visualizer",
  description="You are great at creating beautiful data visualizations. You analyze data present in .csv files, understand trends, and come up with data visualizations relevant to those trends. You also share a brief text summary of the trends observed.",
  model=os.getenv('AZURE_OPENAI_MODEL'),
  tools=[{"type": "code_interpreter"}],
  tool_resources={
    "code_interpreter": {
      "file_ids": [file.id]
    }
  }
)

Got 400 error.

BadRequestError: Error code: 400 - {'error': {'message': "Unknown parameter: 'tool_resources'.", 'type': 'invalid_request_error', 'param': 'tool_resources', 'code': 'unknown_parameter'}}

My ideas

However, I have an idea that it’s because of the Azure account. But I can’t understand whether I should use the original OpenAI model version or my deployment name in Azure. I used my deployment name in the ChatCompletion API (it connected to my account without any problems), but here in the Assistants API, I am confused.

I am also getting same error

1 Like

You should use your deployment name in Azure.
Also make sure to use latest api-version “2024-05-01-preview” and python lib version 1.30.5

1 Like