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

# Curator Viewer

> Watch and share your datasets in the hosted Curator Viewer while Curator generates them.

The Curator Viewer is a hosted web page where you can look through your data. When it is on, Curator uploads each response as it arrives, so you can watch the dataset grow during a run.

## Turn on the viewer

Set the `CURATOR_VIEWER` environment variable before you run Curator.

<CodeGroup>
  ```bash Shell theme={null}
  export CURATOR_VIEWER=1
  ```

  ```python Python or Colab theme={null}
  import os

  os.environ["CURATOR_VIEWER"] = "1"
  ```
</CodeGroup>

Then run any Curator script. Curator prints a line like this next to the progress display.

```text theme={null}
Curator Viewer: Open Curator Viewer
https://curator.bespokelabs.ai/datasets/845c7dd33b8b4242a24ff048b5f94354
```

Each run gets its own link. You can also read the link from the `viewer_url` attribute of the `CuratorResponse`.

<Warning>
  If you do not set an API key, anyone with the link can see the dataset. Set a Bespoke Labs API key to keep your datasets private.
</Warning>

## Use a Bespoke Labs API key

When you set an API key, Curator links your datasets to your Bespoke Labs account. You can then do these things.

* Keep your datasets private.
* See all the datasets you have made.
* Share datasets with other people.
* See what your data generation cost over time.

<Steps>
  <Step title="Create an API key">
    Sign in to the [Bespoke Labs console](https://console.bespokelabs.ai/home/keys) and create a key.
  </Step>

  <Step title="Set the environment variables">
    ```bash theme={null}
    export BESPOKE_API_KEY=<your-api-key>
    export CURATOR_VIEWER=1
    ```

    Curator now streams every dataset to the viewer and links it to your account.
  </Step>

  <Step title="Find your datasets">
    The [Datasets](https://curator.bespokelabs.ai/home/datasets) page lists the datasets made with your keys and the ones others shared with you. The [Cost report](https://curator.bespokelabs.ai/home/costs) page shows what you spent on data generation over a period.
  </Step>
</Steps>

## Upload an existing dataset

Use `push_to_viewer` to upload a Hugging Face `Dataset` that you already have. You can also pass the ID of a dataset on the Hugging Face Hub. The function returns the viewer link, and it works without `CURATOR_VIEWER`.

```python theme={null}
from datasets import Dataset

from bespokelabs import curator

dataset = Dataset.from_list([{"question": "What is 2 + 2?", "answer": "4"}])
url = curator.push_to_viewer(dataset)
print(url)
```

## Download a dataset from the viewer

Use `load_dataset` with the dataset ID, which is the last part of the viewer link. It returns a Hugging Face `Dataset` and caches it in the Curator cache directory.

```python theme={null}
from bespokelabs import curator

dataset = curator.load_dataset("845c7dd33b8b4242a24ff048b5f94354")
```

Curator does not send your API key with this request, so use it for datasets that anyone with the link can open.

<Note>
  The local `curator-viewer` command is retired. Use the hosted viewer instead.
</Note>
