> For the complete documentation index, see [llms.txt](https://developers.chathive.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.chathive.app/sdk/ai-form.md).

# AI form

## Installation

The AI form is already included with the Oniroco SDK. If you haven't installed it into your application, first follow the [SDK installation guide](/sdk/getting-started.md).

## Setup <a href="#installation" id="installation"></a>

To setup the AI form, call the constructor to initialise your AI form. There are many options you can pass to the constructor. See the [configuration documentation](/sdk/ai-form/configuration.md) for more details.&#x20;

```typescript
const aiForm = new Chathive.AIForm({ apiKey: "YOUR_API_KEY" });
```

{% hint style="info" %}
**Good to know:** For single-page apps, ensure this is executed after the SDK has fully loaded.
{% endhint %}

After initializing your AI form, you can embed it into your application. Ensure this is done after the `selector` element has rendered. The `selector` is a required parameter and uses `document.querySelector` to locate the HTML tag where you want to embed the form.

{% code overflow="wrap" %}

```typescript
aiForm.embed({ selector: "#embed" })
    .then(() => console.log("AI form is embedded"));
```

{% endcode %}
