Skip to content

API: AI providers

Set or remove the price of a model (a person in the browser only; the local token and keys get 403)

PUT /api/v1/providers/prices: Set or remove the price of a model (a person in the browser only; the local token and keys get 403)

Last updated:

PUT/api/v1/providers/prices

Authentication#

Send the secret in the header Authorization: Bearer <secret>: the local token in local mode, an API key in network mode. An API key needs the admin scope; the local token has every scope. See the API overview for both modes.

Request body#

Content type application/json.

NameTypeRequiredDescription
currencystringnoThree letters, for example USD; needed to set a price.
input_micros_per_mtokinteger (int64) or nullnoThe price of a million input tokens, in millionths of the currency unit. Leave both prices out to remove the entry.
modelstringyesThe model id, as provider:models lists it.. min length 1
output_micros_per_mtokinteger (int64) or nullnoThe price of a million output tokens, in millionths of the currency unit.
providerstringyesThe id of the provider, for example openai.. min length 1
unitstringnoEmpty for a price of tokens, image for the price of one image, mchar for the price of a million characters of speech, second for the price of one second of video.
unit_microsinteger (int64) or nullnoWith a unit of image, mchar or second: the price of one image, of a million characters or of one second of video, in millionths of the currency unit; the token prices stay out.

Responses#

200 OK#

Content type application/json. Schema: ProviderPricesResult.

NameTypeRequiredDescription
pricesarray of PriceEntryno

400#

Validation failed; errors maps each field to its messages and issues lists each problem with its code, key and params

Content type application/problem+json. Schema: Problem.

401 Unauthorized#

Error (RFC 9457 problem details)

Content type application/problem+json. Schema: Problem.

403#

Error (RFC 9457 problem details)

Content type application/problem+json. Schema: Problem.

429#

Error (RFC 9457 problem details)

Content type application/problem+json. Schema: Problem.

Any other status#

Error (RFC 9457 problem details)

Content type application/problem+json. Schema: Problem.

curl -X PUT "http://127.0.0.1:7878/api/v1/providers/prices" \
  -H "Authorization: Bearer $STUARTY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "string",
  "provider": "string"
}'

Response examples

{
  "prices": [
    {
      "currency": "string",
      "input_micros_per_mtok": 0,
      "model": "string",
      "output_micros_per_mtok": 0,
      "provider": "string",
      "unit": "string",
      "unit_micros": 0
    }
  ]
}

The examples are built from the schemas of the OpenAPI document, so a value is a placeholder of its type. The fields that carry the real values are in the tables.