Skip to main content

Communicate with Weaviate

Here, we'll perform basic operations to communicate with Weaviate using the TypeScript client library.

Check Weaviate status

You can check whether the Weaviate instance is up using the isLive function.

if (await client.isLive()) {
// This will raise an exception if the client is not live
}

Retrieve server meta information

You can retrieve meta information about the Weaviate instance using the getMeta function.

console.log(await client.getMeta())

This will print the server meta information to the console. The output will look similar to the following:

Example getMeta() output
{
hostname: 'http://[::]:8080',
modules: {
'backup-gcs': {
bucketName: 'weaviate-wcs-prod-cust-europe-west3-workloads-backups',
rootName: '55a78146-dae1-4609-90ce-556db01f4a61'
},
'generative-anyscale': {
documentationHref: 'https://docs.anyscale.com/endpoints/overview',
name: 'Generative Search - Anyscale'
},
'generative-aws': {
documentationHref: 'https://docs.aws.amazon.com/bedrock/latest/APIReference/welcome.html',
name: 'Generative Search - AWS'
},
'generative-cohere': {
documentationHref: 'https://docs.cohere.com/reference/chat',
name: 'Generative Search - Cohere'
},
'generative-mistral': {
documentationHref: 'https://docs.mistral.ai/api/',
name: 'Generative Search - Mistral'
},
'generative-openai': {
documentationHref: 'https://platform.openai.com/docs/api-reference/completions',
name: 'Generative Search - OpenAI'
},
'generative-palm': {
documentationHref: 'https://cloud.google.com/vertex-ai/docs/generative-ai/chat/test-chat-prompts',
name: 'Generative Search - Google PaLM'
},
'multi2vec-palm': {
documentationHref: 'https://cloud.google.com/vertex-ai/generative-ai/docs/embeddings/get-multimodal-embeddings',
name: 'Google PaLM Multimodal Module'
},
'qna-openai': {
documentationHref: 'https://platform.openai.com/docs/api-reference/completions',
name: 'OpenAI Question & Answering Module'
},
'ref2vec-centroid': {},
'reranker-cohere': {
documentationHref: 'https://txt.cohere.com/rerank/',
name: 'Reranker - Cohere'
},
'reranker-voyageai': {
documentationHref: 'https://docs.voyageai.com/reference/reranker-api',
name: 'Reranker - VoyageAI'
},
'text2vec-aws': {
documentationHref: 'https://docs.aws.amazon.com/bedrock/latest/userguide/titan-embedding-models.html',
name: 'AWS Module'
},
'text2vec-cohere': {
documentationHref: 'https://docs.cohere.ai/embedding-wiki/',
name: 'Cohere Module'
},
'text2vec-huggingface': {
documentationHref: 'https://huggingface.co/docs/api-inference/detailed_parameters#feature-extraction-task',
name: 'Hugging Face Module'
},
'text2vec-jinaai': {
documentationHref: 'https://jina.ai/embeddings/',
name: 'JinaAI Module'
},
'text2vec-openai': {
documentationHref: 'https://platform.openai.com/docs/guides/embeddings/what-are-embeddings',
name: 'OpenAI Module'
},
'text2vec-palm': {
documentationHref: 'https://cloud.google.com/vertex-ai/docs/generative-ai/embeddings/get-text-embeddings',
name: 'Google PaLM Module'
},
'text2vec-voyageai': {
documentationHref: 'https://docs.voyageai.com/docs/embeddings',
name: 'VoyageAI Module'
}
},
version: '1.25.5'
}

Close the connection

After you have finished using the Weaviate client, you should close the connection. This frees up resources and ensures that the connection is properly closed.

We suggest using a try-finally block as a best practice. For brevity, we will not include the try-finally blocks in the remaining code snippets.

import weaviate, { WeaviateClient } from "weaviate-client";
let client: WeaviateClient;

// Instantiate your client (not shown). e.g.:
// client = weaviate.connect_to_weaviate_cloud(...) or
// client = weaviate.connect_to_local(...)

try {
// Work with the client here
if (await client.isLive()) {
// ...
}
} finally { // This will always be executed, even if an exception is raised
client.close() // Close the connection & release resources
}

Questions and feedback

If you have any questions or feedback, let us know in the user forum.