# Quick start

This guide takes you through your first calls to CKEditor AI with curl. You edit a sample HTML document, then connect an MCP server so the agent can fact-check the same document against Microsoft Learn.

To set up the editor with the AI features, start with the [CKEditor 5 AI documentation](../../../../ckeditor5/latest/features/ai/ckeditor-ai-overview.md). That page has a live demo you can try before writing any code.

> **Note**
>
> **Prerequisites**
>
> * **An active subscription or trial.** Sign up for the [CKEditor Premium Features 14-day free trial](https://portal.ckeditor.com/checkout?plan=free), pick a [self-service plan](https://ckeditor.com/pricing/), or [contact us](https://ckeditor.com/contact/) for a custom plan. CKEditor AI is an add-on to selected tiers.
> * **A Cloud environment.** Log in to the [Customer Portal](https://portal.ckeditor.com/) and open **Cloud environments**. If the list is empty, create one by following [Environments management](../../developer-resources/environments/environments-management.md#creating-a-new-environment).
> * **A development token.** Open your environment, scroll to the bottom of the configuration section, and copy the **development token URL**. It looks like `https://17717-dev.cke-cs.com/token/dev/XXXXXXXX` and requires no code on your side. Use it for this walkthrough only: it gives anyone with the URL unrestricted access to the environment, and it stops working 30 days after first use. [Authentication](authentication.md) covers what to use in production.
> * **Your API host.** For the US region, use `https://ai.cke-cs.com`. For the EU region, use `https://ai.cke-cs-eu.com`. The host must match the region of your environment. To find your environment’s region, see [Environments management](../../developer-resources/environments/environments-management.md#cloud-region).

<a id="prepare-the-sample-document">

## Prepare the sample document

Create a file called `document.html` and paste this into it. It is a typical document created in CKEditor 5, and it carries three things this guide uses:

* Markup that generic model calls tend to break: a table with attributes, a nested list, and CSS classes.
* Spelling and grammar errors in the first paragraph, which the first request corrects.
* Three false claims about Microsoft 365 retention in the last list, which the second request corrects against Microsoft Learn.

```html
<h2 data-id="e1">Quarterly product update</h2>
<p data-id="e2">we shiped the new dashbord to all customers this quater. it should of been out sooner but we hit some bugs in the rollout.</p>
<table data-id="e3" class="metrics-table">
	<thead>
		<tr><th>Metric</th><th>Q2</th><th>Q3</th></tr>
	</thead>
	<tbody>
		<tr><td>Active teams</td><td>1,204</td><td>1,688</td></tr>
		<tr><td>Uptime</td><td>99.95%</td><td>99.97%</td></tr>
	</tbody>
</table>
<ul data-id="e4">
	<li>Faster exports
		<ul><li>PDF and Word</li></ul>
	</li>
	<li class="highlight">New review workflow</li>
</ul>
<p data-id="e5"><em>Numbers above are unaudited.</em></p>
<p data-id="e6">We also shipped the new documentation for recovering deleted files and mail process in Microsoft 365 products:</p>
<ul data-id="e7">
	<li data-id="e8">
		Recovering deleted files and mail
		<ul data-id="e9">
			<li data-id="e10">Files deleted from SharePoint or OneDrive sit in the first-stage recycle bin for 93 days, then move to the second-stage bin for a further 93 days. We can therefore always recover a document within six months of its deletion.</li>
			<li data-id="e11">Deleted mail is recoverable for 30 days. This is a platform limit and cannot be adjusted per mailbox</li>
			<li data-id="e12">If a user edits a file that is under a retention policy, the version that existed when the policy was applied is lost.</li>
		</ul>
	</li>
</ul>
```

<a id="make-your-first-document-edit">

## Make your first document edit

Fetch a token, then post the document with the instruction to apply. The `model` field is required, and `agent-1` lets the service pick the model for you:

```bash
# Get a development token from your environment in the Customer Portal.
TOKEN=$(curl -s "<your-development-token-url>")

# The US region host. For the EU region, use https://ai.cke-cs-eu.com
HOST="https://ai.cke-cs.com"

jq -n --rawfile doc document.html '{
	content: [ { type: "document", content: $doc } ],
	prompt: "Fix the grammar and spelling only in the introduction part.",
	model: "agent-1"
}' | curl -s "$HOST/v1/documents/process" \
	-H "Authorization: Bearer $TOKEN" \
	-H "Content-Type: application/json" \
	-d @- \
	> response.json
```

If you do not have `jq` installed, pass the body inline. JSON-escape the document HTML: write quotes as `\"`, newlines as `\n`, and tabs as `\t`:

```bash
curl -s "$HOST/v1/documents/process" \
	-H "Authorization: Bearer $TOKEN" \
	-H "Content-Type: application/json" \
	-d '{
		"content": [ { "type": "document", "content": "<h2 data-id=\"e1\">Quarterly product update</h2>\n<p data-id=\"e2\">we shiped the new dashbord to all customers this quater. it should of been out sooner but we hit some bugs in the rollout.</p>\n<table data-id=\"e3\" class=\"metrics-table\">\n\t<thead>\n\t\t<tr><th>Metric</th><th>Q2</th><th>Q3</th></tr>\n\t</thead>\n\t<tbody>\n\t\t<tr><td>Active teams</td><td>1,204</td><td>1,688</td></tr>\n\t\t<tr><td>Uptime</td><td>99.95%</td><td>99.97%</td></tr>\n\t</tbody>\n</table>\n<ul data-id=\"e4\">\n\t<li>Faster exports\n\t\t<ul><li>PDF and Word</li></ul>\n\t</li>\n\t<li class=\"highlight\">New review workflow</li>\n</ul>\n<p data-id=\"e5\"><em>Numbers above are unaudited.</em></p>\n<p data-id=\"e6\">We also shipped the new documentation for recovering deleted files and mail process in Microsoft 365 products:</p>\n<ul data-id=\"e7\">\n\t<li data-id=\"e8\">\n\t\tRecovering deleted files and mail\n\t\t<ul data-id=\"e9\">\n\t\t\t<li data-id=\"e10\">Files deleted from SharePoint or OneDrive sit in the first-stage recycle bin for 93 days, then move to the second-stage bin for a further 93 days. We can therefore always recover a document within six months of its deletion.</li>\n\t\t\t<li data-id=\"e11\">Deleted mail is recoverable for 30 days. This is a platform limit and cannot be adjusted per mailbox</li>\n\t\t\t<li data-id=\"e12\">If a user edits a file that is under a retention policy, the version that existed when the policy was applied is lost.</li>\n\t\t</ul>\n\t</li>\n</ul>" } ],
		"prompt": "Fix the grammar and spelling only in the introduction part.",
		"model": "agent-1"
	}' \
	> response.json
```

Read the response:

```json
{
	"documents": [
		{
			"document":"<h2 data-id=\"e1\">Quarterly product update</h2>\n<p data-id=\"e2\">We shipped the new dashboard to all customers this quarter. It should have been out sooner, but we hit some bugs in the rollout.</p>\n<table data-id=\"e3\" class=\"metrics-table\">\n\t<thead>\n\t\t<tr><th>Metric</th><th>Q2</th><th>Q3</th></tr>\n\t</thead>\n\t<tbody>\n\t\t<tr><td>Active teams</td><td>1,204</td><td>1,688</td></tr>\n\t\t<tr><td>Uptime</td><td>99.95%</td><td>99.97%</td></tr>\n\t</tbody>\n</table>\n<ul data-id=\"e4\">\n\t<li>Faster exports\n\t\t<ul><li>PDF and Word</li></ul>\n\t</li>\n\t<li class=\"highlight\">New review workflow</li>\n</ul>\n<p data-id=\"e5\"><em>Numbers above are unaudited.</em></p>\n<p data-id=\"e6\">We also shipped the new documentation for recovering deleted files and mail process in Microsoft 365 products:</p>\n<ul data-id=\"e7\">\n\t<li data-id=\"e8\">\n\t\tRecovering deleted files and mail\n\t\t<ul data-id=\"e9\">\n\t\t\t<li data-id=\"e10\">Files deleted from SharePoint or OneDrive sit in the first-stage recycle bin for 93 days, then move to the second-stage bin for a further 93 days. We can therefore always recover a document within six months of its deletion.</li>\n\t\t\t<li data-id=\"e11\">Deleted mail is recoverable for 30 days. This is a platform limit and cannot be adjusted per mailbox</li>\n\t\t\t<li data-id=\"e12\">If a user edits a file that is under a retention policy, the version that existed when the policy was applied is lost.</li>\n\t\t</ul>\n\t</li>\n</ul>",
			"summary":"Corrected grammar, spelling, capitalization, and punctuation in the introductory paragraph only."
		}
	]
}
```

The response contains the edited document and a summary of the changes.

The edited element:

```html
<h2 data-id="e1">Quarterly product update</h2>
<p data-id="e2">We shipped the new dashboard to all customers this quarter. It should have been out sooner, but we hit some bugs in the rollout.</p>
<!-- Rest of the document, unchanged -->
```

Only the introduction changed. The service preserves the rest of the document, including attributes and CSS classes, unless the prompt asks to change them. The result is valid HTML you can load into the editor with no further processing.

> **Note**
>
> Language models are non-deterministic, so the wording differs between runs. The service returns editor-ready HTML every time.

<a id="connect-an-mcp-server">

## Connect an MCP server

An MCP (Model Context Protocol) server gives the agent tools and knowledge the model alone does not have. The service has an admin API for registering MCP servers and managing their tools.

The example below uses the public [Microsoft Learn](https://learn.microsoft.com/) MCP server, `https://learn.microsoft.com/api/mcp`. You do not have to set up a server of your own. Give the server a name that is unique within the environment:

```bash
curl -s -X POST "$HOST/v1/admin/mcp-servers" \
	-H "Authorization: Bearer $TOKEN" \
	-H "Content-Type: application/json" \
	-d '{
		"name": "microsoft-learn",
		"url": "https://learn.microsoft.com/api/mcp"
	}'
```

Response:

```json
{
	"name": "microsoft-learn"
}
```

If your server needs authentication or extra headers, see [MCP tools](extensions/mcp-tools.md).

Send the sample document again, with a prompt that tells the agent to check its figures against the official Microsoft 365 documentation. This request also sets `responseFormat` to `arf`, so the response carries only the elements the agent changed instead of the whole document. [Fragment responses](fragment-responses.md) explains the format:

```bash
jq -n --rawfile doc document.html '{
	content: [ { type: "document", content: $doc } ],
	prompt: "Verify every retention figure and claim in this document against the official Microsoft 365 documentation, and correct the ones that are wrong.",
	model: "agent-1",
	responseFormat: "arf"
}' | curl -s "$HOST/v1/documents/process" \
	-H "Authorization: Bearer $TOKEN" \
	-H "Content-Type: application/json" \
	-d @- \
	> response-kb.json
```

Read the response:

```json
{
	"documents":[
		{
			"document":"<!-- existing document -->\n<ul data-id=\"e7\">\n\t<li data-id=\"e8\">\n\t\tRecovering deleted files and mail\n\t\t<ul data-id=\"e9\">\n\t\t\t<li data-id=\"e10\">For SharePoint and OneDrive for work or school, deleted items are retained in the recycle bins for a combined total of 93 days from the original deletion date; moving an item to the second-stage recycle bin does not restart that period. Recovery is not guaranteed for six months, and items can be permanently deleted sooner.</li>\n\t\t\t<li data-id=\"e11\">In Exchange Online, items removed from the Deleted Items folder are retained in Recoverable Items for 14 days by default. An administrator can increase this deleted-item retention period to a maximum of 30 days, including for an individual mailbox. Retention policies or holds can preserve content longer.</li>\n\t\t\t<li data-id=\"e12\">When a user edits or deletes content subject to a Microsoft Purview retention policy, SharePoint and OneDrive preserve a copy in the Preservation Hold library. For retained documents, version retention depends on the applicable retention settings; editing a file does not simply discard the version that existed when retention applied.</li>\n\t\t</ul>\n\t</li>\n</ul>\n",
			"summary":"Corrected the three Microsoft 365 retention claims: SharePoint/OneDrive recycle-bin retention, Exchange Online deleted-item retention, and retained file-version behavior. The revised text now reflects Microsoft's documented policies."
		}
	]
}
```

The agent queried the Microsoft Learn server and corrected the three wrong claims. The `<!-- existing document -->` comment stands for the content left untouched.

<a id="try-it-on-your-document">

## Try it on your document

Run the same request on any HTML your product stores. Swap in your own file and your own prompt:

```bash
jq -n --rawfile doc your-own.html '{
	content: [ { type: "document", content: $doc } ],
	prompt: "Translate to German. Keep all markup exactly as it is.",
	model: "agent-1"
}' | curl -s "$HOST/v1/documents/process" \
	-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d @-
```

<a id="next-steps">

## Next steps

* **[Authentication](authentication.md)** covers production setup: your own token endpoint, signed tokens, and permission profiles.
* **[Document Processing](document-processing.md)** covers the full endpoint: several documents in one call, editing part of a document, contexts, and streaming.
* **[Fragment responses](fragment-responses.md)** explains what a fragment contains and how to apply one to your copy of the document.
* **[MCP tools](extensions/mcp-tools.md)** covers listing servers, updating credentials, disabling individual tools, and removing a server.
* **[Choose an extension](extensions/overview.md)** covers everything else you can give the agent: contexts, skills, MCP servers, hooks, and model providers.

---

Full index of the Cloud Services documentation: [llms.txt](../../../llms.txt)
