> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cyborg.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Client

`Client` is the entry point of the CyborgDB Go SDK. It connects to a running CyborgDB service and creates, loads, and lists encrypted indexes. Operations on an index, such as upsert and query, are methods of the `*EncryptedIndex` it returns. Every method that calls the service takes a `context.Context` first.

## Constructor

```go theme={null}
func NewClient(baseURL, apiKey string, verifySSL ...bool) (*Client, error)
```

### Parameters

| Parameter | Type | Default | Description |
| - | - | - | - |
| `baseURL` | `string` | - | Base URL of the CyborgDB service, e.g. `"http://localhost:8000"`. Must use `http` or `https` and have a host. |
| `apiKey` | `string` | - | Service authentication credential, sent as the `X-API-Key` header. Pass `""` when the service runs without authentication. |
| `verifySSL` | `...bool` | auto-detect | *(Optional)* TLS certificate verification. Only the first value is used. See [TLS verification](#tls-verification). |

<Note>`apiKey` is the service **authentication** credential: the root key or a per-user `cdbk_` token. It is required only when the service runs with `CYBORGDB_SERVICE_ROOT_KEY` set; against an unauthenticated service (the default), pass `""`. This is distinct from the service's `CYBORGDB_API_KEY` license key. See [Managing Keys](../../guides/advanced/managing-keys).</Note>

`NewClient` returns a `*ValidationError` wrapping `ErrInvalidURL` if `baseURL` has no `http`/`https` scheme or no host, e.g. `"localhost:8000"`.

A path in `baseURL` is kept as a prefix, so `https://example.com/cyborgdb` sends requests to `https://example.com/cyborgdb/v1/...`.

### Example Usage

```go theme={null}
package main

import (
    "context"
    "fmt"
    "log"

    "github.com/cyborginc/cyborgdb-go"
)

func main() {
    client, err := cyborgdb.NewClient("http://localhost:8000", "your-api-key")
    if err != nil {
        log.Fatal(err)
    }

    health, err := client.GetHealth(context.Background())
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(health["status"])
    // Output: healthy
}
```

## TLS verification

`verifySSL` decides whether the SDK checks the service's TLS certificate:

| `baseURL` | `verifySSL` omitted | `true` | `false` |
| - | - | - | - |
| `http://…` | No TLS | No TLS | No TLS |
| `https://` with host `localhost`, `127.0.0.1`, or `::1` | Verification **off** | Verification on | Verification off |
| Any other `https://` URL | Verification on | Verification on | Verification off |

## Errors and timeouts

Failed requests return errors that wrap a typed error chosen by HTTP status, such as `*NotFoundError` for `404`; arguments the SDK rejects before sending return a `*ValidationError`. See [Errors](../errors).

Bound each call with a context deadline:

```go theme={null}
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

indexes, err := client.ListIndexes(ctx)
if err != nil {
    log.Fatal(err)
}
fmt.Println(indexes)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.