# Api version in Query-time parameters?

**URL:** <https://forum.weaviate.io/t/api-version-in-query-time-parameters/2368>\
**Category:** Support\
**Tags:** python\
**Created:** [May 17, 2024, 11:14am UTC](https://forum.weaviate.io/t/api-version-in-query-time-parameters/2368 "2024-05-17T11:14:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/steve/32/1531_2.png) [@Steve](https://forum.weaviate.io/u/Steve)\
**Post date:** [May 17, 2024, 11:14am UTC](https://forum.weaviate.io/t/api-version-in-query-time-parameters/2368/1 "2024-05-17T11:14:49Z")

</div>

### Description

Hello,

We’ve been trying to use Weaviate on our testing environment.  
Our embedding queries don’t seem to work for our application as weaviate tries to connect to make a post request to:  
http://{baseUrl}/openai/deployments/{deployment\_id}/embeddings?api-version=2024-02-01"

The error we are getting is:  
dial tcp: lookup {baseUrl} on {…}: server misbehaving’

The embeddings are made using a different baseUrl than the ones we want to use on Query-time. So i have added “X-OpenAI-BaseURL”: {baseUrl} to the headers and the request url seems right. The Api version is set to 2024-02-01  
I was wondering if that is the problem to why we are getting this error message and if so would it be possible to change the api version in the headers as well?

Thank you!

---

<div class="post-metadata">

**Author:** ![sebawita](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/sebawita/32/5_2.png) [@sebawita](https://forum.weaviate.io/u/sebawita)\
**Post date:** [May 17, 2024, 1:04pm UTC](https://forum.weaviate.io/t/api-version-in-query-time-parameters/2368/2 "2024-05-17T13:04:33Z")

</div>

Hi @Steve,

You need to provide the base\_url into the collection definition.  
Here is the [docs page for OpenAI](https://weaviate.io/developers/weaviate/model-providers/openai/embeddings#example-configuration) with the available properties.

If you are using python, then you need to add `base_url` like this:

```python
from weaviate.classes.config import Configure

client.collections.create(
    "DemoCollection",
    vectorizer_config=[
        Configure.NamedVectors.text2vec_openai(
            name="title_vector",
            source_properties=["title"],
            base_url="custom_openai_url_here",
        )
    ],
    # ...
)

```

Btw. if you are not using named vectors, then the syntax is like this:

```auto
from weaviate.classes.config import Configure

client.collections.create(
    "DemoCollection",
    vectorizer_config=[
        Configure.Vectorizer.text2vec_openai(
            base_url="custom_openai_url_here",
        )
    ],
    # ...
)

```

---

<div class="post-metadata">

**Author:** ![Steve](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/steve/32/1531_2.png) [@Steve](https://forum.weaviate.io/u/Steve)\
**Post date:** [May 17, 2024, 1:17pm UTC](https://forum.weaviate.io/t/api-version-in-query-time-parameters/2368/3 "2024-05-17T13:17:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sebawita](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/sebawita/32/5_2.png) [@sebawita](https://forum.weaviate.io/u/sebawita)\
**Post date:** [May 17, 2024, 1:52pm UTC](https://forum.weaviate.io/t/api-version-in-query-time-parameters/2368/5 "2024-05-17T13:52:56Z")

</div>

> [@Steve](#):
>
> 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

Btw. there is a [GitHub issue](https://github.com/weaviate/weaviate/issues/4537) that asks for a similar change as your request.

Please upvote it, and feel free to add comments.  
This will help us give this higher priority 😉

---

<div class="post-metadata">

**Author:** ![sebawita](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/sebawita/32/5_2.png) [@sebawita](https://forum.weaviate.io/u/sebawita)\
**Post date:** [May 17, 2024, 1:58pm UTC](https://forum.weaviate.io/t/api-version-in-query-time-parameters/2368/6 "2024-05-17T13:58:10Z")

</div>

Oh, I’ve just noticed that you should be able to send `X-Openai-Baseurl` as a header value.

Can you check if you could do that using one of our clients?

For example, in python this should be something like this:

```auto
client = weaviate.connect_to_local(
    headers={
       "X-Openai-Baseurl": "your-base-url-here",
    }
)

```

Then run a query:

```auto
collection = client.collections.get("CollectionName")

response = collection.query.near_text(
    query="musical instruments",
    limit=5
)

```

---

<div class="post-metadata">

**Author:** ![Steve](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/steve/32/1531_2.png) [@Steve](https://forum.weaviate.io/u/Steve)\
**Post date:** [May 17, 2024, 1:59pm UTC](https://forum.weaviate.io/t/api-version-in-query-time-parameters/2368/7 "2024-05-17T13:59:33Z")

</div>

Yes that is what i’ve been trying to do but I’ve been getting the error:  
dial tcp: lookup {baseUrl} on {…}: server misbehaving’

I was wondering if it is related to the api-version? since that is something that i cannot set within the headers.

Thank you for the quick replies btw 😄

---

<div class="post-metadata">

**Author:** ![Steve](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/steve/32/1531_2.png) [@Steve](https://forum.weaviate.io/u/Steve)\
**Post date:** [May 17, 2024, 2:01pm UTC](https://forum.weaviate.io/t/api-version-in-query-time-parameters/2368/8 "2024-05-17T14:01:27Z")

</div>

could also be a security issue between weaviate → our environment?

---

<div class="post-metadata">

**Author:** ![sebawita](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/sebawita/32/5_2.png) [@sebawita](https://forum.weaviate.io/u/sebawita)\
**Post date:** [May 17, 2024, 2:02pm UTC](https://forum.weaviate.io/t/api-version-in-query-time-parameters/2368/9 "2024-05-17T14:02:43Z")

</div>

> [@Steve](#):
>
> Thank you for the quick replies btw 😄

I appreciate this ☝  
I was worried that due to my eagerness, I was sending you in the wrong direction.

Let me see if I can find someone that might know this part of the API.
