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

# Embedding the chat widget

> Add the Circuit chat widget to your website with a single script tag.

The Circuit chat widget is an embeddable chat interface that lets website visitors interact with your Circuit agent. It loads as a small button in the bottom-right corner of your page and expands into a full chat window.

## Quick setup

Add a single script tag to your website's HTML:

```html theme={null}
<script src="https://build.app.circuit.ai/chat-widget/circuit-chat-widget.iife.js?apiKey=YOUR_AGENT_KEY"></script>
```

Replace `YOUR_AGENT_KEY` with the API key from your agent's settings. The widget handles everything else.

## Getting an API key

<Steps>
  <Step title="Open agent settings">
    Navigate to the agent you want to embed and open its settings.
  </Step>

  <Step title="Create an API key">
    In the API keys section, create a new key. Give it a descriptive name (e.g., "Company Website Widget").
  </Step>

  <Step title="Set domain restrictions (recommended)">
    Restrict the API key to specific domains (e.g., `yourdomain.com`) so it can only be used from your website.
  </Step>

  <Step title="Copy the key">
    Copy the API key and add it to the script tag URL's `apiKey` parameter.
  </Step>
</Steps>

<Warning>
  API keys are visible in your page's HTML source. Always set domain restrictions to prevent unauthorized use. Without restrictions, anyone with the key can send requests to your agent.
</Warning>

## Integration example

A complete HTML page with the widget:

```html theme={null}
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Company</title>
</head>
<body>
  <h1>Welcome to My Company</h1>
  <p>Click the chat button in the bottom-right corner to ask a question.</p>

  <script src="https://build.app.circuit.ai/chat-widget/circuit-chat-widget.iife.js?apiKey=YOUR_AGENT_KEY"></script>
</body>
</html>
```

The widget loads asynchronously and does not block your page rendering.
