UI2 Docs
Quick Start

Setting Up UI2

Set up everything you need to use UI2

Let's start by installing UI2, available on NPM or your favorite package manager.

npm i ui2-sdk

For this guide, we can use either TypeScript or JavaScript. Howevever, UI2 is built from the ground up for TS, so feel free to try it out!

You'll also need a few other dependencies through this guide:

npm i @ai-sdk/cerebras zod

Now, simply import createUI2, and call it for now. This is how we'll be building our UI2 app today.

import { createUI2 } from "ui2-sdk";
 
let { identifyIntent } = createUI2({});

We'll discuss the identifyIntent more later. However, for now, just know this is how you'll be actually identifying intent from text.

Next, in the configuration object, we need to put a model. These are available through the Vercel AI SDK.

It is highly recommended that you use the Cerebras models for their speed. Learn how to set it up on the Vercel AI SDK Website.

Structured Output

UI2 uses Structured Output to guarentee that your Intent parameter schemas are satisfied. Your model has to support this feature. llama-3.3-70b from Cerebras works great.

After you have your model set up, it should look something like this:

import { createUI2 } from "ui2-sdk";
import { createCerebras } from "@ai-sdk/cerebras";
 
const cerebras = createCerebras({
	apiKey: "API_KEY",
});
 
let { identifyIntent } = createUI2({
	model: cerebras("llama-3.3-70b"),
});

In order to run your app, you can either compile it if you're using TypeScript, or simply run it with Node.js if you're using JS:

node yourCode.js

Now, let's move on to creating some intents!