---
title: "Quickstart: With Cloud resources"
description: "Weaviate is an open-source vector database built to power AI applications. This quickstart guide will show you how to:"
url: https://docs.weaviate.io/weaviate/quickstart
---

# Quickstart: With Cloud resources

Weaviate is an open-source vector database built to power AI applications. This quickstart guide will show you how to:

1. **Set up a collection** - Create a collection and import data into it.
2. **Search** - Perform a similarity (vector) search on your data.
3. **RAG** - Perform Retrieval Augmented Generation (RAG) with a generative model.
4. **Query Agent** - Get answers from your data by using a natural language prompt/question.

If you encounter any issues along the way or have additional questions, use the Ask AI feature.

## Prerequisites

A **[Weaviate Cloud](https://console.weaviate.cloud/)** free cluster - you will need an admin **API key** and a **REST endpoint URL** to connect to your instance. See the instructions below for more info. If you don't want to use Weaviate Cloud, check out the [Local Quickstart](https://docs.weaviate.io/weaviate/quickstart/local) with Docker.

**How to set up a Weaviate Cloud free cluster**

Go to the [Weaviate Cloud console](https://console.weaviate.cloud) and create a free cluster as shown in the interactive example below.

[Embedded content](https://app.guideflow.com/embed/3r3vg6mcnp)



> [!NOTE]
>
> - Cluster provisioning typically takes 1-3 minutes.
> - When the cluster is ready, Weaviate Cloud displays a checkmark (`✔️`) next to the cluster name.
> - Note that Weaviate Cloud may add a random suffix to cluster names to ensure uniqueness.

**How to retrieve Weaviate Cloud credentials (`WEAVIATE_API_KEY` and `WEAVIATE_URL`)**

After you create a Weaviate Cloud instance, you will need the:

- **REST Endpoint URL** and the
- **Administrator API Key**.

You can retrieve them both from the [WCD console](https://docs.weaviate.io/go/console?utm_content=quickstart) as shown in the interactive example below.

[Embedded content](https://app.guideflow.com/embed/6kwn8ldczk)



> [!NOTE]
>
> **REST vs gRPC endpoints**
>
> Weaviate supports both REST and gRPC protocols. For Weaviate Cloud deployments, you only need to provide the REST endpoint URL - the client will automatically configure gRPC.

Once you have the **REST Endpoint URL** and the **admin API key**, you can connect to your cluster, and work with Weaviate.

---

## Install a client library

Follow the instructions below to install one of the official client libraries, available in [Python](https://docs.weaviate.io/weaviate/client-libraries/python), [JavaScript/TypeScript](https://docs.weaviate.io/weaviate/client-libraries/typescript), [Go](https://docs.weaviate.io/weaviate/client-libraries/go), and [Java](https://docs.weaviate.io/weaviate/client-libraries/java).

**Python**

```bash
pip install -U "weaviate-client[agents]"
```

**JavaScript/TypeScript**

```bash
npm install @weaviate/node @weaviate/agents
```

**Go (v5)**

```bash
go get github.com/weaviate/weaviate-go-client/v5
```

**Go (v6)**

```bash
go get github.com/weaviate/weaviate-go-client/v6
```

**Java**

```xml
<dependency>
  <groupId>io.weaviate</groupId>
  <artifactId>client6</artifactId>
  <version>6.3.1</version> <!-- Check latest version: https://github.com/weaviate/java-client  -->
</dependency>
```

**C#**

```xml
<PackageReference Include="Weaviate.Client" Version="1.0.0" />
```

**Verify your setup**

Before you create anything, you can also check that the client can reach your cluster:

**Python**

quickstart\_check\_readiness.py

```py
import weaviate
from weaviate.classes.init import Auth
import os

# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]

client = weaviate.connect_to_weaviate_cloud(
    cluster_url=weaviate_url,
    auth_credentials=Auth.api_key(weaviate_api_key),
)

print(client.is_ready())  # Should print: `True`

client.close()  # Free up resources
```

**JavaScript/TypeScript**

quickstart\_check\_readiness.ts

```ts
import weaviate, { WeaviateClient } from '@weaviate/node';

// Best practice: store your credentials in environment variables
const weaviateUrl = process.env.WEAVIATE_URL as string;
const weaviateApiKey = process.env.WEAVIATE_API_KEY as string;

const client: WeaviateClient = await weaviate.connectToWeaviateCloud(
  weaviateUrl, // Replace with your Weaviate Cloud URL
  {
    authCredentials: new weaviate.ApiKey(weaviateApiKey), // Replace with your Weaviate Cloud API key
  }
);

var clientReadiness = await client.isReady();
console.log(clientReadiness); // Should return `true`

client.close(); // Close the client connection
```

**Go (v6)**

quickstart/1\_check\_readiness/main.go

```go
// Set these environment variables
// WEAVIATE_HOSTNAME            your Weaviate instance hostname
// WEAVIATE_API_KEY          your Weaviate instance API key

package main

import (
    "context"
    "fmt"
    "os"

    "github.com/weaviate/weaviate-go-client/v5/weaviate"
    "github.com/weaviate/weaviate-go-client/v5/weaviate/auth"
)

func main() {
    cfg := weaviate.Config{
        Host:       os.Getenv("WEAVIATE_HOSTNAME"),
        Scheme:     "https",
        AuthConfig: auth.ApiKey{Value: os.Getenv("WEAVIATE_API_KEY")},
    }

    client, err := weaviate.NewClient(cfg)
    if err != nil {
        fmt.Println(err)
    }

    // Check the connection
    ready, err := client.Misc().ReadyChecker().Do(context.Background())
    if err != nil {
        panic(err)
    }
    fmt.Printf("%v", ready)
}
```

> [!WARNING]
>
> This client uses the `hostname` parameter (without the `https` scheme) instead of a complete `URL`.

**Java**

```java
// Best practice: store your credentials in environment variables
String weaviateUrl = System.getenv("WEAVIATE_URL");
String weaviateApiKey = System.getenv("WEAVIATE_API_KEY");

WeaviateClient client = WeaviateClient.connectToWeaviateCloud(
    weaviateUrl, // Replace with your Weaviate Cloud URL
    weaviateApiKey // Replace with your Weaviate Cloud key
);
System.out.println(client.isReady()); // Should print: `True`

client.close(); // Free up resources
```

**C#**

```csharp
// Best practice: store your credentials in environment variables
string weaviateUrl = Environment.GetEnvironmentVariable("WEAVIATE_URL");
string weaviateApiKey = Environment.GetEnvironmentVariable("WEAVIATE_API_KEY");

WeaviateClient client = await Connect.Cloud(weaviateUrl, weaviateApiKey);

// GetMeta returns server info. A successful call indicates readiness.
var meta = await client.IsReady();
Console.WriteLine(meta);
```

> [!WARNING]
>
> This client uses the `hostname` parameter (without the `https` scheme) instead of a complete `URL`.

**Curl**

```bash
# Best practice: store your credentials in environment variables
# export WEAVIATE_URL="YOUR_INSTANCE_URL"  # Your Weaviate instance URL
# export WEAVIATE_API_KEY="YOUR_API_KEY"   # Your Weaviate instance API key

curl -w "\nResponse code: %{http_code}\n" \
  -H "Authorization: Bearer $WEAVIATE_API_KEY" \
  $WEAVIATE_URL/v1/.well-known/ready

# You should see "Response code: 200" if the instance is ready
```

Some common first errors include:

| What you see | What it means |
| - | - |
| `unauthorized: invalid api key` (HTTP 401) | The key is wrong or is not an admin key. Copy the **Admin** key from your cluster's **API keys** tab. |
| `Unfortunately, the gRPC health check against Weaviate could not be completed.` | The client reached REST but not gRPC. Check the endpoint format for your client: the Go and C# clients want a bare hostname, without `https://`. On a self-hosted instance, also check that port `50051` is published and not blocked. |
| `no vectorizer found for class "Movie"` | You ran a `nearText` query against a collection that has no vectorizer. Create the collection with a vectorizer, or query with `nearVector` and supply the vector yourself. |
| `no api key found neither in request header: ... nor in environment variable under ...` | The model provider key never reached Weaviate. Pass it in the connection headers, as in the [model provider](https://docs.weaviate.io/weaviate/model-providers) examples. |
| `Con004: The connection to Weaviate was not closed properly.` | The script finished without closing the client. Call `client.close()`, or use a context manager. |

---

## Step 1: Create a collection & import data

There are two paths you can choose from when importing data:

[Vectorize objects during import\
(recommended)](https://docs.weaviate.io/weaviate/quickstart?import=vectorization#create-a-collection): Import objects and vectorize them with the Weaviate Embeddings service.

[Import vectors](https://docs.weaviate.io/weaviate/quickstart?import=custom-embeddings#create-a-collection): Import pre-computed vector embeddings along with your data.



#### Vectorize objects during import

The following example creates a collection called `Movie`. The data will be vectorized with the Weaviate Embeddings model provider. You are also free to use any other available [embedding model provider](https://docs.weaviate.io/weaviate/model-providers).

**Python**

```py
import weaviate
from weaviate.classes.config import Configure
import os

# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]

# Step 1.1: Connect to your Weaviate Cloud instance
with weaviate.connect_to_weaviate_cloud(
    cluster_url=weaviate_url,
    auth_credentials=weaviate_api_key,
) as client:

    # Step 1.2: Create a collection
    movies = client.collections.create(
        name="Movie",
        vector_config=Configure.Vectors.text2vec_weaviate(),  # Configure the Weaviate Embeddings vectorizer
    )

    # Step 1.3: Import three objects
    data_objects = [
        {"title": "The Matrix", "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers.", "genre": "Science Fiction"},
        {"title": "Spirited Away", "description": "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.", "genre": "Animation"},
        {"title": "The Lord of the Rings: The Fellowship of the Ring", "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.", "genre": "Fantasy"},
    ]

    movies = client.collections.use("Movie")
    movies.data.ingest(data_objects)

    print(f"Imported & vectorized {len(movies)} objects into the Movie collection")
```

**JavaScript/TypeScript**

```ts
import weaviate, { WeaviateClient, ApiKey, vectors } from '@weaviate/node';

// Best practice: store your credentials in environment variables
const weaviateUrl = process.env.WEAVIATE_URL!;
const weaviateApiKey = process.env.WEAVIATE_API_KEY!;

// Step 1.1: Connect to your Weaviate Cloud instance
const client: WeaviateClient = await weaviate.connectToWeaviateCloud(
  weaviateUrl,
  {
    authCredentials: new ApiKey(weaviateApiKey),
  }
);

// Step 1.2: Create a collection
const movies = await client.collections.create({
  name: 'Movie',
  vectorizers: vectors.text2VecWeaviate(),
});

// Step 1.3: Import three objects
const dataObjects = [
  { title: 'The Matrix', description: 'A computer hacker learns about the true nature of reality and his role in the war against its controllers.', genre: 'Science Fiction' },
  { title: 'Spirited Away', description: 'A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.', genre: 'Animation' },
  { title: 'The Lord of the Rings: The Fellowship of the Ring', description: 'A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.', genre: 'Fantasy' },
];

const movieCollection = client.collections.get('Movie');
await movieCollection.data.ingest(
  dataObjects.map((properties) => ({ properties }))
);

console.log(`Imported & vectorized ${dataObjects.length} objects into the Movie collection`);

await client.close(); // Free up resources
```

**Go (v5)**

The collection also contains a configuration for the generative (RAG) integration:

- Anthropic [generative AI integrations](https://docs.weaviate.io/weaviate/model-providers/anthropic/generative) for retrieval augmented generation (RAG).

```go
import (
    "context"
    "fmt"
    "os"

    "github.com/weaviate/weaviate-go-client/v5/weaviate"
    "github.com/weaviate/weaviate-go-client/v5/weaviate/auth"
    "github.com/weaviate/weaviate/entities/models"
)

func main() {
    // Best practice: store your credentials in environment variables
    weaviateURL := os.Getenv("WEAVIATE_HOST")
    weaviateAPIKey := os.Getenv("WEAVIATE_API_KEY")

    // Step 1.1: Connect to your Weaviate Cloud instance
    cfg := weaviate.Config{
        Host:       weaviateURL,
        Scheme:     "https",
        AuthConfig: auth.ApiKey{Value: weaviateAPIKey},
    }
    client, err := weaviate.NewClient(cfg)
    if err != nil {
        panic(err)
    }

    // Step 1.2: Create a collection
    classObj := &models.Class{
        Class:      "Movie",
        Vectorizer: "text2vec-weaviate",
        ModuleConfig: map[string]interface{}{
            "generative-anthropic": map[string]interface{}{
                "model": "claude-haiku-4-5",
            },
        },
    }

    err = client.Schema().ClassCreator().WithClass(classObj).Do(context.Background())
    if err != nil {
        panic(err)
    }

    // Step 1.3: Import three objects
    dataObjects := []map[string]interface{}{
        {
            "title":       "The Matrix",
            "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
            "genre":       "Science Fiction",
        },
        {
            "title":       "Spirited Away",
            "description": "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
            "genre":       "Animation",
        },
        {
            "title":       "The Lord of the Rings: The Fellowship of the Ring",
            "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
            "genre":       "Fantasy",
        },
    }

    // Insert objects
    objects := make([]*models.Object, len(dataObjects))
    for i, obj := range dataObjects {
        objects[i] = &models.Object{
            Class:      "Movie",
            Properties: obj,
        }
    }

    _, err = client.Batch().ObjectsBatcher().WithObjects(objects...).Do(context.Background())
    if err != nil {
        panic(err)
    }

    fmt.Printf("Imported & vectorized %d objects into the Movie collection\n", len(dataObjects))
```

**Go (v6)**

> [!NOTE]
>
> **Go client `v6`**
>
> This tab uses the [`v6` Go client](https://docs.weaviate.io/weaviate/client-libraries/go). It vectorizes data with [Weaviate Embeddings](https://docs.weaviate.io/weaviate/model-providers/weaviate/embeddings) (the `text2vec-weaviate` module). Collection-level generative (RAG) configuration is not yet available in the client, so it is omitted here (see Step 3).

```go
package main

import (
  "context"
  "fmt"
  "os"

  weaviate "github.com/weaviate/weaviate-go-client/v6"
  "github.com/weaviate/weaviate-go-client/v6/collections"
  "github.com/weaviate/weaviate-go-client/v6/data"
  wembed "github.com/weaviate/weaviate-go-client/v6/modules/weaviate"
)

func main() {
  ctx := context.Background()

  // Best practice: store your credentials in environment variables.
  // Step 1.1: Connect to your Weaviate Cloud instance.
  client, err := weaviate.NewWeaviateCloud(
    ctx,
    os.Getenv("WEAVIATE_URL"),     // e.g. "my-cluster.weaviate.cloud"
    os.Getenv("WEAVIATE_API_KEY"), // an admin API key
  )
  if err != nil {
    // handle error
    panic(err)
  }
  defer client.Close()

  // Step 1.2: Create a collection vectorized by Weaviate Embeddings
  // (the text2vec-weaviate module).
  if _, err := client.Collections.Create(ctx, collections.Collection{
    Name: "Movie",
    Properties: []collections.Property{
      {Name: "title", DataType: collections.DataTypeText},
      {Name: "description", DataType: collections.DataTypeText},
      {Name: "genre", DataType: collections.DataTypeText},
    },
    Vectors: map[string]collections.VectorConfig{
      "default": {Vectorizer: wembed.Text2Vec{}},
    },
  }); err != nil {
    // handle error
    panic(err)
  }

  // Step 1.3: Import a few objects. Weaviate Embeddings vectorizes each on import.
  if _, err := client.Collections.Use("Movie").Data.Insert(ctx,
    &data.Object{Properties: map[string]any{
      "title":       "The Matrix",
      "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
      "genre":       "Science Fiction",
    }},
    &data.Object{Properties: map[string]any{
      "title":       "Spirited Away",
      "description": "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
      "genre":       "Animation",
    }},
    &data.Object{Properties: map[string]any{
      "title":       "The Lord of the Rings: The Fellowship of the Ring",
      "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
      "genre":       "Fantasy",
    }},
  ); err != nil {
    // handle error
    panic(err)
  }

  fmt.Println("Imported & vectorized 3 objects into the Movie collection")
}
```

**Java**

```java
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import io.weaviate.client6.v1.api.collections.Property;
import io.weaviate.client6.v1.api.collections.VectorConfig;
import io.weaviate.client6.v1.api.collections.WeaviateObject;
import io.weaviate.client6.v1.api.collections.batch.BatchContext;

import java.util.List;
import java.util.Map;

public class QuickstartCreate {

  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;
    String collectionName = "Movie";

    try {
      // Best practice: store your credentials in environment variables
      String weaviateUrl = System.getenv("WEAVIATE_URL");
      String weaviateApiKey = System.getenv("WEAVIATE_API_KEY");

      // Step 1.1: Connect to your Weaviate Cloud instance
      client =
          WeaviateClient.connectToWeaviateCloud(weaviateUrl, weaviateApiKey);
      // Step 1.2: Create a collection
      client.collections.create(collectionName,
          col -> col.vectorConfig(VectorConfig.text2vecWeaviate())
              // Define properties for the collection
              .properties(Property.text("title"), Property.text("description"),
                  Property.text("genre")));

      // Step 1.3: Import three objects
      List<Map<String, Object>> dataObjects = List.of(Map.of("title",
          "The Matrix", "description",
          "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
          "genre", "Science Fiction"),
          Map.of("title", "Spirited Away", "description",
              "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
              "genre", "Animation"),
          Map.of("title", "The Lord of the Rings: The Fellowship of the Ring",
              "description",
              "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
              "genre", "Fantasy"));

      // Insert the objects using server-side batching
      CollectionHandle<Map<String, Object>> movies =
          client.collections.use(collectionName);
      BatchContext<Map<String, Object>> batch = movies.batch.start();
      // Closing the batch sends the remaining objects and waits for the results
      try (batch) {
        for (Map<String, Object> properties : dataObjects) {
          batch.add(
              WeaviateObject.<Map<String, Object>>of(o -> o.properties(properties)));
        }
      }

      if (batch.numberOfErrors() > 0) {
        System.err
            .println("Number of failed imports: " + batch.numberOfErrors());
      } else {
        System.out.println("Imported & vectorized " + dataObjects.size()
            + " objects into the Movie collection");
      }
    } finally {
      if (client != null) {
        client.close(); // Free up resources
      }
    }
  }
}
```

**C#**

```csharp
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Weaviate.Client;
using Weaviate.Client.Models;

namespace WeaviateProject.Examples
{
    public class QuickstartCreate
    {
public static async Task Run()
{
    // Best practice: store your credentials in environment variables
    string weaviateUrl = Environment.GetEnvironmentVariable("WEAVIATE_URL");
    string weaviateApiKey = Environment.GetEnvironmentVariable("WEAVIATE_API_KEY");
    string collectionName = "Movie";

    // Connect to your Weaviate Cloud instance
    var client = await Connect.Cloud(weaviateUrl, weaviateApiKey);

    // Create a collection
    var movies = await client.Collections.Create(
        new CollectionCreateParams
        {
            Name = collectionName,
            VectorConfig = Configure.Vector("default", v => v.Text2VecWeaviate()),
            // Define properties for the collection
            Properties =
            [
                Property.Text("title"),
                Property.Text("description"),
                Property.Text("genre"),
            ],
        }
    );

    // Import three objects
    var dataObjects = new List<object>
    {
        new
        {
            title = "The Matrix",
            description = "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
            genre = "Science Fiction",
        },
        new
        {
            title = "Spirited Away",
            description = "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
            genre = "Animation",
        },
        new
        {
            title = "The Lord of the Rings: The Fellowship of the Ring",
            description = "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
            genre = "Fantasy",
        },
    };

    // Insert the objects using server-side batching
    var insertResponse = await movies.Batch.InsertMany(dataObjects);

    if (insertResponse.HasErrors)
    {
        Console.WriteLine($"Errors during import: {insertResponse.Errors}");
    }
    else
    {
        Console.WriteLine(
            $"Imported & vectorized {insertResponse.Count} objects into the Movie collection"
        );
    }
}
    }
}
```

#### Import vectors

The following example creates a collection called `Movie`. The data should already contain the pre-computed vector embeddings. This option is useful for when you are migrating data from a different vector database.

**Python**

```py
import weaviate
from weaviate.classes.config import Configure
from weaviate.classes.data import DataObject
import os

# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]

# Step 1.1: Connect to your Weaviate Cloud instance
with weaviate.connect_to_weaviate_cloud(
    cluster_url=weaviate_url,
    auth_credentials=weaviate_api_key,
) as client:
    
    # Step 1.2: Create a collection
    movies = client.collections.create(
        name="Movie",
        vector_config=Configure.Vectors.self_provided(),  # No automatic vectorization since we're providing vectors
    )

    # Step 1.3: Import three objects
    data_objects = [
        {"properties": {"title": "The Matrix", "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers.", "genre": "Science Fiction"},
        "vector": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]},
        {"properties": {"title": "Spirited Away", "description": "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.", "genre": "Animation"},
        "vector": [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]},
        {"properties": {"title": "The Lord of the Rings: The Fellowship of the Ring", "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.", "genre": "Fantasy"},
        "vector": [0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]}
    ]

    # Insert the objects with vectors
    movies = client.collections.get("Movie")
    movies.data.ingest(
        DataObject(properties=obj["properties"], vector=obj["vector"])
        for obj in data_objects
    )

    print(
        f"Imported {len(data_objects)} objects with vectors into the Movie collection"
    )
```

**JavaScript/TypeScript**

```ts
import weaviate, { WeaviateClient, ApiKey, vectors } from '@weaviate/node';

// Best practice: store your credentials in environment variables
const weaviateUrl = process.env.WEAVIATE_URL!;
const weaviateApiKey = process.env.WEAVIATE_API_KEY!;

// Step 1.1: Connect to your Weaviate Cloud instance
const client: WeaviateClient = await weaviate.connectToWeaviateCloud(
  weaviateUrl,
  {
    authCredentials: new ApiKey(weaviateApiKey),
  }
);

// Step 1.2: Create a collection
const movies = await client.collections.create({
  name: 'Movie',
  vectorizers: vectors.selfProvided(), // No automatic vectorization since we're providing vectors
});

// Step 1.3: Import three objects
const dataObjects = [
  {
    properties: { title: 'The Matrix', description: 'A computer hacker learns about the true nature of reality and his role in the war against its controllers.', genre: 'Science Fiction' },
    vectors: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
  },
  {
    properties: { title: 'Spirited Away', description: 'A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.', genre: 'Animation' },
    vectors: [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
  },
  {
    properties: { title: 'The Lord of the Rings: The Fellowship of the Ring', description: 'A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.', genre: 'Fantasy' },
    vectors: [0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0],
  },
];

// Insert the objects with vectors
const movieCollection = client.collections.get('Movie');
await movieCollection.data.ingest(dataObjects);

console.log(`Imported ${dataObjects.length} objects with vectors into the Movie collection`);

await client.close(); // Free up resources
```

**Go (v5)**

The collection also contains a configuration for the generative (RAG) integration:

- Anthropic [generative AI integrations](https://docs.weaviate.io/weaviate/model-providers/anthropic/generative) for retrieval augmented generation (RAG).

```go
import (
    "context"
    "fmt"
    "os"

    "github.com/weaviate/weaviate-go-client/v5/weaviate"
    "github.com/weaviate/weaviate-go-client/v5/weaviate/auth"
    "github.com/weaviate/weaviate/entities/models"
)

func main() {
    // Best practice: store your credentials in environment variables
    weaviateURL := os.Getenv("WEAVIATE_HOST")
    weaviateAPIKey := os.Getenv("WEAVIATE_API_KEY")

    // Step 1.1: Connect to your Weaviate Cloud instance
    cfg := weaviate.Config{
        Host:       weaviateURL,
        Scheme:     "https",
        AuthConfig: auth.ApiKey{Value: weaviateAPIKey},
    }
    client, err := weaviate.NewClient(cfg)
    if err != nil {
        panic(err)
    }

    // Step 1.2: Create a collection
    classObj := &models.Class{
        Class:      "Movie",
        Vectorizer: "none", // No automatic vectorization since we're providing vectors
        ModuleConfig: map[string]interface{}{
            "generative-anthropic": map[string]interface{}{
                "model": "claude-haiku-4-5",
            },
        },
    }

    err = client.Schema().ClassCreator().WithClass(classObj).Do(context.Background())
    if err != nil {
        panic(err)
    }

    // Step 1.3: Import three objects
    dataObjects := []struct {
        Properties map[string]interface{}
        Vector     []float32
    }{
        {
            Properties: map[string]interface{}{
                "title":       "The Matrix",
                "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
                "genre":       "Science Fiction",
            },
            Vector: []float32{0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8},
        },
        {
            Properties: map[string]interface{}{
                "title":       "Spirited Away",
                "description": "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
                "genre":       "Animation",
            },
            Vector: []float32{0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9},
        },
        {
            Properties: map[string]interface{}{
                "title":       "The Lord of the Rings: The Fellowship of the Ring",
                "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
                "genre":       "Fantasy",
            },
            Vector: []float32{0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0},
        },
    }

    // Insert the objects with vectors
    objects := make([]*models.Object, len(dataObjects))
    for i, obj := range dataObjects {
        objects[i] = &models.Object{
            Class:      "Movie",
            Properties: obj.Properties,
            Vector:     obj.Vector,
        }
    }

    _, err = client.Batch().ObjectsBatcher().WithObjects(objects...).Do(context.Background())
    if err != nil {
        panic(err)
    }

    fmt.Printf("Imported %d objects with vectors into the Movie collection\n", len(dataObjects))
```

**Java**

```java
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import io.weaviate.client6.v1.api.collections.Property;
import io.weaviate.client6.v1.api.collections.VectorConfig;
import io.weaviate.client6.v1.api.collections.Vectors;
import io.weaviate.client6.v1.api.collections.WeaviateObject;
import io.weaviate.client6.v1.api.collections.batch.BatchContext;
import java.util.List;
import java.util.Map;

public class QuickstartCreateVectors {

  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;
    String collectionName = "Movie";

    try {
      // Best practice: store your credentials in environment variables
      String weaviateUrl = System.getenv("WEAVIATE_URL");
      String weaviateApiKey = System.getenv("WEAVIATE_API_KEY");

      // Step 1.1: Connect to your Weaviate Cloud instance
      client =
          WeaviateClient.connectToWeaviateCloud(weaviateUrl, weaviateApiKey);
      // Step 1.2: Create a collection
      client.collections.create(collectionName, col -> col
          // No automatic vectorization since we're providing vectors
          .vectorConfig(VectorConfig.selfProvided())
          // Define properties for the collection
          .properties(Property.text("title"), Property.text("description"),
              Property.text("genre")));

      // Step 1.3: Import three objects
      Map<String, Object> props1 = Map.of("title", "The Matrix", "description",
          "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
          "genre", "Science Fiction");
      float[] vector1 =
          new float[] {0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f};

      Map<String, Object> props2 = Map.of("title", "Spirited Away",
          "description",
          "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
          "genre", "Animation");
      float[] vector2 =
          new float[] {0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f};

      Map<String, Object> props3 = Map.of("title",
          "The Lord of the Rings: The Fellowship of the Ring", "description",
          "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
          "genre", "Fantasy");
      float[] vector3 =
          new float[] {0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f};

      // Insert the objects with vectors using server-side batching
      CollectionHandle<Map<String, Object>> movies =
          client.collections.use(collectionName);
      List<WeaviateObject<Map<String, Object>>> objectsToInsert = List.of(
          WeaviateObject.of(v -> v.properties(props1)
              .vectors(Vectors.of(vector1))),
          WeaviateObject.of(v -> v.properties(props2)
              .vectors(Vectors.of(vector2))),
          WeaviateObject.of(v -> v.properties(props3)
              .vectors(Vectors.of(vector3))));

      BatchContext<Map<String, Object>> batch = movies.batch.start();
      // Closing the batch sends the remaining objects and waits for the results
      try (batch) {
        for (WeaviateObject<Map<String, Object>> object : objectsToInsert) {
          batch.add(object);
        }
      }

      if (batch.numberOfErrors() > 0) {
        System.err
            .println("Number of failed imports: " + batch.numberOfErrors());
      } else {
        System.out.println("Imported " + objectsToInsert.size()
            + " objects with vectors into the Movie collection");
      }
    } finally {
      if (client != null) {
        client.close(); // Free up resources
      }
    }
  }
}
```

**C#**

```csharp
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Weaviate.Client;
using Weaviate.Client.Models;

namespace WeaviateProject.Examples
{
    public class QuickstartCreateVectors
    {
public static async Task Run()
{
    string weaviateUrl = Environment.GetEnvironmentVariable("WEAVIATE_URL");
    string weaviateApiKey = Environment.GetEnvironmentVariable("WEAVIATE_API_KEY");
    string collectionName = "Movie";

    var client = await Connect.Cloud(weaviateUrl, weaviateApiKey);

    // Step 1.2: Create a collection
    var movies = await client.Collections.Create(
        new CollectionCreateParams
        {
            Name = collectionName,
            VectorConfig = Configure.Vector("default", v => v.SelfProvided()),
            Properties =
            [
                Property.Text("title"),
                Property.Text("description"),
                Property.Text("genre"),
            ],
        }
    );

    // Step 1.3: Import three objects using collection initialization
    var dataToInsert = new List<BatchInsertRequest>
    {
        new BatchInsertRequest(
            new
            {
                title = "The Matrix",
                description = "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
                genre = "Science Fiction",
            },
            null,
            new Vectors
            {
                {
                    "default",
                    new float[] { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f }
                },
            }
        ),
        new BatchInsertRequest(
            new
            {
                title = "Spirited Away",
                description = "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
                genre = "Animation",
            },
            null,
            new Vectors
            {
                {
                    "default",
                    new float[] { 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f }
                },
            }
        ),
        new BatchInsertRequest(
            new
            {
                title = "The Lord of the Rings: The Fellowship of the Ring",
                description = "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
                genre = "Fantasy",
            },
            null,
            new Vectors
            {
                {
                    "default",
                    new float[] { 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f }
                },
            }
        ),
    };

    // Insert the objects with vectors using server-side batching
    var insertResponse = await movies.Batch.InsertMany(dataToInsert);

    if (insertResponse.HasErrors)
    {
        Console.WriteLine($"Errors during import: {insertResponse.Errors}");
    }
    else
    {
        Console.WriteLine(
            $"Imported {insertResponse.Count} objects with vectors into the Movie collection"
        );
    }
}
    }
}
```

## Step 2: Semantic (vector) search

> [!TIP]
>
> **For production use**
>
> This step shows vector search on its own. For most applications, start with [hybrid search](https://docs.weaviate.io/weaviate/search/hybrid), which combines vector search with lexical or keyword (BM25) search for a "best of both worlds" performance.

#### Vectorize objects during import

Semantic search finds results based on meaning. This is called `nearText` in Weaviate. The following example searches for 2 objects (*limit*) whose meaning is most similar to that of `sci-fi`.

**Python**

```py
import weaviate
import os, json

# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]

# Step 2.1: Connect to your Weaviate Cloud instance
with weaviate.connect_to_weaviate_cloud(
    cluster_url=weaviate_url,
    auth_credentials=weaviate_api_key,
) as client:

    # Step 2.2: Use this collection
    movies = client.collections.use("Movie")

    # Step 2.3: Perform a semantic search with NearText
    response = movies.query.near_text(
        query="sci-fi",
        limit=2
    )

    for obj in response.objects:
        print(json.dumps(obj.properties, indent=2))  # Inspect the results
```

**JavaScript/TypeScript**

```ts
import weaviate, { WeaviateClient, ApiKey } from '@weaviate/node';

// Best practice: store your credentials in environment variables
const weaviateUrl = process.env.WEAVIATE_URL!;
const weaviateApiKey = process.env.WEAVIATE_API_KEY!;

// Step 2.1: Connect to your Weaviate Cloud instance
const client: WeaviateClient = await weaviate.connectToWeaviateCloud(
  weaviateUrl,
  {
    authCredentials: new ApiKey(weaviateApiKey),
  }
);

// Step 2.2: Use this collection
const movies = client.collections.get('Movie');

// Step 2.3: Perform a semantic search with NearText
const response = await movies.query.nearText(
  'sci-fi',
  {
    limit: 2,
  }
);

for (const obj of response.objects) {
  console.log(JSON.stringify(obj.properties, null, 2)); // Inspect the results
}

await client.close(); // Free up resources
```

**Go (v5)**

```go
import (
    "context"
    "encoding/json"
    "fmt"
    "os"

    "github.com/weaviate/weaviate-go-client/v5/weaviate"
    "github.com/weaviate/weaviate-go-client/v5/weaviate/auth"
    "github.com/weaviate/weaviate-go-client/v5/weaviate/graphql"
)

func main() {
    // Best practice: store your credentials in environment variables
    weaviateURL := os.Getenv("WEAVIATE_HOST")
    weaviateAPIKey := os.Getenv("WEAVIATE_API_KEY")

    // Step 1.1: Connect to your Weaviate Cloud instance
    cfg := weaviate.Config{
        Host:       weaviateURL,
        Scheme:     "https",
        AuthConfig: auth.ApiKey{Value: weaviateAPIKey},
    }
    client, err := weaviate.NewClient(cfg)
    if err != nil {
        panic(err)
    }

    // Step 2.2: Perform a semantic search with NearText
    title := graphql.Field{Name: "title"}
    description := graphql.Field{Name: "description"}
    genre := graphql.Field{Name: "genre"}

    nearText := client.GraphQL().NearTextArgBuilder().
        WithConcepts([]string{"sci-fi"})

    result, err := client.GraphQL().Get().
        WithClassName("Movie").
        WithNearText(nearText).
        WithLimit(2).
        WithFields(title, description, genre).
        Do(context.Background())

    if err != nil {
        panic(err)
    }

    // Inspect the results
    if result.Errors != nil {
        fmt.Printf("Error: %v\n", result.Errors)
        return
    }

    data := result.Data["Get"].(map[string]interface{})
    movies := data["Movie"].([]interface{})

    for _, movie := range movies {
        jsonData, err := json.MarshalIndent(movie, "", "  ")
        if err != nil {
            panic(err)
        }
        fmt.Println(string(jsonData))
    }
```

**Go (v6)**

```go
package main

import (
  "context"
  "fmt"
  "os"

  weaviate "github.com/weaviate/weaviate-go-client/v6"
  "github.com/weaviate/weaviate-go-client/v6/query"
)

func main() {
  ctx := context.Background()

  // Step 2.1: Connect to your Weaviate Cloud instance.
  client, err := weaviate.NewWeaviateCloud(
    ctx,
    os.Getenv("WEAVIATE_URL"),     // e.g. "my-cluster.weaviate.cloud"
    os.Getenv("WEAVIATE_API_KEY"), // an admin API key
  )
  if err != nil {
    // handle error
    panic(err)
  }
  defer client.Close()

  // Step 2.2: Semantic (vector) search. Weaviate Embeddings vectorizes the query
  // text server-side and returns the closest matches.
  movies := client.Collections.Use("Movie")
  response, err := movies.Query.NearText(ctx, query.NearText{
    Concepts: []string{"science fiction movie"},
    Limit:    2,
  })
  if err != nil {
    // handle error
    panic(err)
  }
  for _, obj := range response.Objects {
    fmt.Printf("%v\n", obj.Properties)
  }
}
```

**Java**

```java
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import com.fasterxml.jackson.databind.ObjectMapper; // For pretty-printing JSON

import java.util.Map;

public class QuickstartQueryNearText {
  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;

    try {
      // Best practice: store your credentials in environment variables
      String weaviateUrl = System.getenv("WEAVIATE_URL");
      String weaviateApiKey = System.getenv("WEAVIATE_API_KEY");

      // Step 2.1: Connect to your Weaviate Cloud instance
      client =
          WeaviateClient.connectToWeaviateCloud(weaviateUrl, weaviateApiKey);

      // Step 2.2: Perform a semantic search with NearText
      CollectionHandle<Map<String, Object>> movies =
          client.collections.use("Movie");
      ObjectMapper objectMapper = new ObjectMapper();

      var response = movies.query.nearText("sci-fi",
          q -> q.limit(2).returnProperties("title", "description", "genre"));

      // Inspect the results
      System.out.println("--- Query Results ---");
      for (var obj : response.objects()) {
        System.out.println(objectMapper.writerWithDefaultPrettyPrinter()
            .writeValueAsString(obj.properties()));
      }
    } finally {
      if (client != null) {
        client.close(); // Free up resources
      }
    }
  }
}
```

**C#**

```csharp
using System;
using System.Text.Json;
using System.Threading.Tasks;
using Weaviate.Client;
using Weaviate.Client.Models;

namespace WeaviateProject.Examples
{
    public class QuickstartQueryNearText
    {
public static async Task Run()
{
    // Best practice: store your credentials in environment variables
    string weaviateUrl = Environment.GetEnvironmentVariable("WEAVIATE_URL");
    string weaviateApiKey = Environment.GetEnvironmentVariable("WEAVIATE_API_KEY");

    // Step 2.1: Connect to your Weaviate Cloud instance
    var client = await Connect.Cloud(weaviateUrl, weaviateApiKey);

    // Step 2.2: Perform a semantic search with NearText
    var movies = client.Collections.Use("Movie");

    var response = await movies.Query.NearText(
        "sci-fi",
        limit: 2,
        returnProperties: ["title", "description", "genre"]
    );

    // Inspect the results
    Console.WriteLine("--- Query Results ---");
    foreach (var obj in response.Objects)
    {
        Console.WriteLine(
            JsonSerializer.Serialize(
                obj.Properties,
                new JsonSerializerOptions { WriteIndented = true }
            )
        );
    }
}
    }
}
```

#### Import vectors

Semantic search finds results based on meaning. This is called `nearVector` in Weaviate. The following example searches for 2 objects (*limit*) whose vector is most similar to the query vector.

**Python**

```py
import weaviate
import os, json

# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]

# Step 2.1: Connect to your Weaviate Cloud instance
with weaviate.connect_to_weaviate_cloud(
    cluster_url=weaviate_url,
    auth_credentials=weaviate_api_key,
) as client:

    # Step 2.2: Use this collection
    movies = client.collections.use("Movie")

    # Step 2.3: Perform a vector search with NearVector
    response = movies.query.near_vector(
        near_vector=[0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81], 
        limit=2
    )

    for obj in response.objects:
        print(json.dumps(obj.properties, indent=2))  # Inspect the results
```

**JavaScript/TypeScript**

```ts
import weaviate, { WeaviateClient, ApiKey } from '@weaviate/node';

// Best practice: store your credentials in environment variables
const weaviateUrl = process.env.WEAVIATE_URL!;
const weaviateApiKey = process.env.WEAVIATE_API_KEY!;

// Step 2.1: Connect to your Weaviate Cloud instance
const client: WeaviateClient = await weaviate.connectToWeaviateCloud(
  weaviateUrl,
  {
    authCredentials: new ApiKey(weaviateApiKey),
  }
);

// Step 2.2: Use this collection
const movies = client.collections.get('Movie');

// Step 2.3: Perform a vector search with NearVector
const response = await movies.query.nearVector(
  [0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81],
  {
    limit: 2,
  }
);

for (const obj of response.objects) {
  console.log(JSON.stringify(obj.properties, null, 2)); // Inspect the results
}

await client.close(); // Free up resources
```

**Go (v5)**

```go
```

**Java**

```java
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import com.fasterxml.jackson.databind.ObjectMapper; // For pretty-printing JSON

import java.util.Map;

public class QuickstartQueryNearVector {
  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;

    try {
      // Best practice: store your credentials in environment variables
      String weaviateUrl = System.getenv("WEAVIATE_URL");
      String weaviateApiKey = System.getenv("WEAVIATE_API_KEY");

      // Step 2.1: Connect to your Weaviate Cloud instance
      client =
          WeaviateClient.connectToWeaviateCloud(weaviateUrl, weaviateApiKey);

      // Step 2.2: Perform a vector search with NearVector
      CollectionHandle<Map<String, Object>> movies =
          client.collections.use("Movie");
      ObjectMapper objectMapper = new ObjectMapper();

      // Use primitive float[] for v6
      float[] queryVector =
          new float[] {0.11f, 0.21f, 0.31f, 0.41f, 0.51f, 0.61f, 0.71f, 0.81f};

      var response = movies.query.nearVector(queryVector,
          q -> q.limit(2).returnProperties("title", "description", "genre"));

      // Inspect the results
      System.out.println("--- Query Results ---");
      for (var obj : response.objects()) {
        System.out.println(objectMapper.writerWithDefaultPrettyPrinter()
            .writeValueAsString(obj.properties()));
      }
    } finally {
      if (client != null) {
        client.close(); // Free up resources
      }
    }
  }
}
```

**C#**

```csharp
using System;
using System.Text.Json;
using System.Threading.Tasks;
using Weaviate.Client;

namespace WeaviateProject.Examples
{
    public class QuickstartQueryNearVector
    {
public static async Task Run()
{
    // Best practice: store your credentials in environment variables
    string weaviateUrl = Environment.GetEnvironmentVariable("WEAVIATE_URL");
    string weaviateApiKey = Environment.GetEnvironmentVariable("WEAVIATE_API_KEY");

    // Step 2.1: Connect to your Weaviate Cloud instance
    var client = await Connect.Cloud(weaviateUrl, weaviateApiKey);

    // Step 2.2: Perform a vector search with NearVector
    var movies = client.Collections.Use("Movie");

    float[] queryVector = [0.11f, 0.21f, 0.31f, 0.41f, 0.51f, 0.61f, 0.71f, 0.81f];

    var response = await movies.Query.NearVector(
        queryVector,
        limit: 2,
        returnProperties: ["title", "description", "genre"]
    );

    // Inspect the results
    Console.WriteLine("--- Query Results ---");
    foreach (var obj in response.Objects)
    {
        Console.WriteLine(
            JsonSerializer.Serialize(
                obj.Properties,
                new JsonSerializerOptions { WriteIndented = true }
            )
        );
    }
}
    }
}
```

**Example response**

```json
{
  "genre": "Science Fiction",
  "title": "The Matrix",
  "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers."
}
{
  "genre": "Fantasy",
  "title": "The Lord of the Rings: The Fellowship of the Ring",
  "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth."
}
```

## Step 3: Retrieval augmented generation (RAG)

> [!NOTE]
>
> **Requirement: Claude API key**
>
> For Retrieval Augmented Generation (RAG) in this step, you will need a [Claude API key](https://console.anthropic.com/settings/keys). You can also use another generative [model provider](https://docs.weaviate.io/weaviate/model-providers) instead.

#### Vectorize objects during import

Retrieval augmented generation (RAG), also called generative search, works by prompting a large language model (LLM) with a combination of a *user query* and *data retrieved from a database*.

The following example combines the semantic search for the query `sci-fi` with a prompt to generate a tweet using the Anthropic generative model ([`generative-anthropic`](https://docs.weaviate.io/weaviate/model-providers/anthropic/generative)).

**Python**

```py
import os
import weaviate
from weaviate.classes.generate import GenerativeConfig

# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]
anthropic_api_key = os.environ["ANTHROPIC_API_KEY"]

# Step 2.1: Connect to your Weaviate Cloud instance
with weaviate.connect_to_weaviate_cloud(
    cluster_url=weaviate_url,
    auth_credentials=weaviate_api_key,
    headers={"X-Anthropic-Api-Key": anthropic_api_key},
) as client:

    # Step 2.2: Use this collection
    movies = client.collections.use("Movie")

    # Step 2.3: Perform RAG with on NearText results
    response = movies.generate.near_text(
        query="sci-fi",
        limit=1,
        grouped_task="Write a tweet with emojis about this movie.",
        generative_provider=GenerativeConfig.anthropic(
            model="claude-haiku-4-5"
        ),  # Configure the Anthropic generative integration for RAG
    )

    print(response.generative.text)  # Inspect the results
```

**JavaScript/TypeScript**

```ts
import weaviate, { WeaviateClient, ApiKey, generativeParameters } from '@weaviate/node';

// Best practice: store your credentials in environment variables
const weaviateUrl = process.env.WEAVIATE_URL!;
const weaviateApiKey = process.env.WEAVIATE_API_KEY!;
const anthropicApiKey = process.env.ANTHROPIC_API_KEY!;

// Step 2.1: Connect to your Weaviate Cloud instance
const client: WeaviateClient = await weaviate.connectToWeaviateCloud(
  weaviateUrl,
  {
    authCredentials: new ApiKey(weaviateApiKey),
    headers: { 'X-Anthropic-Api-Key': anthropicApiKey },
  }
);

// Step 2.2: Use this collection
const movies = client.collections.get('Movie');

// Step 2.3: Perform RAG with on NearText results
const response = await movies.generate.nearText(
  'sci-fi',
  {
    groupedTask: 'Write a tweet with emojis about this movie.',
    config: generativeParameters.anthropic({
      model: "claude-haiku-4-5",
    }),
  },
  {
    limit: 1,
  }
);

console.log(response.generative); // Inspect the results

await client.close(); // Free up resources
```

**Go (v5)**

```go
import (
    "context"
    "fmt"
    "os"

    "github.com/weaviate/weaviate-go-client/v5/weaviate"
    "github.com/weaviate/weaviate-go-client/v5/weaviate/auth"
    "github.com/weaviate/weaviate-go-client/v5/weaviate/graphql"
)

func main() {
    // Best practice: store your credentials in environment variables
    weaviateURL := os.Getenv("WEAVIATE_HOST")
    weaviateAPIKey := os.Getenv("WEAVIATE_API_KEY")
    anthropicAPIKey := os.Getenv("ANTHROPIC_API_KEY")

    // Step 2.1: Connect to your Weaviate Cloud instance
    headers := map[string]string{
        "X-Anthropic-Api-Key": anthropicAPIKey,
    }

    cfg := weaviate.Config{
        Host:       weaviateURL,
        Scheme:     "https",
        AuthConfig: auth.ApiKey{Value: weaviateAPIKey},
        Headers:    headers,
    }
    client, err := weaviate.NewClient(cfg)
    if err != nil {
        panic(err)
    }

    // Step 2.2: Perform RAG with NearText results
    title := graphql.Field{Name: "title"}
    description := graphql.Field{Name: "description"}
    genre := graphql.Field{Name: "genre"}

    nearText := client.GraphQL().NearTextArgBuilder().
        WithConcepts([]string{"sci-fi"})

    generate := graphql.NewGenerativeSearch().GroupedResult("Write a tweet with emojis about this movie.")

    result, err := client.GraphQL().Get().
        WithClassName("Movie").
        WithNearText(nearText).
        WithLimit(1).
        WithFields(title, description, genre).
        WithGenerativeSearch(generate).
        Do(context.Background())

    if err != nil {
        panic(err)
    }

    // Inspect the results
    if result.Errors != nil {
        fmt.Printf("Error: %v\n", result.Errors)
        return
    }

    fmt.Printf("%v", result)
```

**Go (v6)**

> [!NOTE]
>
> **Go client `v6`**
>
> Generative (RAG) queries are not yet available in the [`v6` Go client](https://docs.weaviate.io/weaviate/client-libraries/go).

```go
// Coming soon
```

**Java**

```java
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import io.weaviate.client6.v1.api.collections.generate.GenerativeProvider;
import java.util.Map;

public class QuickstartQueryNearTextRAG {
  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;

    try {
      // Best practice: store your credentials in environment variables
      String weaviateUrl = System.getenv("WEAVIATE_URL");
      String weaviateApiKey = System.getenv("WEAVIATE_API_KEY");
      String anthropicApiKey = System.getenv("ANTHROPIC_API_KEY");

      // Step 2.1: Connect to your Weaviate Cloud instance
      client = WeaviateClient.connectToWeaviateCloud(weaviateUrl,
          weaviateApiKey, config -> config
              .setHeaders(Map.of("X-Anthropic-Api-Key", anthropicApiKey)));

      // Step 2.2: Perform RAG with nearText results
      CollectionHandle<Map<String, Object>> movies =
          client.collections.use("Movie");

      var response = movies.generate.nearText("sci-fi",
          // Query configuration (nearText and limit)
          q -> q.limit(1).returnProperties("title", "description", "genre"),
          // Generative configuration (RAG task)
          g -> g.groupedTask("Write a tweet with emojis about this movie.",
              c -> c.generativeProvider(GenerativeProvider
                  .anthropic(o -> o.model("claude-haiku-4-5"))))); // The model to use

      // Inspect the results
      // Use .generative() to access the generative result
      System.out.println(response.generative().text());

    } finally {
      if (client != null) {
        client.close(); // Free up resources
      }
    }
  }
}
```

**C#**

```csharp
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using Weaviate.Client;
using Weaviate.Client.Models;
using Weaviate.Client.Models.Generative;

namespace WeaviateProject.Examples
{
    public class QuickstartQueryNearTextRAG
    {
public static async Task Run()
{
    // Best practice: store your credentials in environment variables
    string weaviateUrl = Environment.GetEnvironmentVariable("WEAVIATE_URL");
    string weaviateApiKey = Environment.GetEnvironmentVariable("WEAVIATE_API_KEY");
    string anthropicApiKey = Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY");

    // Step 3.1: Connect to your Weaviate Cloud instance
    var client = await Connect.Cloud(
        weaviateUrl,
        weaviateApiKey,
        headers: new Dictionary<string, string>
        {
            { "X-Anthropic-Api-Key", anthropicApiKey },
        }
    );

    // Step 3.2: Perform RAG with nearText results
    var movies = client.Collections.Use("Movie");

    var response = await movies.Generate.NearText(
        "sci-fi",
        limit: 1,
        returnProperties: ["title", "description", "genre"],
        groupedTask: new GroupedTask("Write a tweet with emojis about this movie."),
        provider: new Providers.Anthropic
        {
            Model = "claude-haiku-4-5", // The model to use
        }
    );

    // Inspect the results
    Console.WriteLine(JsonSerializer.Serialize(response.Generative.Values));
}
    }
}
```

#### Import vectors

Retrieval augmented generation (RAG), also called generative search, works by prompting a large language model (LLM) with a combination of a *user query* and *data retrieved from a database*.

The following example combines the vector similarity search with a prompt to generate a tweet using the Anthropic generative model ([`generative-anthropic`](https://docs.weaviate.io/weaviate/model-providers/anthropic/generative)).

**Python**

```py
import os
import weaviate
from weaviate.classes.generate import GenerativeConfig

# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]
anthropic_api_key = os.environ["ANTHROPIC_API_KEY"]

# Step 2.1: Connect to your Weaviate Cloud instance
with weaviate.connect_to_weaviate_cloud(
    cluster_url=weaviate_url,
    auth_credentials=weaviate_api_key,
    headers={"X-Anthropic-Api-Key": anthropic_api_key},
) as client:

    # Step 2.2: Use this collection
    movies = client.collections.use("Movie")

    # Step 2.3: Perform RAG with on NearVector results
    response = movies.generate.near_vector(
        near_vector=[0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81],
        limit=1,
        grouped_task="Write a tweet with emojis about this movie.",
        generative_provider=GenerativeConfig.anthropic(
            model="claude-haiku-4-5"
        ),  # Configure the Anthropic generative integration for RAG
    )

    print(response.generative.text)  # Inspect the results
```

**JavaScript/TypeScript**

```ts
import weaviate, { WeaviateClient, ApiKey, generativeParameters } from '@weaviate/node';

// Best practice: store your credentials in environment variables
const weaviateUrl = process.env.WEAVIATE_URL!;
const weaviateApiKey = process.env.WEAVIATE_API_KEY!;
const anthropicApiKey = process.env.ANTHROPIC_API_KEY!;

// Step 2.1: Connect to your Weaviate Cloud instance
const client: WeaviateClient = await weaviate.connectToWeaviateCloud(
  weaviateUrl,
  {
    authCredentials: new ApiKey(weaviateApiKey),
    headers: { 'X-Anthropic-Api-Key': anthropicApiKey },
  }
);

// Step 2.2: Use this collection
const movies = client.collections.get('Movie');

// Step 2.3: Perform RAG with on NearVector results
const response = await movies.generate.nearVector(
  [0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81],
  {
    groupedTask: 'Write a tweet with emojis about this movie.',
    config: generativeParameters.anthropic({
      model: "claude-haiku-4-5",
    }),
  },
  {
    limit: 1,
  }
);

console.log(response.generative); // Inspect the results

await client.close(); // Free up resources
```

**Go (v5)**

```go
```

**Java**

```java
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import io.weaviate.client6.v1.api.collections.generate.GenerativeProvider;
import java.util.Map;

public class QuickstartQueryNearVectorRAG {
  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;

    try {
      // Best practice: store your credentials in environment variables
      String weaviateUrl = System.getenv("WEAVIATE_URL");
      String weaviateApiKey = System.getenv("WEAVIATE_API_KEY");
      String anthropicApiKey = System.getenv("ANTHROPIC_API_KEY");

      // Step 2.1: Connect to your Weaviate Cloud instance
      client = WeaviateClient.connectToWeaviateCloud(weaviateUrl,
          weaviateApiKey, config -> config
              .setHeaders(Map.of("X-Anthropic-Api-Key", anthropicApiKey)));

      // Step 2.2: Perform RAG with NearVector results
      CollectionHandle<Map<String, Object>> movies =
          client.collections.use("Movie");

      // Use primitive float[] for v6
      float[] queryVector =
          new float[] {0.11f, 0.21f, 0.31f, 0.41f, 0.51f, 0.61f, 0.71f, 0.81f};

      var response = movies.generate.nearVector(queryVector,
          q -> q.limit(1).returnProperties("title", "description", "genre"),
          // Generative configuration (RAG task)
          g -> g.groupedTask("Write a tweet with emojis about this movie.",
              c -> c.generativeProvider(GenerativeProvider
                  .anthropic(o -> o.model("claude-haiku-4-5"))))); // The model to use

      // Inspect the results
      // Use .generative() to access the generative result
      System.out.println(response.generative().text());

    } finally {
      if (client != null) {
        client.close(); // Free up resources
      }
    }
  }
}
```

**C#**

```csharp
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using Weaviate.Client;
using Weaviate.Client.Models;
using Weaviate.Client.Models.Generative;

namespace WeaviateProject.Examples
{
    public class QuickstartQueryNearVectorRAG
    {
public static async Task Run()
{
    // Best practice: store your credentials in environment variables
    string weaviateUrl = Environment.GetEnvironmentVariable("WEAVIATE_URL");
    string weaviateApiKey = Environment.GetEnvironmentVariable("WEAVIATE_API_KEY");
    string anthropicApiKey = Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY");

    // Step 3.1: Connect to your Weaviate Cloud instance
    var client = await Connect.Cloud(
        weaviateUrl,
        weaviateApiKey,
        headers: new Dictionary<string, string>
        {
            { "X-Anthropic-Api-Key", anthropicApiKey },
        }
    );

    // Step 3.2: Perform RAG with NearVector results
    var movies = client.Collections.Use("Movie");

    float[] queryVector = [0.11f, 0.21f, 0.31f, 0.41f, 0.51f, 0.61f, 0.71f, 0.81f];

    var response = await movies.Generate.NearVector(
        vectors: queryVector,
        limit: 1,
        returnProperties: ["title", "description", "genre"],
        groupedTask: new GroupedTask("Write a tweet with emojis about this movie."),
        provider: new Providers.Anthropic
        {
            Model = "claude-haiku-4-5", // The model to use
        }
    );

    // Inspect the results
    Console.WriteLine(JsonSerializer.Serialize(response.Generative.Values));
}
    }
}
```

**Example response**

```json
🕶️ Unplug from the system & join Neo's journey 💊🐰

"The Matrix" will blow your mind 🤯 as reality unravels 🌀

Kung-fu, slow-mo & mind-bending sci-fi 🥋🕴️

Are you ready to see how deep the rabbit hole goes? 🔴🔵 #TheMatrix #WakeUp
```

## Step 4: Query Agent

The [Weaviate Query Agent](https://docs.weaviate.io/query-agent) is a pre-built agentic service designed to answer natural language queries based on the data stored in Weaviate Cloud. The user simply provides a prompt/question in natural language, and the Query Agent takes care of all intervening steps to provide an answer.

**Python**

```py
import os
import weaviate
from weaviate.agents.query import QueryAgent

# Best practice: store your credentials in environment variables
weaviate_url = os.environ["WEAVIATE_URL"]
weaviate_api_key = os.environ["WEAVIATE_API_KEY"]

# Step 2.1: Connect to your Weaviate Cloud instance
with weaviate.connect_to_weaviate_cloud(
    cluster_url=weaviate_url,
    auth_credentials=weaviate_api_key,
) as client:

    # Step 2.2: Instantiate a new agent object
    qa = QueryAgent(client=client, collections=["Movie"])

    # Step 2.3: Perform a query using Search Mode
    response = qa.search("Find a cool sci-fi movie.", limit=1)

    # Print the response
    for obj in response.search_results.objects:
        print(f"Movie: {obj.properties['title']} - {obj.properties['description']}")
```

**JavaScript/TypeScript**

```ts
import weaviate, { WeaviateClient, ApiKey } from '@weaviate/node';
import { QueryAgent } from '@weaviate/agents';

// Best practice: store your credentials in environment variables
const weaviateUrl = process.env.WEAVIATE_URL!;
const weaviateApiKey = process.env.WEAVIATE_API_KEY!;

// Step 2.1: Connect to your Weaviate Cloud instance
const client: WeaviateClient = await weaviate.connectToWeaviateCloud(
  weaviateUrl,
  {
    authCredentials: new ApiKey(weaviateApiKey),
  }
);

// Step 2.2: Use this collection
// Instantiate a new agent object
const queryAgent = new QueryAgent(
  client, {
  collections: ['Movie'],

});

// Perform a search using Search Mode (retrieval only, no answer generation)
const basicSearchResponse = await queryAgent.search("Find a cool sci-fi movie.", {
  limit: 1
})

// Access the search results
for (const obj of basicSearchResponse.searchResults.objects) {
  console.log(`Movie: ${obj.properties['title']} - ${obj.properties['description']}`)
}

await client.close(); // Free up resources
```

Here is the printed response:

```json
Movie: The Matrix - A computer hacker learns about the true nature of reality and his role in the war against its controllers.
```

## Next steps

We recommend you check out the following resources to continue learning about Weaviate.

[Quick tour of Weaviate](https://docs.weaviate.io/weaviate/tutorials/quick-tour-of-weaviate): Continue with the Quick tour tutorial – an end-to-end guide that covers important topics like configuring collections, searches, etc.

[Weaviate Academy](https://academy.weaviate.io/): Check out Weaviate Academy – a learning platform centered around AI-native development.

[How-to manuals](https://docs.weaviate.io/weaviate/guides): Quick examples of how to configure, manage and query Weaviate using client libraries.

[Starter guides](https://docs.weaviate.io/weaviate/starter-guides): Guides and tips for new users learning how to use Weaviate.

