---
title: "Connect to your own AI service"
slug: "connect-to-your-own-ai-service"
abstract: "How to create a connector to use your own AI service to bring your customized tags into Content Hub image tagging."
---
# Connect to your own AI service

> [!important]
> AI capabilities in Content Hub need to be enabled and, if necessary, configured by a *superuser* or a user with the necessary permissions granted to them through [user group policies](https://doc.sitecore.com/ch/en/users/content-hub/user-group-policies.html "User group policies"). Most AI capabilities require Sitecore Stream.

You can use your own AI service or a third-party AI service to generate metadata, including image tags and image alt text. Using AI to add [image metadata](https://doc.sitecore.com/ch/en/users/content-hub/add-image-metadata-using-ai.html "Add image metadata using AI") reduces the manual effort required to tag images and improves the overall efficiency of your workflows. It ensures image tags are consistent and relevant for you and lets you tailor content discovery to your own specific workflows and requirements.

This walkthrough describes how to:

:::walkthrough
1. [Create a connector](https://doc.sitecore.com/ch/en/users/content-hub/connect-to-your-own-ai-service.html#create-a-connector)
2. [Create an AI processing input script and result script](https://doc.sitecore.com/ch/en/users/content-hub/connect-to-your-own-ai-service.html#create-an-ai-processing-input-script-and-result-script)
:::

After you create the connector and AI processing scripts, you [create an AI profile](https://doc.sitecore.com/ch/en/users/content-hub/create-an-ai-profile.html "Create an AI profile"). For AI-assisted metadata enrichment to be available on the details page, you need to add the [**Enrich with AI** operation](https://doc.sitecore.com/ch/en/users/content-hub/add-the-enrich-with-ai-operation-to-your-page.html "Add the Enrich with AI operation to your page") to the details page.

> [!note]
> When you use your own AI service, all data received complies with Sitecore security and privacy standards.

## Create a connector

To link your AI service to the Sitecore Content Hub metadata enrichment feature, you need to create a connector. When you create an AI profile, you select the connector you want to use.

To create a connector:

1. On the menu bar, click **Manage** :mdiCogOutline:.
2. On the **Manage** page, click **Connectors**. The **Connectors** tile is only visible after you [enable metadata enrichment](https://doc.sitecore.com/ch/en/users/content-hub/enable-ai-assisted-metadata-enrichment.html "Enable AI-assisted metadata enrichment").
3. On the **Connectors** page, click :mdiPlus: **Connector**.
4. In the **Create** dialog, in the **Name** field, enter a name for the connector. The name you define cannot be changed after the connector is created.
5. In the **Type** drop-down list, select the type of authorization required for the connector:
    - To use an API key, specify the endpoint (for example, `https://image-tags.app/api/v1/tags`), the header, and a value for the key.
    - To use the [OAuth authentication framework](https://datatracker.ietf.org/doc/html/rfc6749), specify the endpoint (for example, `https://image-tags.app/api/v1/tags`), the authority, the audience, the client ID, and the client secret.
6. Click **Save**.

## Create an AI processing input script and result script

To use your AI service with Content Hub, update the [scripts](https://doc.sitecore.com/ch/en/developers/cloud-dev/work-with-scripts.html) provided to convert the data from your AI service to the format required by Content Hub. When you create an AI profile, you select the AI input script and the AI result script that you want to use.

There are several default scripts provided for the **Metadata enrichment** feature.

- *Default AI input*
- *Default AI results*

Modify these scripts to ensure your code reflects the format that your AI service requires and outputs. When creating the AI input processing script, ensure you define the payload and headers as follows:

```

Context.Payload = JToken.Parse("{}");
Context.Headers = new Dictionary<string, string>();

```

The following headers are not supported in `Context.Headers`:

- `Content-Length`
- `Content-Type`
- `Transfer-Encoding`
- `Connection`
- `Host`
- `Expect`
- `Date`
- `Range`
- `If-Modified-Since`
- `If-Unmodified-Since`
- `TE`
- `Trailer`
- `Upgrade`
- All Content-\* headers (for example, `Content-Disposition`, `Content-Encoding`)

> [!tip]
> Comments are provided in the scripts to help you better understand what needs to be updated.

To create an AI input script and an AI result script:

1. On the menu bar, click **Manage** :mdiCogOutline:.
2. On the **Manage** page, click **Scripts**.
3. On the **Scripts** page, click :mdiPlus: **Script**.
4. In the **Script** dialog, in the **Name** field, enter a name.
5. In the **Type** drop-down list, click **Default AI input** or **Default AI result**.
6. Optionally, enter additional details about the script, and click **Save**.
7. On the **Scripts** page, click the script you just created to open its details page.
8. Click **Edit** and copy over the code from the **Tag with AI** script.
9. Update your code accordingly.
10. Click **Save changes**.
11. Click **Close**.