> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/plugins-and-integrations/convai-pixel-streaming-embed/on-premise-deployment.md).

# Configure an on-premise deployment

Point the Pixel Streaming Embed package at your own session service and stream servers instead of Convai's, for on-premise and self-hosted deployments.

Route the embed's session request and its stream to services you host, with the `serviceUrls` option. Use this page when an experience runs on your own Pixel Streaming servers. At the end, the embed requests its session from your service and loads the stream from your servers.

### Prerequisites

* An embed that already works against Convai. See [Embed an experience in a React TypeScript app](/api-docs/plugins-and-integrations/convai-pixel-streaming-embed/react-typescript.md) or [Embed an experience with a script tag](/api-docs/plugins-and-integrations/convai-pixel-streaming-embed/cdn-umd-script.md).
* A session service and a stream server that implement the requests described on this page.

### How the embed reaches its services

The embed makes two requests. `serviceUrls` replaces the base URL of each one:

| Key               | Default                  | Request the embed makes                                                                                            |
| ----------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------ |
| `sessionFetch`    | `https://api.convai.com` | `POST <sessionFetch>/xp/streams/viewPublishedExperience` to create a session                                       |
| `pixelStreamBase` | Convai's stream servers  | Loads the stream page for the session in the iframe, by default from `https://x.convai.com/stream-v2/<sessionId>/` |

`sessionFetch` is a base URL: the embed appends `/xp/streams/viewPublishedExperience` to it.

### Set the service URLs

{% tabs %}
{% tab title="React" %}

```tsx
<PixelStreamComponent
  expId="YOUR_EXPERIENCE_ID"
  serviceUrls={{
    sessionFetch: 'https://sessions.example.com',
    pixelStreamBase: 'https://stream.example.com',
  }}
/>
```

{% endtab %}

{% tab title="JavaScript" %}

```js
const experience = new PixelStreamCore.PixelStreamClient({
  container: document.getElementById('experience'),
  expId: 'YOUR_EXPERIENCE_ID',
  serviceUrls: {
    sessionFetch: 'https://sessions.example.com',
    pixelStreamBase: 'https://stream.example.com/stream-v2/',
  },
});
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
The React component and the framework-free client build the stream URL differently. `PixelStreamComponent` loads `<pixelStreamBase>/stream-v2/<sessionId>/`. `PixelStreamClient` loads `<pixelStreamBase><sessionId>/`, with no separator, so end its `pixelStreamBase` with the path to the session, including the trailing `/`.
{% endhint %}

### Implement the session service

The embed sends a JSON body to the session service:

```json
{
  "experience_id": "YOUR_EXPERIENCE_ID",
  "allocate_server": false,
  "end_user_id": "user-123"
}
```

`end_user_id` is present only when the embed has an `endUserId`. When the embed has an `authToken`, the request carries it in the `API-AUTH-TOKEN` header.

The embed reads the response this way:

| Response                                                       | Result                                      |
| -------------------------------------------------------------- | ------------------------------------------- |
| Status `200` with `{ "session": { "session_id": "<id>" } }`    | The embed loads the stream page for `<id>`. |
| Status `200` with `{ "status": "retry", "message": "<text>" }` | The embed shows its error screen.           |
| Any other status, with `{ "ERROR": "<text>" }`                 | The embed shows its error screen.           |

After the stream page loads, the embed posts it a JSON string, `{"type":"SESSION_ID","sessionId":"<id>"}`, and, when `endUserId` is set, an `END_USER_ID` message carrying `end_user_id` and `end_user_metadata`.

### Verify the deployment

Load the page and open the browser's network panel.

{% hint style="success" %}
The session request goes to your `sessionFetch` URL, and the iframe loads from your `pixelStreamBase` URL.
{% endhint %}

### Next steps

{% content-ref url="/pages/MWe8NjQDMtLGGeNG14mq" %}
[Pixel Streaming Embed API reference](/api-docs/plugins-and-integrations/convai-pixel-streaming-embed/api-reference.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.convai.com/api-docs/plugins-and-integrations/convai-pixel-streaming-embed/on-premise-deployment.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
