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. 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 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:

After you create the connector and AI processing scripts, you 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 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 .

  2. On the Manage page, click Connectors. The Connectors tile is only visible after you enable metadata enrichment.

  3. On the Connectors page, click 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, 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 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:

RequestResponse
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 .

  2. On the Manage page, click Scripts.

  3. On the Scripts page, click 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.

Do you have some feedback for us?

If you have suggestions for improving this article,