# Issue with Base URL and API Version when using AzureOpenAI #862

**URL:** <https://forum.weaviate.io/t/issue-with-base-url-and-api-version-when-using-azureopenai-862/1707>\
**Category:** Support\
**Created:** [March 13, 2024, 9:27pm UTC](https://forum.weaviate.io/t/issue-with-base-url-and-api-version-when-using-azureopenai-862/1707 "2024-03-13T21:27:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pi\_crust](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/pi_crust/32/1122_2.png) [@pi\_crust](https://forum.weaviate.io/u/pi_crust)\
**Post date:** [March 13, 2024, 9:27pm UTC](https://forum.weaviate.io/t/issue-with-base-url-and-api-version-when-using-azureopenai-862/1707/1 "2024-03-13T21:27:33Z")

</div>

When using Azure OpenAI through Private Org BaseURL, the following error occurs

`ValueError: Error during query: [{'locations': [{'column': 6, 'line': 1}], 'message': 'explorer: get class: vectorize params: vectorize params: vectorize params: vectorize keywords: remote client vectorize: send POST request: Post "https://azure-llm.openai.azure.com/openai/deployments/text-embedding-ada-002/embeddings?api-version=2022-12-01": read tcp 100.64.95.5:59158->20.232.91.180:443: read: connection reset by peer', 'path': ['Get', 'OAAIndexOpenAITest']}]`

The program is sending request to `https://azure-llm.openai.azure.com/openai/deployments/text-embedding-ada-002/embeddings?api-version=2022-12-01` even after specifying the X-OpenAI-BaseURL". Instead of routing to `https://<baseURL>/openai/deployments/<deploymentID>/chat/completions?api-version=<api-version>`

This is occurring when retrieving the indexed documents from Weaviate.

```auto
import weaviate

auth_client_secret = weaviate.AuthApiKey(Config.WEAVIATE_READER_APIKEY)
additional_headers = {"X-Azure-Api-Key": Config.OPENAI_API_KEY,
                                      "X-OpenAI-BaseURL":Config.OPENAI_API_BASE,
                                      "X-OpenAI-Organization":Config.OPENAI_ORGANIZATION}
wv_conn = weaviate.Client(url=os.environ["WEAVIATE_URL"],
                                             auth_client_secret=auth_client_secret,
                                             additional_headers=additional_headers)

```

The index is created using create\_class

```auto
vectorizer = "text2vec-openai"
module_config = {vectorizer: {"resourceName": Config.OPENAI_RESOURCE_NAME,
                                                    "baseURL" : Config.OPENAI_API_BASE,
                                                    "deploymentId": Constants.OPENAI_DEPLOYMENT}}
wv_conn.schema.create_class({"class": "temp_class",
                                                      "vectorizer": vectorizer ,
                                                       "moduleConfig": module_config})

```

These updates are made in weaviate repo, see below PRs. Aren’t these supposed to be reflected here too?

> <https://github.com/weaviate/weaviate/pull/4124>
>
> \### What's being changed:
> 
> This PR adds the ability to define \`baseURL\` when u…ser uses Azure (closes #4092).
> 
> \### 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.

> <https://github.com/weaviate/weaviate/pull/3966>
>
> \### What's being changed:
> 
> Fix #3588 - Let the text2vec-openai module be confi…gured properly for AzureOpenAI.
> 
> As #3588 indicates the code https://github.com/weaviate/weaviate/blob/b10d399760f69d6b0a7ae00051c8f2f07f016b28/modules/text2vec-openai/clients/vectorizer.go#L56
> 
> currently assumes that all Azure deployments use the base URL
> 
> \`\`\`
> "https://" + resourceName + ".openai.azure.com"
> \`\`\`
> 
> But this is no longer the case. My baseURL ends up being \`https://eastus.api.cognitive.microsoft.com\`
> 
> The \[Azure docs\](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/create-resource?pivots=cli#get-the-endpoint-url) say the endpoint can be obtained by running this command
> 
> \`\`\`
> az cognitiveservices account show \\
> \--name \<myResourceName\> \\
> \--resource-group \<myResourceGroupName\> \\
> | jq -r .properties.endpoint
> \`\`\`
> 
> The proposed fix allows the \`baseURL\` parameter to be used to set the baseURL in the case of Azure deployments
> 
> If the baseURL isn't set in the case of Azure then we fall back to the current code path. So this should preserve backwards compatibility
> 
> I've added a unittest to cover the case where baseURL is set in the case AzureOpenAI
> 
> \### 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.

````auto
Version: 4.4.2
Summary: A python native Weaviate client
Home-page: https://github.com/weaviate/weaviate-python-client
Author: Weaviate
Author-email: hello@weaviate.io,
License: BSD 3-clause
Location: /Users/vedala/Documents/projects/OA/oa-answers/oaa/lib/python3.9/site-packages
Requires: authlib, grpcio, grpcio-health-checking, grpcio-tools, httpx, pydantic, requests, validators```
````

---

<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:** [March 13, 2024, 9:28pm UTC](https://forum.weaviate.io/t/issue-with-base-url-and-api-version-when-using-azureopenai-862/1707/2 "2024-03-13T21:28:39Z")

</div>

Hi @pi_crust !

What is the server and client version?

Can you reproduce this on latest version of both Weaviate and the python client (4.X?)

Thanks!
