- REST API (recommended) — Submit prompts, poll for status, and retrieve results using Omni’s AI Jobs API. This gives you full control over the request lifecycle and is the easiest path to integrate into most backend architectures.
- MCP Server — Connect an MCP-compatible agent to Omni’s MCP endpoint. This is a good fit if your agent framework already supports the Model Context Protocol. Managing the user authentication can be trickier.
userId parameter, which is required for embed to ensure queries run with the correct user’s permissions.
Prerequisites
- An Omni API key with organization-level access
- Embed users provisioned in your Omni instance
- A model ID for the model your chat agent will query against
- For MCP: the MCP server AI setting enabled for your organization
Get the embed user ID
Each embed user in Omni has a unique user ID. Your chat agent needs this ID to run queries with that user’s permissions. The List embed users endpoint depends on the embed user already existing in Omni. By default, embed users are created when they first authenticate into an iframe — but your chat agent may need to look up a user before they’ve ever loaded an iframe. To avoid this dependency, use the 2-step SSO login flow to pre-create embed users. Thegenerate-session endpoint upserts the embed user, creating them if they don’t already exist:
id for each embed user. You’ll pass this value as the userId query parameter (REST API) or the X-MCP-User-ID header (MCP Server).
Option 1: REST API (recommended)
The AI Jobs API lets you submit a natural language prompt, poll for completion, and retrieve the full result, all through standard HTTP requests. This is the recommended approach because it integrates into any backend without requiring MCP client support.How it works
- Create a job — Submit a prompt with
modelIdand the embed user’suserId - Poll for status — Check the job status every 2–5 seconds until it reaches a terminal state, or configure a webhook to be notified on completion
- Stream results — Retrieve the full result, including any queries the AI ran and the final answer
Step 1: Create an AI job
Use the Create AI job endpoint. Pass the embed user’s ID as theuserId query parameter so the job runs with that user’s permissions:
jobId and conversationId:
conversationId in subsequent requests:
Optional parameters
| Parameter | Description |
|---|---|
topicName | Scope query generation to a specific topic. If omitted, the AI selects the best topic automatically. |
branchId | Query against an in-progress model branch instead of the shared model. |
conversationId | Continue an existing conversation thread. |
webhookUrl | Receive a POST notification when the job completes instead of polling. |
Step 2: Poll for job status
Use the Get AI job status endpoint to check progress. Poll every 2–5 seconds until the job reaches a terminal state (COMPLETE, FAILED, or CANCELLED):
resultSummary:
The
resultSummary is a short markdown summary. For the full result including query details and data, use the Stream AI job results endpoint in the next step.Step 3: Stream the full result
Once the job is complete, use the Stream AI job results endpoint to retrieve the full response, including all queries the AI ran and the final answer:message field contains the AI’s final answer in markdown, which you can render directly in your chat interface. The actions array provides the underlying query details if you want to show the data behind the answer.
Cancel a job
If a user cancels a request in your chat interface, use the Cancel AI job endpoint to stop the job:Using webhooks instead of polling
Instead of polling for status, you can pass awebhookUrl when creating the job. Omni will send a POST request to your URL when the job reaches a terminal state:
Example: end-to-end integration
Here’s a simplified example of how to wire this together in a backend service:Option 2: MCP Server
If your agent framework supports the Model Context Protocol, you can connect it directly to Omni’s MCP endpoint. The MCP Server exposes tools that let your agent pick models, select topics, and query data through natural language.Configure the MCP Server
Point your chat agent’s MCP client at your Omni instance. Set theX-MCP-User-ID header to the embed user’s ID so that all queries run with that user’s permissions:
MCP configuration
Header reference
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Your Omni API key, prefixed with Bearer |
X-MCP-User-ID | Yes | The embed user’s Omni user ID. Queries run with this user’s permissions. |
X-MCP-User-Required | Yes | Set to true to enforce that a user ID is provided for every query |
X-MCP-Model-ID | No | Scope the MCP Server to a specific model |
X-MCP-Topic-Name | No | Scope the MCP Server to a specific topic |
Dynamic user ID assignment
In a production embed setup, retrieve the embed user ID at the start of each session rather than hardcoding it:- A user starts a chat session in your embedded application
- Your application identifies the user (from a session token or external ID)
- Your backend calls the List embed users endpoint to resolve the user’s Omni user ID
- Your backend passes the user ID in the
X-MCP-User-IDheader when connecting to the MCP Server
User permissions in embed
Both integration paths enforce the embed user’s Omni permissions on every query. This includes:- Access grants — Users only see data they’re authorized to access
- Row-level security — Query results are filtered to the user’s allowed rows
- Topic-level restrictions — Users can only query topics they have access to
userId you provide.