> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corti.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# How it works

> Learn how to make basic and advanced requests for code prediction

Use the following request to send a clinical context, get structured medical codes back -- ready for clinician review:

```
POST https://api.$environment.corti.app/v2/tools/coding/
```

## Basic Usage

<Steps>
  <Step title="Choose one or more coding systems">
    Set `system` to an array of one or more system identifiers. Systems are typically combined by encounter type — for example, `icd10cm-outpatient` + `cpt` for office visits and ED encounters, or `icd10cm-inpatient` + `icd10pcs` for hospital admissions. See [Coding Systems](/coding/coding-systems) for the full list.
  </Step>

  <Step title="Pass your clinical context">
    The `context` field is an array of context objects. Two input types are supported:

    * **Text** — `type: "text"` with the clinical text in `text`. Pass multiple objects to provide multiple context sources.
    * **Document** — `type: "documentId"` with a document ID in `documentId`, referencing a document already stored in Corti.
  </Step>

  <Step title="Read the response">
    `codes` contains the medical entities the model predicts should be coded. `candidates` contains entities that are clinically relevant but not strictly required — optional codes surfaced for human review. `usageInfo.creditsConsumed` reports the credits used for the request, which is reflected in your account billing.
  </Step>
</Steps>

***

## Advanced Usage

<Steps>
  <Step title="Filter the prediction set">
    Use the optional `filter` field to restrict which codes the model may predict. It accepts an object with three properties:

    * **`include`** — codes or categories to include. An empty list (the default) means all codes in the system are eligible.
    * **`exclude`** — codes or categories to subtract from the include set. An empty list (the default) means nothing is excluded.
    * **`expand`** — when `true` (the default), category codes are expanded to their assignable leaf codes. When `false`, codes are passed through as-is.

    Processing follows include → exclude → result semantics: the final prediction set is the include set minus the exclude set.

    ```json theme={null}
    "filter": {
      "include": ["J18"],
      "exclude": ["J189"],
      "expand": true
    }
    ```
  </Step>
</Steps>

<Tip>
  Omit the `filter` field for open-ended prediction — the API will predict across the full coding system.
</Tip>

<Note>Please [contact us](https://help.corti.app) if you need help configuring your requests or have questions about advanced usage.</Note>
