# Complete lsp

URL: https://docs.hanzo.ai/docs/openapi/lsp/post-lsp-complete

> Offers the candidates a language server has at a position, typed and resolved through the repository's dependencies rather than guessed from text.

`POST /v1/lsp/complete`

> [LSP →](https://docs.hanzo.ai/docs/openapi/lsp) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                        |
| ------------- | -------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/lsp/complete` |
| **Method**    | `POST`                                 |
| **Operation** | `post_lsp_complete`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY` |

Offers the candidates a language server has at a position, typed and
resolved through the repository's dependencies rather than guessed from text.

## Request

6 fields, body `application/json` (required).

| Field       | In   | Type            | Required | Description                                                                                                                     |
| ----------- | ---- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `character` | body | integer (int64) | —        | Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification — not a byte offset and not a rune index. |
| `line`      | body | integer (int64) | —        | Line is 0-based, per the LSP specification.                                                                                     |
| `path`      | body | string          | —        | Path is the repo-relative file, e.g. "apps/lsp/lsp.go".                                                                         |
| `relation`  | body | string          | —        | Relation refines locate: definition, reference, type or implementation.                                                         |
| `repo`      | body | string          | —        | Repo is the repository NAME within the caller's own org, e.g. "cloud".                                                          |
| `rev`       | body | string          | —        | Rev is a branch, tag or commit sha.                                                                                             |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `200`     | lsp.Answer      | ok      |
| `default` | problem-details | refused |

`200` body — 44 fields.

| Field                                 | In   | Type              | Always | Description                                                                                                                                                                                                                  |
| ------------------------------------- | ---- | ----------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `cold`                                | body | boolean           | —      | Cold reports that this request paid to PREPARE the revision — the tree write, the dependency fetch and the language server's first index.                                                                                    |
| `completions`                         | body | lsp.Completion\[] | —      | Completions is complete's answer: the candidates at the position, typed and resolved through the repository's dependencies rather than guessed from text.                                                                    |
| `completions[].detail`                | body | string            | —      | Detail is the server's short elaboration, typically the type or signature.                                                                                                                                                   |
| `completions[].kind`                  | body | integer (int64)   | —      | Kind is the LSP CompletionItemKind number (2 method, 3 function, 5 field, 6 variable, …), passed through as the protocol spells it.                                                                                          |
| `completions[].label`                 | body | string            | —      | Label is the text a client would insert, and what an editor lists.                                                                                                                                                           |
| `diagnostics`                         | body | lsp.Diagnostic\[] | —      | Diagnostics is diagnostics' answer: every problem the server finds in the whole file, position ignored.                                                                                                                      |
| `diagnostics[].code`                  | body | any               | —      | Code is the checker's own identifier for the rule, a string or a number depending on the server.                                                                                                                             |
| `diagnostics[].message`               | body | string            | —      | Message is the problem in the server's own words, meant to be shown.                                                                                                                                                         |
| `diagnostics[].range`                 | body | lsp.Range         | —      |                                                                                                                                                                                                                              |
| `diagnostics[].range.end`             | body | lsp.Position      | —      |                                                                                                                                                                                                                              |
| `diagnostics[].range.end.character`   | body | integer (int64)   | —      | Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification: not a byte offset and not a rune index.                                                                                               |
| `diagnostics[].range.end.line`        | body | integer (int64)   | —      | Line is 0-BASED, per the LSP specification — one less than the line an editor shows a human.                                                                                                                                 |
| `diagnostics[].range.start`           | body | lsp.Position      | —      |                                                                                                                                                                                                                              |
| `diagnostics[].range.start.character` | body | integer (int64)   | —      | Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification: not a byte offset and not a rune index.                                                                                               |
| `diagnostics[].range.start.line`      | body | integer (int64)   | —      | Line is 0-BASED, per the LSP specification — one less than the line an editor shows a human.                                                                                                                                 |
| `diagnostics[].severity`              | body | integer (int64)   | —      | Severity is the LSP's: 1 error, 2 warning, 3 information, 4 hint.                                                                                                                                                            |
| `diagnostics[].source`                | body | string            | —      | Source is which checker reported it ("compiler", "go vet", a linter's name), which is what separates a build error from a style opinion.                                                                                     |
| `hover`                               | body | string            | —      | Hover is hover's answer: the type and documentation as the language server itself renders them, so it is prose meant to be shown, not parsed.                                                                                |
| `lang`                                | body | string            | —      | Lang is the language the server that answered speaks ("go"), as the daemon reports it.                                                                                                                                       |
| `locations`                           | body | lsp.Location\[]   | —      | Locations is locate's answer: where the symbol is defined, referenced, typed or implemented, per the relation asked for.                                                                                                     |
| `locations[].external`                | body | boolean           | —      | External is true when the answer left the repository — the case a static index cannot answer, and the reason this service resolves through dependencies.                                                                     |
| `locations[].path`                    | body | string            | —      | Path is repo-relative while External is false, and the module coordinate ("golang.org/x/mod\@v0.14.0/semver/semver.go") once it is true.                                                                                     |
| `locations[].range`                   | body | lsp.Range         | —      |                                                                                                                                                                                                                              |
| `locations[].range.end`               | body | lsp.Position      | —      |                                                                                                                                                                                                                              |
| `locations[].range.end.character`     | body | integer (int64)   | —      | Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification: not a byte offset and not a rune index.                                                                                               |
| `locations[].range.end.line`          | body | integer (int64)   | —      | Line is 0-BASED, per the LSP specification — one less than the line an editor shows a human.                                                                                                                                 |
| `locations[].range.start`             | body | lsp.Position      | —      |                                                                                                                                                                                                                              |
| `locations[].range.start.character`   | body | integer (int64)   | —      | Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification: not a byte offset and not a rune index.                                                                                               |
| `locations[].range.start.line`        | body | integer (int64)   | —      | Line is 0-BASED, per the LSP specification — one less than the line an editor shows a human.                                                                                                                                 |
| `op`                                  | body | string            | —      | Op is the question that was asked: hover, locate, symbols, diagnostics or complete.                                                                                                                                          |
| `path`                                | body | string            | —      | Path is the repo-relative file the question was about, echoed back.                                                                                                                                                          |
| `repo`                                | body | string            | —      | Repo is the repository the question was about, echoed back.                                                                                                                                                                  |
| `rev`                                 | body | string            | —      | Rev is the RESOLVED commit sha, never the branch or tag that was asked for.                                                                                                                                                  |
| `symbols`                             | body | lsp.Symbol\[]     | —      | Symbols is symbols' answer: the file's whole outline, position ignored.                                                                                                                                                      |
| `symbols[].detail`                    | body | string            | —      | Detail is the server's short elaboration, typically the signature.                                                                                                                                                           |
| `symbols[].kind`                      | body | integer (int64)   | —      | Kind is the LSP SymbolKind number (5 class, 6 method, 12 function, 23 struct, …), passed through rather than translated to a word — these callers already speak LSP, and inventing a second vocabulary is how the two drift. |
| `symbols[].name`                      | body | string            | —      | Name is the declared identifier.                                                                                                                                                                                             |
| `symbols[].range`                     | body | lsp.Range         | —      |                                                                                                                                                                                                                              |
| `symbols[].range.end`                 | body | lsp.Position      | —      |                                                                                                                                                                                                                              |
| `symbols[].range.end.character`       | body | integer (int64)   | —      | Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification: not a byte offset and not a rune index.                                                                                               |
| `symbols[].range.end.line`            | body | integer (int64)   | —      | Line is 0-BASED, per the LSP specification — one less than the line an editor shows a human.                                                                                                                                 |
| `symbols[].range.start`               | body | lsp.Position      | —      |                                                                                                                                                                                                                              |
| `symbols[].range.start.character`     | body | integer (int64)   | —      | Character is a 0-based UTF-16 code-unit offset within Line, per the LSP specification: not a byte offset and not a rune index.                                                                                               |
| `symbols[].range.start.line`          | body | integer (int64)   | —      | Line is 0-BASED, per the LSP specification — one less than the line an editor shows a human.                                                                                                                                 |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo lsp complete
```

**SDK**

**.ts**

```ts
import { Configuration, LspApi } from 'hanzoai';

const api = new LspApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postLspComplete({ character: 0, line: 0 });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import LspApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = LspApi(client).post_lsp_complete(character=0, line=0)
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.LspAPI.PostLspComplete(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, lsp_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = lsp_api::post_lsp_complete(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.LspApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new LspApi(client).postLspComplete();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/lsp/complete \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "character": 0,
       "line": 0
     }'
```

**MCP**

MCP declares no tool for **lsp** — `tools/list` on `https://api.hanzo.ai/v1/mcp` names the products it does reach. Use HTTP or an SDK.

---

[LSP API](https://docs.hanzo.ai/docs/openapi/lsp) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
