# Python V4 - Set api version for Azure OpenAI vectorizer?

**URL:** <https://forum.weaviate.io/t/python-v4-set-api-version-for-azure-openai-vectorizer/3306>\
**Category:** Support\
**Tags:** python, azure, documentation\
**Created:** [August 8, 2024, 4:36pm UTC](https://forum.weaviate.io/t/python-v4-set-api-version-for-azure-openai-vectorizer/3306 "2024-08-08T16:36:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Taylor\_Hickman](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/taylor_hickman/32/2099_2.png) [@Taylor\_Hickman](https://forum.weaviate.io/u/Taylor_Hickman)\
**Post date:** [August 8, 2024, 4:36pm UTC](https://forum.weaviate.io/t/python-v4-set-api-version-for-azure-openai-vectorizer/3306/1 "2024-08-08T16:36:38Z")

</div>

### Description

Is there a way to set the api version for v4 Azure OpenAI vectorizer? I tried  
passing the OPENAI\_API\_VERSION but Weaviate seems to default to:

/embeddings?api-version=2024-02-01

…but our instance of Azure OpenAI uses 2023-05-15

### Server Setup Information

- Weaviate Server Version: 1.26.1
- Deployment Method: Docker
- Multi Node? Number of Running Nodes: Single
- Client Language and Version: Python weaviate\_client-4.7.1
- Multitenancy?:

### Any additional Information

```yaml

  weaviate:
    image: cr.weaviate.io/semitechnologies/weaviate:latest
    ports:
      - 8080:8080
      - 50051:50051
    environment:
      QUERY_DEFAULTS_LIMIT: 25
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
      PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
      AZURE_APIKEY: ${AZURE_OPENAI_API_KEY}
      OPENAI_API_TYPE: 'azure'
      ENABLE_MODULES: 'text2vec-azure-openai, text2vec-openai'
      DEFAULT_VECTORIZER_MODULE: 'none'
      OPENAI_API_VERSION: ${AZURE_OPENAI_API_VERSION}
      AZURE_ENDPOINT: ${AZURE_OPENAI_ENDPOINT}
      AZURE_OPENAI_BASE_URL: ${AZURE_OPENAI_BASE_URL}
      AZURE_OPENAI_RESOURCE_NAME: ${AZURE_OPENAI_RESOURCE_NAME}
      AZURE_OPENAI_API_VERSION: ${AZURE_OPENAI_API_VERSION}
      AZURE_OPENAI_EMBEDDING_DEPLOYMENT: ${AZURE_OPENAI_EMBEDDING_DEPLOYMENT}
      CLUSTER_HOSTNAME: 'node1'
    volumes:
      - weaviate_data:/var/lib/weaviate
      

```

```python

class WeaviateStore:
    def __init__ (self, settings: Settings):
        self.settings = settings
        self.client: weaviate.WeaviateAsyncClient = None
        self.class_name = settings.WEAVIATE_CLASS_NAME

    async def initialize(self):
        if self.client is None:
            connection_params = ConnectionParams.from_params(
                http_host=self.settings.WEAVIATE_HOST,
                http_port=self.settings.WEAVIATE_PORT,
                http_secure=False,
                grpc_host=self.settings.WEAVIATE_HOST,
                grpc_port=self.settings.WEAVIATE_GRPC_PORT,
                grpc_secure=False,
            )

            self.client = weaviate.WeaviateAsyncClient(
                connection_params=connection_params,
                additional_headers={
                    "X-Azure-Api-Key": self.settings.AZURE_OPENAI_API_KEY,
                },
            )
            
            await self.client.connect()
            await self._create_or_update_schema()

    async def _create_or_update_schema(self):
        try:
            collection = self.client.collections.get(self.class_name)
            logger.info(f"Collection '{self.class_name}' already exists. Updating configuration.")
            await self.client.collections.delete(self.class_name)
        except UnexpectedStatusCodeError as e:
            if e.status_code != 404:
                logger.error(f"Unexpected error when checking for existing collection: {str(e)}")
                raise
        try:
            properties = [
                Property(name="content", data_type=DataType.TEXT),
                Property(name="metadata", data_type=DataType.OBJECT, nested_properties=[
                    Property(name="source", data_type=DataType.TEXT),
                    Property(name="document_type", data_type=DataType.TEXT),
                    Property(name="npi", data_type=DataType.TEXT),
                ]),
                Property(name="npi", data_type=DataType.TEXT),
            ]

            vectorizer_config = Configure.Vectorizer.text2vec_azure_openai(
                resource_name=self.settings.AZURE_OPENAI_RESOURCE_NAME,
                deployment_id=self.settings.AZURE_OPENAI_EMBEDDING_DEPLOYMENT,
                base_url=self.settings.AZURE_OPENAI_ENDPOINT
            )

            logger.info(f"Creating new collection '{self.class_name}'")
            await self.client.collections.create(
                name=self.class_name,
                properties=properties,
                vectorizer_config=vectorizer_config
            )
            logger.info(f"Successfully created collection '{self.class_name}'")

        except UnexpectedStatusCodeError as e:
            logger.error(f"Failed to create collection: {str(e)}")
            raise
        except Exception as e:
            logger.error(f"Unexpected error during schema creation/update: {str(e)}", exc_info=True)
            raise

```

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [August 8, 2024, 9:22pm UTC](https://forum.weaviate.io/t/python-v4-set-api-version-for-azure-openai-vectorizer/3306/2 "2024-08-08T21:22:40Z")

</div>

hi @Taylor_Hickman !!

I believe we have found an undocumented feature 🙂

`apiVersion`

I am not sure you can pass `apiVersion` at query time. 🤔 I will have to ask internally as I couldn’t figure out from the PR:

> <https://github.com/weaviate/weaviate/pull/4605>
>
> \### What's being changed:
> 
> This PR adds \`apiVersion\` support to \`text2vec-open…ai\` module.
> 
> It sets the default \`apiVersion\` to \`2024-02-01\` both in \`text2vec-openai\` and \`generative-openai\` modules.
> 
> \### Review checklist
> 
> \- \[\] Documentation has been updated, if necessary. Link to changed documentation:
> \- \[\] Chaos pipeline run or not necessary. Link to pipeline:
> \- \[\] All new code is covered by tests where it is reasonable.
> \- \[\] Performance tests have been run or not necessary.

You can also change the baseUrl at query time, as documented here:

> **[text2vec-openai | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-openai#query-time-parameters)**
>
> Overview

I have also found some related forum threads:

> [@Weaviate Post still using api-version=2022-12-01 even though the version has been retired](https://forum.weaviate.io/t/weaviate-post-still-using-api-version-2022-12-01-even-though-the-version-has-been-retired/1891):
>
> Hello. I am quite new to using weaviate but have enjoyed it well. Yesterday all of my embedding queries stopped working for my application as weaviate continues to try to connect to https://{resource}.openai.azure.com/openai/deployments/{deployment-id}/embeddings?api-version=2022-12-01. As of my understanding since yesterday 2.4.2024 that version has been retired. I read here that weaviate should try another version automatically. But clearly it does not so for me as it still uses 2022-12-01…

> [@Api version in Query-time parameters?](https://forum.weaviate.io/t/api-version-in-query-time-parameters/2368/3):
>
> Yes, I added those to the collection definition and those worked for vectorizing our documents. but what about when I want to deploy the application and we are using a different base\_url when deployed? So if i want to vector search with “nearText” using a different base\_url. Thas base\_url should be added in the headers like “X-OpenAI-BaseURL”: {baseUrl} since I am making REST Api calls

Let me know if this helps!

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [August 9, 2024, 6:27pm UTC](https://forum.weaviate.io/t/python-v4-set-api-version-for-azure-openai-vectorizer/3306/3 "2024-08-09T18:27:57Z")

</div>

Hi!

You cannot pass the `apiVersion` on query time ☹

Our team is looking into this.

but right now, you will need to set the apiversion while creating a collection.
