> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Set up the Wix AI SDK

## Article: Set up the Wix AI SDK

## Article Link: https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/set-up-the-wix-ai-sdk.md

## Article Content:

# Set up the Wix AI SDK

The Wix AI SDK lets you access AI models from [supported providers](https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/about-the-wix-ai-apis.md) via the [Vercel AI SDK](https://ai-sdk.dev/). Follow these steps to set it up:

## Step 1 | Install the packages

Install the Vercel `ai`, Wix `@wix/ai` and `zod` packages:

```bash
npm install @wix/ai
npm install ai@>=6.0.26
npm install zod@>=4.1.8
```

## Step 2 | Import an AI method

Import one or more [supported methods](https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/about-the-wix-ai-apis.md) from the Vercel AI package:

```js
import { <aiMethod> } from "ai";
```

Where `<aiMethod>` is the method you want to call. For example, this line imports `generateText()` from Vercel:

```js
import { generateText } from "ai";
```

## Step 3 | Set up a provider module

Import an AI provider from the Wix AI package. The import method depends on your [hosting environment](https://dev.wix.com/docs/sdk/articles/get-started/about-the-wix-java-script-sdk.md#uses):

::::tabs
:::Wix-managed
In a [Wix-managed environment](https://dev.wix.com/docs/sdk/articles/get-started/about-the-wix-java-script-sdk.md#uses), directly import the [provider module](https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/about-the-wix-ai-apis.md):

```js
import { <providerModule> } from "@wix/ai";
```

Where `<providerModule>` is the provider whose API and models you want to access. For example, this line imports `openai` from Wix:

```js
import { openai } from "@wix/ai";
```

You can directly import the following provider modules:

| Provider | Module name |
| -------- | ----------- |
| OpenAI   | `openai`    |
| Runware  | `runware`   |

:::
:::Self-managed
In a [self-managed environment](https://dev.wix.com/docs/sdk/articles/get-started/about-the-wix-java-script-sdk.md#uses):

1. Initialize a [Wix client](https://dev.wix.com/docs/sdk/core-modules/sdk/wix-client.md) with an [authorization strategy](https://dev.wix.com/docs/sdk/articles/set-up-a-client/about-the-wix-client.md#authorization-strategy-auth):

   ```js
   import { createClient, <authStrategy> } from "@wix/sdk";
   const wixClient = createClient({<authStrategy>});
   ```

2. Import a Wix utility method and call it to create an authenticated [provider module](https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/about-the-wix-ai-apis.md):

   ```js
   import { <createProviderModule> } from "@wix/ai";
   const <providerModule> = <createProviderModule>({ client: wixClient });
   ```

   Where:
   - `<createProviderModule()>` creates a provider module authenticated by the Wix client.
   - `<providerModule>` is the provider whose API and models you want to access.

   For example, this code snippet sets up and authenticates the `openai` provider module:

   ```js
   import { generateText } from "ai";
   import { createOpenAI } from "@wix/ai";
   import { createClient, AppStrategy } from "@wix/sdk";

   // Create a Wix client with a Wix app context:
   const wixClient = createClient({
     auth: AppStrategy({
       appId: "YOUR_APP_ID",
       appSecret: "YOUR_APP_SECRET",
       instanceId: "YOUR_INSTANCE_ID",
     }),
   });

   // Create an openai module with the authenticated client
   const openai = createOpenAI({ client: wixClient });
   ```

   You can create the following provider modules:

   | Provider | Module name | Create by calling |
   | -------- | ----------- | ----------------- |
   | OpenAI   | `openai`    | `createOpenAI()`  |
   | Runware  | `runware`   | `createRunware()` |

:::
::::

## Step 4 | Specify the provider API and model

Call the AI method and specify the [provider API and model](https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/about-the-wix-ai-apis.md):

```js
const result = await <aiMethod>({
  model: <providerModule>.<api>("<modelName>"),
  // Additional method parameters
});
```

Where:

- `<aiMethod>` is the Vercel AI method you want to call.
- `<providerModule>` is the provider whose API you want to access.
- `<api>` is the API that has the functionality you need.
- `<modelName>` is the specific model you want to interact with.

For example, this code snippet calls the `generateText()` method imported from Vercel, and configures it using the `openai` module imported from Wix:

```js
const { text } = await generateText({
  model: openai("gpt-5.2"),
  prompt: "Write a vegetarian lasagna recipe for 4 people.",
});
```

## Complete code example

This code uses [`generateText()`](https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-text) to call [OpenAI's Responses API](https://ai-sdk.dev/providers/ai-sdk-providers/openai#responses-models) to generate text:

::::tabs
:::Wix-managed

```js
// Import AI functionality from the Vercel SDK
import { generateText } from "ai";
// Import the provider module
import { openai } from "@wix/ai";

// Generate text by specifying the model name
const { text } = await generateText({
  model: openai("gpt-5.2"), // or openai.responses('gpt-5.2')
  prompt: "Write a vegetarian lasagna recipe for 4 people.",
});
```

:::
:::Self-managed

```js
// Import AI functionality from the Vercel SDK
import { generateText } from "ai";
// Import the method to create an authenticated provider module
import { createOpenAI } from "@wix/ai";
// Import Wix client methods
import { createClient, AppStrategy } from "@wix/sdk";

// Create a Wix client authenticated with an AppStrategy
const wixClient = createClient({
  auth: AppStrategy({
    appId: "YOUR_APP_ID",
    appSecret: "YOUR_APP_SECRET",
    instanceId: "YOUR_INSTANCE_ID",
  }),
});

// Create the openai provider module via the authenticated Wix client
const openai = createOpenAI({ client: wixClient });

// Generate text by specifying the model name
const { text } = await generateText({
  model: openai("gpt-5.2"), // or openai.responses('gpt-5.2')
  prompt: "Write a vegetarian lasagna recipe for 4 people.",
});
```

:::
::::

## See also

- [About the Wix AI APIs](https://dev.wix.com/docs/api-reference/articles/ai-tools/ai-apis/about-the-wix-ai-apis.md)
- [About AI credits on Wix](https://support.wix.com/en/article/about-ai-credits)
- [Vercel AI SDK Core](https://ai-sdk.dev/docs/ai-sdk-core/overview)