---
title: "Initialize the xmc package"
slug: "initialize-the-xmc-package"
abstract: "How to initialize the optional Marketplace SDK xmc package so your app can interact with SitecoreAI APIs."
---
# Initialize the xmc package

> [!note]
> **Before you begin**
> -   Complete the [SDK quick start](https://doc.sitecore.com/mp/en/developers/sdk/0/sitecore-marketplace-sdk/quick-start--manual-.html "Quick start (manual)"). In the quick start, you initialize the Marketplace SDK `client` package, which is required for every Marketplace app.

The Marketplace SDK `xmc` package is optional by default, but you must initialize it if your app needs to interact with SitecoreAI APIs.

To initialize the `xmc` package:

1. If you haven't installed the package yet, install it by running the following command in your terminal:

    ```bash
    npm install @sitecore-marketplace-sdk/xmc
    ```

2. In the `useMarketplaceClient.ts` hook, import `XMC` from the package:

    ```typescript
    import { XMC } from "@sitecore-marketplace-sdk/xmc";
    ```

3. In the same file, in the `getMarketplaceClient` function, in the `config` variable, add `XMC` to the list of modules, then save your changes:

    ```typescript
    const config = {
      target: window.parent,
      modules: [XMC], // add the module
    };
    ```

You can now start making queries and mutations that require access to SitecoreAI APIs, for example, [make GraphQL queries](https://doc.sitecore.com/mp/en/developers/sdk/0/sitecore-marketplace-sdk/make-a-graphql-query.html "Make a GraphQL query"). For a full list of operations, refer to the [reference documentation](https://doc.sitecore.com/mp/en/developers/sdk/0/sitecore-marketplace-sdk/sitecore-marketplace-sdk-reference.html "Sitecore Marketplace SDK reference").

> [!important]
> Requests to SitecoreAI APIs only work in the SitecoreAI environments where your app is [installed](https://doc.sitecore.com/mp/en/developers/marketplace/install-an-activated-custom-app.html).
>
> All requests to SitecoreAI APIs must contain the Context ID of your SitecoreAI environment, which you can retrieve from the [application context](https://doc.sitecore.com/mp/en/developers/sdk/0/sitecore-marketplace-sdk/query-the-application-context.html "Query the application context"). For code examples, see [Make a GraphQL query](https://doc.sitecore.com/mp/en/developers/sdk/0/sitecore-marketplace-sdk/make-a-graphql-query.html "Make a GraphQL query").