> For the complete documentation index, see [llms.txt](https://docs.wproofreader.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wproofreader.com/v6.13.0/api-reference/text-autocomplete-api.md).

# Text autocomplete API

`autocomplete` takes input text and returns possible completions.

**Command name:** `autocomplete`\
**Success status:** `200 OK`

### On this page

* [Common parameters](#common-parameters)
* [Parameters](#parameters)
* [Request examples](#request-examples)
* [Response schema](#response-schema)
* [Errors](#errors)

**Related**: [Overview](/v6.13.0/api-reference/overview.md), [Supported languages](/v6.13.0/features/supported-languages.md)

### Common parameters

`cmd` selects the command to run.

| Name  | Type   | Required | Description             |
| ----- | ------ | -------- | ----------------------- |
| `cmd` | string | Yes      | Must be `autocomplete`. |

These parameters work with any `cmd`.

| Name           | Type    | Required   | Description                                                        |
| -------------- | ------- | ---------- | ------------------------------------------------------------------ |
| `serviceid`    | string  | Cloud only | Cloud API key. Required for Cloud requests. Not used on-premises.  |
| `short_answer` | boolean | No         | JSON only. When `true`, shortens JSON keys to reduce payload size. |

See [Overview](/v6.13.0/api-reference/overview.md#common-parameters) for details.

### Parameters

These are parameters specific to `cmd=autocomplete`.

| Name   | Type   | Required | Description                                                                                                                       |
| ------ | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `text` | string | Yes      | Text to complete. The completion is returned as a suffix string. It can start with whitespace.                                    |
| `lang` | string | Yes      | Language code. Use a language where autocomplete is enabled. See [Supported languages](/v6.13.0/features/supported-languages.md). |

### Request examples

#### Example: completion found

Request:

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

```http
GET https://endpoint/api?cmd=autocomplete&lang=en_US&text=Welcome%20to
```

{% endtab %}

{% tab title="POST" %}

```http
POST https://endpoint/api
Content-Type: application/json

{
  "cmd": "autocomplete",
  "lang": "en_US",
  "text": "Welcome to"
}
```

{% endtab %}
{% endtabs %}

Response (`200 OK`):

{% tabs %}
{% tab title="JSON" %}
Use defaults: `format=json`, `short_answer=false`.

```json
{
  "result": {
    "suggestions": [
      " the"
    ]
  }
}
```

{% endtab %}

{% tab title="Short JSON" %}
Add `short_answer=true`.

```json
{
  "r": {
    "s": [
      " the"
    ]
  }
}
```

{% endtab %}
{% endtabs %}

#### Example: no suggestions

Request:

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

```http
GET https://endpoint/api?cmd=autocomplete&lang=en_US&text=Thank%20you
```

{% endtab %}

{% tab title="POST" %}

```http
POST https://endpoint/api
Content-Type: application/json

{
  "cmd": "autocomplete",
  "lang": "en_US",
  "text": "Thank you"
}
```

{% endtab %}
{% endtabs %}

Response (`200 OK`):

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

```json
{
  "result": {
    "suggestions": []
  }
}
```

{% endtab %}

{% tab title="Short JSON" %}

```json
{
  "r": {
    "s": []
  }
}
```

{% endtab %}
{% endtabs %}

### Response schema

The response is always an object with a single `result`.

#### JSON (`short_answer=false`)

```json
{
  "result": {
    "suggestions": [
      " the"
    ]
  }
}
```

* `result` (object)\
  Always present.
* `result.suggestions` (array of strings)\
  May be empty. Each item is a completion suffix to append to `text`.

#### Short JSON (`short_answer=true`)

Key mapping:

* `result` → `r`
* `suggestions` → `s`

### Errors

Errors use the shared error format from [Overview](/v6.13.0/api-reference/overview.md#errors).

#### Language code not found (`400 Bad Request`)

```json
{
  "error": true,
  "message": "Language code not found."
}
```

#### Language has no autocomplete support (`403 Forbidden`)

```json
{
  "error": true,
  "message": "Command 'autocomplete' for language 'es_ES' is not enabled or unsupported."
}
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wproofreader.com/v6.13.0/api-reference/text-autocomplete-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
