Skip to content

Commit 30b86b7

Browse files
authored
Merge pull request #488 from aimlapi/docs/document-models-catalogue-api
Document the model catalogue API (`GET /v1/models`)
2 parents 8401f23 + 5799db4 commit 30b86b7

3 files changed

Lines changed: 367 additions & 0 deletions

File tree

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
* [🟡 Service Endpoints](api-references/service-endpoints/README.md)
1515
* [Account Balance](api-references/service-endpoints/account-balance.md)
16+
* [Model Catalogue API](api-references/service-endpoints/models-catalogue.md)
1617
* [API Key Management](api-references/service-endpoints/api-key-management.md)
1718
* [API Key Usage](api-references/service-endpoints/api-key-usage.md)
1819
* [Complete Model List](api-references/service-endpoints/complete-model-list.md)
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
icon: list-tree
3+
---
4+
5+
# Model Catalogue API
6+
7+
## List models
8+
9+
`GET /v1/models` returns the live catalogue. It is the machine-readable source for which models exist, what they are called, what they can do, and what they cost — use it instead of scraping the model pages.
10+
11+
By default each entry carries only its identity. Pricing, modalities and capabilities are opt-in, so the default response stays small:
12+
13+
```bash
14+
curl https://api.aimlapi.com/v1/models
15+
```
16+
17+
```json
18+
{
19+
"object": "list",
20+
"data": [
21+
{
22+
"id": "deepgram/aura-2",
23+
"aliases": ["aura-2", "aura-2-helena-en", "deepgram/aura-2-helena-en"],
24+
"type": "internal/text-to-speech",
25+
"info": { "name": "Aura-2", "developer": "Deepgram" },
26+
"tags": ["playground:tts"]
27+
}
28+
]
29+
}
30+
```
31+
32+
{% openapi-operation spec="models-catalogue" path="/v1/models" method="get" %}
33+
[OpenAPI models-catalogue](https://raw.githubusercontent.com/aimlapi/api-docs/refs/heads/main/docs/service-endpoints/models-catalogue.json)
34+
{% endopenapi-operation %}
35+
36+
## Asking for more per model
37+
38+
`include` attaches optional sections. Combine them freely, comma-separated:
39+
40+
```bash
41+
curl 'https://api.aimlapi.com/v1/models?include=pricing'
42+
curl 'https://api.aimlapi.com/v1/models?include=pricing,capabilities'
43+
curl 'https://api.aimlapi.com/v1/models?include=all'
44+
```
45+
46+
| Value | Adds |
47+
| --- | --- |
48+
| `pricing` | the `pricing` block — rates, units, price bands |
49+
| `modalities` | which input and output modalities the model handles |
50+
| `capabilities` | declared capabilities, e.g. `image_to_video` |
51+
| `all` | every section. `?details=true` is a synonym |
52+
53+
Unknown values are ignored rather than rejected, so a typo returns a valid response with that section missing.
54+
55+
## Filtering
56+
57+
Every filter below narrows *which models* come back. They are independent of `include`, so you can filter on capabilities without asking for the capabilities section.
58+
59+
| Parameter | Keeps models that… |
60+
| --- | --- |
61+
| `id` | match this id **or carry it as an alias** |
62+
| `type` | are served through this endpoint type |
63+
| `tags` | carry this tag, e.g. `playground:video` |
64+
| `modalities` | have it among input **or** output modalities |
65+
| `input_modalities` | accept this input modality |
66+
| `output_modalities` | produce this output modality |
67+
| `capabilities` | declare this capability |
68+
69+
Rules that apply to all of them:
70+
71+
* **Several values, one parameter — OR.** `?capabilities=text_to_video,image_to_video` returns models that do either.
72+
* **Several parameters — AND.** `?output_modalities=video&capabilities=audio_generation` returns models that do both.
73+
* Values are **case-insensitive**, and may be given comma-separated (`?tags=a,b`) or repeated (`?tags=a&tags=b`). Both forms merge.
74+
* An omitted parameter filters nothing.
75+
76+
```bash
77+
# every model that turns an image into video
78+
curl 'https://api.aimlapi.com/v1/models?capabilities=image_to_video'
79+
80+
# what one specific model costs — a few kilobytes instead of the whole catalogue
81+
curl 'https://api.aimlapi.com/v1/models?id=deepgram/aura-2&include=pricing'
82+
```
83+
84+
## Checking whether a model is still available
85+
86+
Match against **`id` and `aliases` together**. A model may be published under a canonical id while the name you integrated against lives on as an alias — the alias keeps working, but it is not the `id` any more, so an `id`-only comparison reports a live model as gone.
87+
88+
```js
89+
const res = await fetch('https://api.aimlapi.com/v1/models');
90+
const { data } = await res.json();
91+
92+
const byName = new Map();
93+
for (const model of data) {
94+
byName.set(model.id, model.id);
95+
for (const alias of model.aliases ?? []) byName.set(alias, model.id);
96+
}
97+
98+
const canonical = byName.get(myModelId); // undefined ⇒ genuinely unavailable
99+
```
100+
101+
The same map de-duplicates your list: two names resolving to one canonical id are one model, not two.
102+
103+
## Reading prices
104+
105+
With `?include=pricing`, each model carries a `pricing` block. Read `kind` first:
106+
107+
| `kind` | What it means |
108+
| --- | --- |
109+
| `fixed` | one rate per unit, in `units[]` |
110+
| `variants` | the rate depends on request parameters — `dimensions` names them, `variants[]` quotes a rate per combination |
111+
| `variable` | the rate cannot be quoted ahead of the request |
112+
113+
**Always read `per` together with `price`.** `price` is the charge for `per` units, and `per` is not the same across models — `1000000` for most token rates, `1000` for some, `1` for per-second and per-megapixel rates. Comparing bare `price` values across models compares different bases and will be wrong by orders of magnitude.
114+
115+
```json
116+
{
117+
"kind": "variants",
118+
"dimensions": ["resolution"],
119+
"variants": [
120+
{ "when": { "resolution": "720p" }, "price": 0.39, "unit": "second", "per": 1 },
121+
{ "when": { "resolution": "1080p" }, "price": 0.65, "unit": "second", "per": 1 }
122+
]
123+
}
124+
```
125+
126+
Here a 5-second 1080p generation costs `0.65 × 5 = $3.25`.
127+
128+
Prices are in USD and are what you are charged.
129+
130+
## Caching
131+
132+
Responses carry an `ETag`. Send it back as `If-None-Match` and you get `304 Not Modified` with an empty body when nothing changed:
133+
134+
```bash
135+
curl -I 'https://api.aimlapi.com/v1/models?include=pricing'
136+
# etag: W/"1440a0-uH6NONsG/9An5njw3kqMcYY5k8w"
137+
138+
curl -H 'If-None-Match: W/"1440a0-uH6NONsG/9An5njw3kqMcYY5k8w"' \
139+
'https://api.aimlapi.com/v1/models?include=pricing'
140+
# 304
141+
```
142+
143+
The ETag covers the whole response, so it changes on any catalogue edit — a new model or a reworded description, not only a price change. Treat it as "something moved, re-read and diff", not as a price-change feed.
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"title": "AIML API",
5+
"version": "1.0.0"
6+
},
7+
"servers": [
8+
{
9+
"url": "https://api.aimlapi.com"
10+
}
11+
],
12+
"paths": {
13+
"/v1/models": {
14+
"get": {
15+
"operationId": "_v1_models",
16+
"summary": "List models",
17+
"description": "Returns the model catalogue. By default each entry carries only its identity (`id`, `aliases`, `type`, `info`, `tags`); pricing, modalities and capabilities are opt-in through `include`.",
18+
"parameters": [
19+
{
20+
"name": "include",
21+
"in": "query",
22+
"required": false,
23+
"description": "Comma-separated sections to attach: `pricing`, `modalities`, `capabilities`. `all` (or `details`) attaches every section. Unknown values are ignored rather than rejected.",
24+
"schema": {
25+
"type": "string",
26+
"example": "pricing"
27+
}
28+
},
29+
{
30+
"name": "details",
31+
"in": "query",
32+
"required": false,
33+
"description": "Shorthand for `include=all`. Accepts `true` or `1`.",
34+
"schema": {
35+
"type": "string",
36+
"example": "true"
37+
}
38+
},
39+
{
40+
"name": "id",
41+
"in": "query",
42+
"required": false,
43+
"description": "Keep only models matching these ids. Matches the canonical `id` **and** every entry in `aliases`, so a legacy name resolves to the model that serves it today.",
44+
"schema": {
45+
"type": "string",
46+
"example": "gpt-5,aura-2-helena-en"
47+
}
48+
},
49+
{
50+
"name": "type",
51+
"in": "query",
52+
"required": false,
53+
"description": "Keep only models served through this endpoint type.",
54+
"schema": {
55+
"type": "string",
56+
"example": "openai/chat-completions"
57+
}
58+
},
59+
{
60+
"name": "tags",
61+
"in": "query",
62+
"required": false,
63+
"description": "Keep only models carrying these tags.",
64+
"schema": {
65+
"type": "string",
66+
"example": "playground:video"
67+
}
68+
},
69+
{
70+
"name": "modalities",
71+
"in": "query",
72+
"required": false,
73+
"description": "Keep only models whose input **or** output modalities include these values.",
74+
"schema": {
75+
"type": "string",
76+
"example": "video"
77+
}
78+
},
79+
{
80+
"name": "input_modalities",
81+
"in": "query",
82+
"required": false,
83+
"description": "Keep only models that accept these input modalities.",
84+
"schema": {
85+
"type": "string",
86+
"example": "image"
87+
}
88+
},
89+
{
90+
"name": "output_modalities",
91+
"in": "query",
92+
"required": false,
93+
"description": "Keep only models that produce these output modalities.",
94+
"schema": {
95+
"type": "string",
96+
"example": "video"
97+
}
98+
},
99+
{
100+
"name": "capabilities",
101+
"in": "query",
102+
"required": false,
103+
"description": "Keep only models declaring these capabilities, e.g. `image_to_video`, `text_to_video`, `audio_generation`.",
104+
"schema": {
105+
"type": "string",
106+
"example": "image_to_video"
107+
}
108+
}
109+
],
110+
"responses": {
111+
"200": {
112+
"description": "The catalogue.",
113+
"content": {
114+
"application/json": {
115+
"schema": {
116+
"type": "object",
117+
"properties": {
118+
"object": {
119+
"type": "string",
120+
"example": "list"
121+
},
122+
"data": {
123+
"type": "array",
124+
"items": {
125+
"type": "object",
126+
"properties": {
127+
"id": {
128+
"type": "string",
129+
"description": "Canonical model id. Stable, provider-independent, and the value to store on your side.",
130+
"example": "deepgram/aura-2"
131+
},
132+
"aliases": {
133+
"type": "array",
134+
"description": "Every other name this model answers to. All of them keep working on input, forever.",
135+
"items": {
136+
"type": "string"
137+
},
138+
"example": ["aura-2", "aura-2-helena-en"]
139+
},
140+
"type": {
141+
"type": "string",
142+
"description": "The endpoint this entry is callable through.",
143+
"example": "internal/text-to-speech"
144+
},
145+
"info": {
146+
"type": "object",
147+
"description": "Display metadata: name, developer, description, context length, links."
148+
},
149+
"tags": {
150+
"type": "array",
151+
"items": {
152+
"type": "string"
153+
},
154+
"example": ["playground:tts"]
155+
},
156+
"pricing": {
157+
"type": "object",
158+
"description": "Present only with `include=pricing`. See the page body for how to read it.",
159+
"properties": {
160+
"currency": {
161+
"type": "string",
162+
"example": "USD"
163+
},
164+
"kind": {
165+
"type": "string",
166+
"description": "`fixed` — one rate per unit. `variants` — the rate depends on request parameters, listed in `variants`. `variable` — the rate cannot be quoted up front.",
167+
"example": "fixed"
168+
},
169+
"units": {
170+
"type": "array",
171+
"description": "Rate lines. `price` is the charge for `per` units; `per` differs by unit, so never compare `price` across models without it. `price: null` means this line is request-dependent.",
172+
"items": {
173+
"type": "object"
174+
}
175+
},
176+
"thresholds": {
177+
"type": "array",
178+
"description": "Price bands that kick in above a request size.",
179+
"items": {
180+
"type": "object"
181+
}
182+
},
183+
"dimensions": {
184+
"type": "array",
185+
"description": "Request parameters the rate depends on.",
186+
"items": {
187+
"type": "string"
188+
},
189+
"example": ["resolution"]
190+
},
191+
"variants": {
192+
"type": "array",
193+
"description": "One quoted rate per combination of `dimensions`.",
194+
"items": {
195+
"type": "object"
196+
}
197+
}
198+
}
199+
},
200+
"modalities": {
201+
"type": "object",
202+
"description": "Present only with `include=modalities`."
203+
},
204+
"capabilities": {
205+
"type": "array",
206+
"description": "Present only with `include=capabilities`.",
207+
"items": {
208+
"type": "string"
209+
}
210+
}
211+
}
212+
}
213+
}
214+
}
215+
}
216+
}
217+
}
218+
}
219+
}
220+
}
221+
}
222+
}
223+
}

0 commit comments

Comments
 (0)