# Test LLM Provider Connectivity

`POST /api/agents/models/test`

### Overview
Sends a lightweight probe completion to the model provider to verify that API keys, network routes, and quota allocations are functioning.

### Authentication & Headers
- **Auth**: Bearer Token (L1 / L2)
- **Required Header**: `API-Version: 1`

### Parameters & Request Body Fields
- **`provider`** *(string, required)*: Provider identifier (`openai`, `anthropic`, `gemini`).
- **`model_name`** *(string, required)*: Physical upstream model string (`gpt-4o-mini`).
- **`api_key`** *(string, required)*: Secret API credential key to test.

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string \| null | no |  |
| `provider` | string | yes |  |
| `model_id` | string | yes |  |
| `api_key_id` | string \| null | no |  |
| `api_key` | string \| null | no |  |
| `base_url` | string \| null | no |  |
| `default_parameters` | object | no |  |

```json
{
  "id": "string",
  "provider": "string",
  "model_id": "string",
  "api_key_id": "string",
  "api_key": "string",
  "base_url": "string",
  "default_parameters": {}
}
```

## Responses

### 200 — Provider test passed

### 400 — Bad Request - The request parameters or headers are invalid (e.g. unsupported API-Version).

### 401 — Unauthorized - Missing, invalid, or expired JWT Bearer token.

### 403 — Forbidden - Insufficient role permissions or resource access denied by RBAC policy.

### 404 — Not Found - The requested resource ID was not found.

### 422 — Validation Error

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | object[] | no |  |
| `detail[].loc` | string | integer[] | yes |  |
| `detail[].msg` | string | yes |  |
| `detail[].type` | string | yes |  |
| `detail[].input` | object | no |  |
| `detail[].ctx` | object | no |  |

```json
{
  "detail": [
    {
      "loc": [
        null
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}
```

## Example

```bash
curl -X POST "$PINTER_URL/api/agents/models/test" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"id":"string","provider":"string","model_id":"string","api_key_id":"string","api_key":"string","base_url":"string","default_parameters":{}}'
```
