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

# Model Pricing

> Configure per-model token pricing for cost calculation.

Pikarc uses model pricing entries to calculate `cost_usd` for each step. When a step is updated with token counts, the cost is calculated as:

```
cost_usd = prompt_tokens × input_cost_per_token + completion_tokens × output_cost_per_token
```

If no pricing entry exists for a model, `cost_usd` remains null for that step.

## List Model Pricing

```
GET /v1/model-pricing/
```

Returns all active model pricing entries.

**Auth**: JWT or API Key

### Response `200`

```json theme={null}
[
  {
    "id": "880e8400-e29b-41d4-a716-446655440000",
    "model": "gpt-4o",
    "input_cost_per_token": 0.0000025,
    "output_cost_per_token": 0.000010,
    "is_active": true
  },
  {
    "id": "990e8400-e29b-41d4-a716-446655440000",
    "model": "gpt-4o-mini",
    "input_cost_per_token": 0.00000015,
    "output_cost_per_token": 0.0000006,
    "is_active": true
  }
]
```

### Response Fields

| Field                   | Type      | Description                                                   |
| ----------------------- | --------- | ------------------------------------------------------------- |
| `id`                    | `string`  | Pricing entry UUID                                            |
| `model`                 | `string`  | Model identifier (must match what you pass to `model_call()`) |
| `input_cost_per_token`  | `number`  | Cost per input/prompt token in USD                            |
| `output_cost_per_token` | `number`  | Cost per output/completion token in USD                       |
| `is_active`             | `boolean` | Whether this pricing entry is active                          |

***

## Upsert Model Pricing

```
PUT /v1/model-pricing/{model}
```

Creates or updates pricing for a model. The `model` path parameter is the model identifier string.

**Auth**: JWT or API Key

### Request Body

```json theme={null}
{
  "input_cost_per_token": 0.0000025,
  "output_cost_per_token": 0.000010,
  "is_active": true
}
```

| Field                   | Type      | Required | Default | Description                  |
| ----------------------- | --------- | -------- | ------- | ---------------------------- |
| `input_cost_per_token`  | `number`  | Yes      | —       | Cost per input token in USD  |
| `output_cost_per_token` | `number`  | Yes      | —       | Cost per output token in USD |
| `is_active`             | `boolean` | No       | `true`  | Whether this entry is active |

### Response `200`

Returns the full `ModelPricingResponse` for the created or updated entry.

### Example: Add pricing for Claude

```bash theme={null}
curl -X PUT http://localhost:8000/v1/model-pricing/claude-sonnet-4-5-20250929 \
  -H "Authorization: Bearer lg_..." \
  -H "Content-Type: application/json" \
  -d '{
    "input_cost_per_token": 0.000003,
    "output_cost_per_token": 0.000015
  }'
```
