feat: add a source filter to the AI model price list (#28329)

## Description

With prices from the price book and prices set through the API both in the table, `list` showed only the price in effect and gave no way to tell where it came from. There was also no way to see the price book's entry for a model that had been overridden, since the listing resolves to the custom price.

This adds a `source` column to the output and a `--source` filter for narrowing to one source, or to every row with `all`.

Note: `--source` selects rows rather than models. A model carrying both a price book price and a custom one appears under either value, so the two filtered listings do not sum to the unfiltered one. `--source all` reports both rows at once.

## Changes

- Add `Source` to `codersdk.AIModelPrice` and `AIModelPricesFilter`, and map it in `db2sdk`, which previously dropped it.
- Filter `GetAIModelPrices` by source before resolution, so the price book's row for an overridden model stays reachable.
- Accept `all` as a source, which reports every price a model holds instead of resolving to one.
- Accept a `source` query parameter on the list endpoint, rejected with a 400 when outside the enum.
- Add `--source` to the list command and a `source` column to its output.
- Document the column and the filter, and lead the price section with `coder exp ai-model-prices list`.
- Distinguish a deployment's default prices from the price book that ships with each release.

Closes https://linear.app/codercom/issue/AIGOV-593

> [!NOTE]
> Initially generated by Claude Opus 5, modified and reviewed by @ssncferreira
This commit is contained in:
Susana Ferreira
2026-08-20 11:56:58 +01:00
committed by GitHub
parent 4a7a0a3348
commit 50ecd6959f
16 changed files with 455 additions and 45 deletions
+26 -10
View File
@@ -1149,22 +1149,38 @@ title: Schemas
"model": "string",
"output_price": 0,
"provider": "string",
"source": "default",
"updated_at": "2019-08-24T14:15:22Z"
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
|---------------------|---------|----------|--------------|-------------|
| `cache_read_price` | integer | false | | |
| `cache_write_price` | integer | false | | |
| `created_at` | string | false | | |
| `input_price` | integer | false | | |
| `model` | string | false | | |
| `output_price` | integer | false | | |
| `provider` | string | false | | |
| `updated_at` | string | false | | |
| Name | Type | Required | Restrictions | Description |
|---------------------|------------------------------------------------------------|----------|--------------|-------------|
| `cache_read_price` | integer | false | | |
| `cache_write_price` | integer | false | | |
| `created_at` | string | false | | |
| `input_price` | integer | false | | |
| `model` | string | false | | |
| `output_price` | integer | false | | |
| `provider` | string | false | | |
| `source` | [codersdk.AIModelPriceSource](#codersdkaimodelpricesource) | false | | |
| `updated_at` | string | false | | |
## codersdk.AIModelPriceSource
```json
"default"
```
### Properties
#### Enumerated Values
| Value(s) |
|---------------------|
| `custom`, `default` |
## codersdk.AIModelPriceUpsert