Api version in Query-time parameters?

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!

Hi @Steve,

You need to provide the base_url into the collection definition.
Here is the docs page for OpenAI with the available properties.

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

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:

from weaviate.classes.config import Configure

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

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

Btw. there is a GitHub issue 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 :wink:

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:

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

Then run a query:

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

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

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 :smile:

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

I appreciate this :point_up:
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.

1 Like