---
title: "Weaviate Cloud"
description: "Connect to Weaviate Cloud instances with code examples in Python, TypeScript, Go, Java, and C#."
url: https://docs.weaviate.io/weaviate/connections/connect-cloud
---

# Weaviate Cloud

Follow these steps to connect to a [Weaviate Cloud (WCD)](https://docs.weaviate.io/go/console?utm_content=howto/) instance.

## Retrieve your API key and REST endpoint

Open the [Weaviate Cloud console](https://docs.weaviate.io/go/console?utm_content=howto/) and follow the steps below:

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



## Connection example

To connect, use the `REST Endpoint` and the `Admin` API key stored as [environment variables](https://docs.weaviate.io/weaviate/connections/connect-cloud#environment-variables):

**Python**

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

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

# Connect to Weaviate Cloud
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**

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

// Set these environment variables
// WEAVIATE_URL      your WCD instance URL
// WEAVIATE_API_KEY  your WCD instance API key

const weaviateURL = process.env.WEAVIATE_URL as string
const weaviateKey = process.env.WEAVIATE_API_KEY as string

const client: WeaviateClient = await weaviate.connectToWeaviateCloud(weaviateURL, {
    authCredentials: new weaviate.ApiKey(weaviateKey),
  }
)
```

**Go (v5)**

```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"
)

// Create the client
func CreateClient() {
    cfg := weaviate.Config{
        Host:       os.Getenv("WEAVIATE_HOSTNAME"),
        Scheme:     "https",
        AuthConfig: auth.ApiKey{Value: os.Getenv("WEAVIATE_API_KEY")},
        Headers:    nil,
    }

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

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

}

func main() {
    CreateClient()
}
```

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

**Go (v6)**

```go
client, err := weaviate.NewWeaviateCloud(
  ctx,
  os.Getenv("WEAVIATE_URL"),
  os.Getenv("WEAVIATE_API_KEY"),
)
if err != nil {
  // handle error
  panic(err)
}
defer client.Close()

ready, err := client.IsReady(ctx)
if err != nil {
  // handle error
  panic(err)
}
fmt.Println(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, // Replace with your Weaviate Cloud URL
    weaviateApiKey // Replace with your Weaviate Cloud key
);

var isReady = await client.IsReady();
Console.WriteLine(isReady);
```

**Shell**

```shell
# Set these environment variables
# WEAVIATE_URL      your Weaviate instance URL
# WEAVIATE_API_KEY  your Weaviate instance API key

curl https://${WEAVIATE_URL}/v1/meta -H "Authorization: Bearer ${WEAVIATE_API_KEY}" | jq
```

## Third party API keys

If you use API-based models for vectorization or RAG, you must provide an API key for the service. To add third party API keys, follow these examples:

**Python**

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

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

# Connect to Weaviate Cloud
client = weaviate.connect_to_weaviate_cloud(
    cluster_url=weaviate_url,
    auth_credentials=Auth.api_key(weaviate_api_key),
    headers={
        "X-Cohere-Api-Key": cohere_api_key
    }
)

print(client.is_ready())
```

**JavaScript/TypeScript**

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

// Set these environment variables
// WEAVIATE_URL      your Weaviate instance URL
// WEAVIATE_API_KEY  your Weaviate instance API key
// COHERE_API_KEY    your Cohere API key

const weaviateURL = process.env.WEAVIATE_URL as string
const weaviateKey = process.env.WEAVIATE_API_KEY as string
const cohereKey = process.env.COHERE_API_KEY as string

const client: WeaviateClient = await weaviate.connectToWeaviateCloud(weaviateURL, {
  authCredentials: new weaviate.ApiKey(weaviateKey),
    headers: {
     'X-Cohere-Api-Key': cohereKey,
   }
  }
)
```

**Go (v5)**

```go
// Set these environment variables
// WEAVIATE_URL      your Weaviate instance URL
// WEAVIATE_API_KEY  your Weaviate instance API key
// COHERE_API_KEY    your Cohere 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"
)

// Create the client
func CreateClient() {
cfg := weaviate.Config{
    Host: os.Getenv("WEAVIATE_HOSTNAME"),   // URL only, no scheme prefix
    Scheme: "https",
    AuthConfig: auth.ApiKey{Value: os.Getenv("WEAVIATE_API_KEY")},
    Headers: map[string]string{
        "X-Cohere-Api-Key": os.Getenv("WEAVIATE_COHERE_KEY"),
    },
}

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

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

func main() {
    CreateClient()
}
```

**Go (v6)**

```go
client, err := weaviate.NewWeaviateCloud(
  ctx,
  os.Getenv("WEAVIATE_URL"),
  os.Getenv("WEAVIATE_API_KEY"),
  weaviate.WithHeader(http.Header{
    "X-Cohere-Api-Key": []string{os.Getenv("COHERE_API_KEY")},
  }),
)
if err != nil {
  // handle error
  panic(err)
}
defer client.Close()

ready, err := client.IsReady(ctx)
if err != nil {
  // handle error
  panic(err)
}
fmt.Println(ready)
```

**Java**

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

WeaviateClient client = WeaviateClient.connectToWeaviateCloud(weaviateUrl, // Replace with your Weaviate Cloud URL
    weaviateApiKey, // Replace with your Weaviate Cloud key
    config -> config.setHeaders(Map.of("X-Cohere-Api-Key", cohereApiKey)));

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");
string cohereApiKey = Environment.GetEnvironmentVariable("COHERE_API_KEY");

WeaviateClient client = await Connect.Cloud(
    weaviateUrl, // Replace with your Weaviate Cloud URL
    weaviateApiKey, // Replace with your Weaviate Cloud key
    new Dictionary<string, string> { { "X-Cohere-Api-Key", cohereApiKey } }
);

var isReady = await client.IsReady();
Console.WriteLine(isReady);
```

**Shell**

```shell
# Set these environment variables
# WEAVIATE_URL      your Weaviate instance URL
# WEAVIATE_API_KEY  your Weaviate instance API key
# COHERE_API_KEY    your Cohere API key

curl https://${WEAVIATE_URL}/v1/meta \
-H 'Content-Type: application/json' \
-H "X-Cohere-Api-Key: ${COHERE_API_KEY}" \
-H "Authorization: Bearer ${WEAVIATE_API_KEY}" | jq
```

## Environment variables

> [!WARNING]
>
> Do not hard-code API keys or other credentials in your client code. Use environment variables or a similar secure coding technique instead.

Environment variables keep sensitive details out of your source code. Your application imports the information to runtime.

**Set an environment variable.**

In these examples, the environment variable names are in UPPER\_CASE.

**Bash**

```bash
export WEAVIATE_URL="http://localhost:8080"
export WEAVIATE_API_KEY="sAmPleKEY8FwELJILn0YDRG9gjy4hReqfInz"
```

**Windows PowerShell**

```shell
$Env:WEAVIATE_URL="http://localhost:8080"
$Env:WEAVIATE_API_KEY="sAmPleKEY8FwELJILn0YDRG9gjy4hReqfInz"
```

**Windows Command Prompt**

```shell
set WEAVIATE_URL=http://localhost:8080
set WEAVIATE_API_KEY=sAmPleKEY8FwELJILn0YDRG9gjy4hReqfInz
```

**Import an environment variable.**

**Python**

```python
weaviate_url = os.getenv("WEAVIATE_URL")
weaviate_key = os.getenv("WEAVIATE_API_KEY")
```

**JavaScript/TypeScript**

```js
const weaviateUrl = process.env.WEAVIATE_URL;
const weaviateKey = process.env.WEAVIATE_API_KEY;
```

**Go (v5)**

```go
weaviateUrl := os.Getenv("WEAVIATE_URL")
weaviateKey := os.Getenv("WEAVIATE_API_KEY")
```

## gRPC timeouts

The Python client v4 and TypeScript client v3 use [gRPC](https://docs.weaviate.io/weaviate/api/grpc). The gRPC protocol is sensitive to network delay. If you encounter connection timeouts, adjust the timeout values for initialization, queries, and insertions.

**Python**

```py
import weaviate, os
from weaviate.classes.init import Auth
from weaviate.classes.init import AdditionalConfig, Timeout

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

# Connect to a WCD instance
client = weaviate.connect_to_weaviate_cloud(
    cluster_url=weaviate_url,
    auth_credentials=Auth.api_key(weaviate_api_key),
    # skip_init_checks=True,
    additional_config=AdditionalConfig(
        timeout=Timeout(init=30, query=60, insert=120)  # Values in seconds
    )
)

print(client.is_ready())
```

**JavaScript/TypeScript**

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

// Set these environment variables
// WEAVIATE_URL       your Weaviate instance URL
// WEAVIATE_API_KEY   your Weaviate instance API key

const weaviateURL = process.env.WEAVIATE_URL as string
const weaviateKey = process.env.WEAVIATE_API_KEY as string

const client: WeaviateClient = await weaviate.connectToWeaviateCloud(weaviateURL, {
  authCredentials: new weaviate.ApiKey(weaviateKey),
    timeout: { init: 30, query: 60, insert: 120 } // Values in seconds
  }
)

console.log(client)
```

**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
    config -> config.timeout(30, 60, 120)); // Values in seconds

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,
    initTimeout: TimeSpan.FromSeconds(30),
    queryTimeout: TimeSpan.FromSeconds(60),
    insertTimeout: TimeSpan.FromSeconds(120)
);

var isReady = await client.IsReady();
Console.WriteLine(isReady);
```
