Search code examples
node.jsweaviate

Unable to connect to Weaviate


I am attempting to use weaviate-client in my nodejs application and followed Weaviate's documentation.

Unfortunately, their sample code doesn't seem to work for me at all.

import weaviate from 'weaviate-client'

const search = async () => {
    const client = await weaviate.connectToWCS(
        MY_WEAVIATE_URL, { 
          authCredentials: new weaviate.ApiKey(MY_API_KEY), 
          headers: {
            'X-OpenAI-Api-Key': MY_OPENAI_API_KEY,
          }
        } 
      )

    console.log(client)
}

search()

The error that I've been receiving is TypeError: weaviate.connectToWCS is not a function. Am I missing something?


Solution

  • We've recently renamed Weaviate Cloud Services (WCS) to Weaviate Cloud (WCD), as a result, this changed the connection function to weaviate.connectToWCD.

    By mistake, we removed weaviate.connectToWCS, instead of deprecating.

    Please use the following:

    import weaviate from 'weaviate-client'
    
    const search = async () => {
        const client = await weaviate.connectToWCD(
            MY_WEAVIATE_URL, { 
              authCredentials: new weaviate.ApiKey(MY_API_KEY), 
              headers: {
                'X-OpenAI-Api-Key': MY_OPENAI_API_KEY,
              }
            } 
          )
    
        console.log(client)
    }
    
    search()