Skip to content

ValueError for missing api_version when calling with_options() on an (Async)AzureOpenAI client instance #779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
gleason-m opened this issue Nov 10, 2023 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@gleason-m
Copy link

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

Calling with_options() on an AzureOpenAI or AsyncAzureOpenAI client instance throws a ValueError exception:

ValueError: Must provide either the api_version argument or the OPENAI_API_VERSION environment variable

To Reproduce

Initialize an AzureOpenAI client and call with_options() on it.

Code snippets

from openai import AsyncAzureOpenAI

client = AsyncAzureOpenAI(
    azure_endpoint="",
    api_key="mykey",
    api_version="2023-07-01-preview",
)

copied_client = client.with_options(timeout=30)

OS

ubuntu 22.04

Python version

v3.10.12

Library version

opeanai v1.1.2

@gleason-m gleason-m added the bug Something isn't working label Nov 10, 2023
@rattrayalex
Copy link
Collaborator

Thanks for reporting, we'll try to fix this on Monday.

@Mikkolehtimaki
Copy link

Still running into this on openai-1.3.3 client.

@rattrayalex
Copy link
Collaborator

Thank you for following up @Mikkolehtimaki , I'm so sorry we let this slip! We'll take a look soon.

@RobertCraigie
Copy link
Collaborator

This will be fixed in the next release, sorry for the delay!

@chenxy1021
Copy link

该问题将在下一个版本中修复,抱歉延迟了!

Still not fixed

@rattrayalex
Copy link
Collaborator

This should have been fixed in #858 which was released in https://github.com/openai/openai-python/releases/tag/v1.3.5

Can you try that version and share the traceback you see, along with your code causing it?

@Mikkolehtimaki
Copy link

Can confirm that 1.3.5 works!

@ahmedbr
Copy link

ahmedbr commented Jan 29, 2024

I have same error with the following set of requirements:

openai==1.10.0
langchain==0.1.4
langchain-community==0.0.16
langchain-core==0.1.16
langchain-openai==0.0.5

stainless-app bot pushed a commit that referenced this issue Mar 27, 2025
…-changes--next--components--openai

release: 4.37.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants