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

# JavaScript SDK

> Integrate Vizlook's powerful APIs natively via Vizlook JavaScript SDK (@vizlook/sdk) in your apps.

## GitHub

[https://github.com/Vizlook/vizlook-js-sdk](https://github.com/Vizlook/vizlook-js-sdk)

## Install

```Bash Bash theme={null}
npm install @vizlook/sdk
```

## Examples

<Card horizontal="true" arrow="true" title="Get Your Vizlook API Key" icon="key" href="https://www.vizlook.com/dashboard/api-keys">Sign up and receive \$10 free credit.</Card>

If not asign `apiKey`, the SDK will get API key from environment variable `VIZLOOK_API_KEY` by default.

### Search

```JavaScript JavaScript theme={null}
import Vizlook from "@vizlook/sdk";

const vizlook = new Vizlook({
  apiKey: process.env.VIZLOOK_API_KEY,
});

const response = await vizlook.search("how to be productive", {
  startPublishedDate: "2025-08-19T15:01:36.000Z",
  endPublishedDate: Date.now(),
  maxResults: 5,
  includeTranscription: true,
  includeSummary: true,
});

console.log("response:", response);
```

### Answer

Answer in non-stream mode.

```JavaScript JavaScript theme={null}
import Vizlook from "@vizlook/sdk";

const vizlook = new Vizlook({
  apiKey: process.env.VIZLOOK_API_KEY,
});

const response = await vizlook.answer("how to be productive", {
  includeTranscription: true,
});

console.log("Answer:", response.answer);
console.log("Citations:", response.citations);
```

Answer in stream mode.

```JavaScript JavaScript theme={null}
import Vizlook from "@vizlook/sdk";

const vizlook = new Vizlook({
  apiKey: process.env.VIZLOOK_API_KEY,
});

const streamResponse = vizlook.streamAnswer("how to be productive");
let answer = "";

for await (const chunk of streamResponse) {
  switch (chunk.type) {
    case "answer-chunk":
      answer += chunk.data;
      console.log("Answer chunk:", chunk.data);
      break;
    case "data-citations":
      console.log("Citations:", chunk.data.citations);
      break;
    case "data-cost":
      console.log("Cost:", chunk.data.dollarCost);
      break;
    case "error":
      console.log("Error:", chunk.data.errorText);
      break;
  }
}

console.log("Final answer:", answer);
```

### Get video contents

```JavaScript JavaScript theme={null}
import Vizlook from "@vizlook/sdk";

const vizlook = new Vizlook({
  apiKey: process.env.VIZLOOK_API_KEY,
});

const response = await vizlook.getVideoContents(
  ["https://www.youtube.com/watch?v=QdBokRd2ahw"],
  {
    crawlMode: "Fallback",
    includeTranscription: true,
    includeSummary: true,
  }
);

console.log("response:", response);
```
