# Test a connection: a free account check, or one model turn.

> OpenCode's free models pass the account check when a machine runs OpenCode and lists at least one free model; a machine's OpenCode sign-in, when that machine reports OpenCode signed in.
> https://koi.dog/docs/api/provider-connections/start-provider-test/

`POST /api/v1/provider-connections/{id}/tests` · Scope: `config`

Neither check spends anything; until a machine says so the stage is `deferred`. A turn on someone's own OpenCode sign-in is theirs alone to ask for (`403 not_allowed`), and runs only on its machine. The timeline records the key ID, action and outcome.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The provider connection's id. |

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | `string` | no | Retry the same request with the same key. [Retry rules](https://koi.dog/docs/api/#retries). |

## Body.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `stage` | `enum` | yes | `account` checks the credential with its provider for free (the model list, Boat's account, GitHub's `/user`); a machine or plan sign-in answers it `deferred`. `turn` also runs one paid model turn of `pick` on a machine that can run it. |
| `pick` | `object` | no | One role's explicit choice: which named connection, which harness, which model, which options. |
| `pick.connectionId` | `string` | yes | The connection this role's agents use, by id (`GET /connections`). Named every time: the server never picks one. At least 5 characters. |
| `pick.harness` | `enum` | yes | The coding agent program that runs the model. A machine runs it only when that harness is installed there. One of `claude-code`, `pi`, `codex`, `opencode`. |
| `pick.model` | `string` | yes | The model this role's agents use, as the connection's provider names it. 1 to 200 characters. |
| `pick.options` | `object` | no | The model's options for this role. Default `{}`. |
| `pick.options.effort` | `enum` | no | How much reasoning the model spends, where its harness lets you choose. Left out, the harness's default. One of `low`, `medium`, `high`, `xhigh`, `max`. |
| `nodeId` | `string` | no | The machine to run the turn on. An offline machine makes the turn `deferred`; a cloud worker is never started for a test. At least 5 characters. |

## Response.

202 Accepted · JSON object. Follow progress on the timeline.

- **422 validation_failed**: Each schema error appears in `details`.

## Request.

```sh
curl -X POST "https://api.koi.dog/api/v1/provider-connections/$ID/tests" \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Content-Type: application/json" \
    -d '{
      "stage": "account"
    }'
```

```js
const res = await fetch(`https://api.koi.dog/api/v1/provider-connections/${process.env.ID}/tests`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    stage: "account",
  }),
});
console.log(await res.json());
```

```python
import os
import uuid

import requests

r = requests.post(
    f"https://api.koi.dog/api/v1/provider-connections/{os.environ['ID']}/tests",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "stage": "account",
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "id": "string",
  "connectionId": "string",
  "generation": 0,
  "stages": [],
  "finishedAt": "string"
}
```
