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

# Models

> Connect model providers and choose models.

See [Models](https://docs.usecadence.gg/bots/models.md) for what each option means.

## models/list and models/credentials

`models/list` returns every model you can use. `models/credentials` returns your connected providers, without their keys. Neither takes input.

## models/connect

`POST /rpc/models/connect` connects a provider with an API key or a server address.

**provider** `string` *required*

The provider id.

**credentialId** `string | null` *required*

An existing connection to update, or null to add a new one.

**apiKey** `string`

The key.

**baseUrl** `string`

For an OpenAI-compatible server.

**label** `string`

A name for this connection.

**modelId** `string`

The model to use.

**makeDefault** `boolean` (default: true)

Make this the main model.

> [!WARNING]
>
> Send keys only over HTTPS, and never log request bodies that contain them.

## Subscription sign-in

Signing in with a Claude or ChatGPT subscription takes several calls:

1. `models/beginOAuth` with the `provider` and `credentialId: null`. Set `codePage: true` when you cannot receive a redirect; the provider then shows a code. Returns a `loginId` and where to send the person.
2. If the provider showed a code, `models/submitOAuthCode` with the `loginId` and `code`.
3. Poll `models/completeOAuth` with the `loginId` until `status` is `ready` (or `error`).
4. `models/finishOAuth` with the `loginId` saves the connection.

`models/cancelOAuth` abandons a sign-in.

## Choosing models

| Procedure | Input | Effect |
| - | - | - |
| `models/setDefault` | `{ provider, modelId, thinkingLevel? }` | Sets the main model. |
| `models/role` | `{ role }` | Reads the `main` or `approval` role. |
| `models/setRole` | `{ role, ... }` | Sets a role's model. |
| `models/backups`, `models/setBackups` | | Reads or sets fallback models. |
| `models/rename` | `{ credentialId, label }` | Renames a connection. |
| `models/disconnect` | `{ provider, credentialId }` | Removes a connection. |

To give one bot its own model, use [`bots/update`](https://docs.usecadence.gg/api/reference/bots#bots%2Fupdate) with `modelProvider` and `modelId`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.