@bodhiapp/reference-api-types 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.d.ts +252 -7
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -12,10 +12,8 @@ export type ModelType = 'gguf';
12
12
  export type ModelSource = 'huggingface';
13
13
  /** Derived specialisation tags that are filterable in v1. */
14
14
  export type Specialisation = 'coding' | 'reasoning' | 'vision';
15
- /** Sort keys for the list endpoint. */
15
+ /** Sort keys for the list endpoint. Always sorted descending (HuggingFace supports descending only). */
16
16
  export type SortKey = 'downloads' | 'likes' | 'last_modified' | 'created_at' | 'trending';
17
- /** Sort direction. */
18
- export type SortOrder = 'asc' | 'desc';
19
17
  /** One quantization variant of a model (single-model response only). */
20
18
  export interface Quant {
21
19
  name: string;
@@ -110,10 +108,8 @@ export interface ListModelsQuery {
110
108
  tag?: string | string[];
111
109
  /** Repeatable; AND. Catalog-wide. */
112
110
  specialisation?: Specialisation | Specialisation[];
113
- /** Default "downloads". */
111
+ /** Default "downloads". Always sorted descending (HuggingFace supports descending only). */
114
112
  sort?: SortKey;
115
- /** Default "desc". */
116
- order?: SortOrder;
117
113
  /** Min params (billions). Page-local filter. */
118
114
  params_min?: number;
119
115
  /** Max params (billions). Page-local filter. */
@@ -138,9 +134,258 @@ export interface GetModelQuery {
138
134
  }
139
135
  /** Response of the single-model endpoint: a Model with its `quants` table populated. */
140
136
  export type GetModelResponse = Model;
141
- export type ErrorCode = 'validation' | 'unauthorized' | 'not_found' | 'unsupported_source' | 'unsupported_type' | 'internal';
137
+ /** A HuggingFace namespace is either an organization or a user account. */
138
+ export type NamespaceKind = 'org' | 'user';
139
+ /** One autocomplete suggestion for `GET /api/v1/namespaces`. */
140
+ export interface NamespaceSuggestion {
141
+ /** The handle used as the `{namespace}` in a `{namespace}/{repo}` path (e.g. "meta-llama"). */
142
+ name: string;
143
+ /** Display name, may differ from the handle (e.g. "Meta Llama"); null when HF omits it. */
144
+ fullname: string | null;
145
+ /** Absolute avatar URL (HF's relative ones are resolved to absolute); null when none. */
146
+ avatar_url: string | null;
147
+ kind: NamespaceKind;
148
+ }
149
+ /** Query parameters for `GET /api/v1/namespaces`. */
150
+ export interface ListNamespacesQuery {
151
+ /** Search prefix/substring the user is typing. Required. */
152
+ q: string;
153
+ /** Restrict to orgs or users. Omit to return both. */
154
+ kind?: NamespaceKind;
155
+ /** Max suggestions to return. 1–50, default 10. */
156
+ limit?: number;
157
+ }
158
+ export interface ListNamespacesResponse {
159
+ items: NamespaceSuggestion[];
160
+ }
161
+ export type ErrorCode = 'validation' | 'unauthorized' | 'not_found' | 'unsupported_source' | 'unsupported_type' | 'upstream' | 'internal';
142
162
  /** Error envelope returned on non-2xx responses. */
143
163
  export interface ErrorResponse {
144
164
  error: ErrorCode | string;
145
165
  message?: string;
146
166
  }
167
+ /**
168
+ * Error envelope when an upstream (HuggingFace) call fails: the upstream status and raw body are
169
+ * forwarded verbatim. Returned with the upstream HTTP status as the response status.
170
+ */
171
+ export interface UpstreamErrorResponse {
172
+ error: 'upstream';
173
+ status: number;
174
+ body: unknown;
175
+ }
176
+ export type Modality = 'text' | 'audio' | 'image' | 'video' | 'pdf';
177
+ /** Only real models.dev values; absent ⇒ "Stable" (synthesized by the UI). */
178
+ export type ModelStatus = 'alpha' | 'beta' | 'deprecated';
179
+ /** Derived from the boolean fields + modalities (`vision` = modalities_in includes 'image'). */
180
+ export type Capability = 'reasoning' | 'tool_call' | 'structured_output' | 'attachment' | 'vision';
181
+ /** The BodhiApp api_format the configure bridge can target. */
182
+ export type BridgeApiFormat = 'openai' | 'openai_responses' | 'anthropic' | 'anthropic_oauth' | 'gemini';
183
+ export type ProviderShape = 'openai' | 'openai-compatible' | 'anthropic' | 'openrouter' | 'kiro' | 'native';
184
+ export type ApiFormatHint = BridgeApiFormat | 'other';
185
+ /** Band-relevant pricing for list rows / served-by rows. null = field absent at source. */
186
+ export interface PricingLite {
187
+ input_per_m: number | null;
188
+ output_per_m: number | null;
189
+ cache_read_per_m: number | null;
190
+ cache_write_per_m: number | null;
191
+ }
192
+ /**
193
+ * Full unified pricing (model-detail). The opaque blob fields carry Portkey gap dimensions and are
194
+ * deferred — they ship `null`/absent in the models.dev-only release and are filled later without a
195
+ * breaking change.
196
+ */
197
+ export interface Pricing extends PricingLite {
198
+ currency: string;
199
+ reasoning_per_m: number | null;
200
+ input_audio_per_m: number | null;
201
+ output_audio_per_m: number | null;
202
+ /** Deferred Portkey-gap blobs; present-but-null until Portkey enrichment lands. */
203
+ cache_write_1h_per_m?: number | null;
204
+ context_over_200k?: unknown | null;
205
+ batch?: unknown | null;
206
+ finetune?: unknown | null;
207
+ tool_surcharges?: unknown | null;
208
+ image_pricing?: unknown | null;
209
+ video_pricing?: unknown | null;
210
+ custom_pricing?: unknown | null;
211
+ calculate?: unknown | null;
212
+ /** Which source filled this row. */
213
+ pricing_source: 'modelsdev' | 'portkey' | 'both' | null;
214
+ /** Deferred; whether filled from Portkey's per-provider `default` fallback. */
215
+ portkey_default_used?: boolean;
216
+ }
217
+ export interface PageMeta {
218
+ page: number;
219
+ page_size: number;
220
+ total: number;
221
+ }
222
+ /** value → count over the current (post-filter, pre-pagination) result set. */
223
+ export type FacetBucket = Record<string, number>;
224
+ export interface ModelFacets {
225
+ capability: FacetBucket;
226
+ modality: FacetBucket;
227
+ /** keys: alpha|beta|deprecated|stable (stable = status absent). */
228
+ status: FacetBucket;
229
+ /** provider slug → model count. */
230
+ provider: FacetBucket;
231
+ /** keys: open|closed. */
232
+ open_weights: FacetBucket;
233
+ }
234
+ export interface ConfigureBridge {
235
+ api_format: BridgeApiFormat;
236
+ /** models.dev `api` when present, else a BodhiApp preset; null ⇒ the form shows "base URL required". */
237
+ base_url: string | null;
238
+ base_url_source: 'modelsdev_api' | 'bodhi_preset' | 'user_required';
239
+ /** Bedrock's `api` is a literal AWS_REGION placeholder — flag it. */
240
+ base_url_requires_substitution: boolean;
241
+ }
242
+ export interface ProviderSummary {
243
+ slug: string;
244
+ name: string;
245
+ /** Served from our own R2 (images.<env>-api.getbodhi.app); null ⇒ UI falls back to a monogram. */
246
+ logo_url: string | null;
247
+ model_count: number;
248
+ /** 1-based, by model_count desc. */
249
+ rank: number;
250
+ /** models.dev `api`; null for native providers (the bridge fills from a BodhiApp preset). */
251
+ api_base_url: string | null;
252
+ provider_shape: ProviderShape;
253
+ api_format_hint: ApiFormatHint;
254
+ /** Union of capability flags across the provider's models. */
255
+ capabilities_summary: Capability[];
256
+ pricing_summary: {
257
+ min_in_per_m: number | null;
258
+ min_out_per_m: number | null;
259
+ };
260
+ }
261
+ export interface ProviderListResponse extends PageMeta {
262
+ items: ProviderSummary[];
263
+ facets: {
264
+ capability: FacetBucket;
265
+ api_format: FacetBucket;
266
+ };
267
+ }
268
+ export interface ProviderDetailResponse {
269
+ slug: string;
270
+ name: string;
271
+ logo_url: string | null;
272
+ model_count: number;
273
+ /** credential env var names, e.g. ["ANTHROPIC_API_KEY"]. */
274
+ env: string[];
275
+ npm: string | null;
276
+ doc_url: string | null;
277
+ api_base_url: string | null;
278
+ provider_shape: ProviderShape;
279
+ bridge: ConfigureBridge;
280
+ }
281
+ export interface ListProvidersQuery {
282
+ q?: string;
283
+ capability?: Capability | Capability[];
284
+ api_format?: ApiFormatHint | ApiFormatHint[];
285
+ pricing_max?: number;
286
+ sort?: 'rank' | 'name' | 'model_count';
287
+ page?: number;
288
+ page_size?: number;
289
+ }
290
+ export interface ProviderModelRow {
291
+ model_id: string;
292
+ name: string;
293
+ caps: Capability[];
294
+ context_limit: number | null;
295
+ output_limit: number | null;
296
+ pricing: PricingLite;
297
+ status: ModelStatus | null;
298
+ modalities_in: Modality[];
299
+ modalities_out: Modality[];
300
+ }
301
+ export interface ProviderModelsResponse {
302
+ items: ProviderModelRow[];
303
+ total: number;
304
+ }
305
+ export interface ListProviderModelsQuery {
306
+ sort?: 'name' | 'context' | 'price';
307
+ }
308
+ /** One logical model (serving rows grouped by canonical_id). `slug`/`model_id`/`pricing` are the
309
+ * primary (cheapest input_per_m) provider in the group. */
310
+ export interface ModelLite {
311
+ slug: string;
312
+ model_id: string;
313
+ name: string;
314
+ family: string | null;
315
+ context_limit: number | null;
316
+ output_limit: number | null;
317
+ pricing: PricingLite;
318
+ caps: Capability[];
319
+ status: ModelStatus | null;
320
+ open_weights: boolean;
321
+ modalities_in: Modality[];
322
+ modalities_out: Modality[];
323
+ /** COUNT(DISTINCT provider_slug) in the canonical_id group. */
324
+ provider_count: number;
325
+ release_date: string | null;
326
+ last_updated: string | null;
327
+ }
328
+ export interface ListCatalogModelsQuery {
329
+ q?: string;
330
+ /** Repeatable; AND. */
331
+ capability?: Capability | Capability[];
332
+ /** Repeatable; OR. Matches modalities_in ∪ modalities_out. */
333
+ modality?: Modality | Modality[];
334
+ pricing_max?: number;
335
+ pricing_band?: 'free' | 'low' | 'mid' | 'high';
336
+ context_min?: number;
337
+ /** Repeatable. "stable" selects rows whose status is ABSENT. */
338
+ status?: ('alpha' | 'beta' | 'deprecated' | 'stable') | ('alpha' | 'beta' | 'deprecated' | 'stable')[];
339
+ /** Repeatable; OR. */
340
+ provider?: string | string[];
341
+ open_weights?: 'open' | 'closed';
342
+ sort?: 'updated' | 'context' | 'price' | 'name' | 'providers';
343
+ page?: number;
344
+ page_size?: number;
345
+ }
346
+ export interface ModelsListResponse extends PageMeta {
347
+ items: ModelLite[];
348
+ facets: ModelFacets;
349
+ }
350
+ export interface ServedBy {
351
+ slug: string;
352
+ name: string;
353
+ logo_url: string | null;
354
+ base_url: string | null;
355
+ pricing: PricingLite;
356
+ }
357
+ export interface ModelDetailResponse {
358
+ /** primary/representative provider of the canonical_id group. */
359
+ slug: string;
360
+ model_id: string;
361
+ name: string;
362
+ family: string | null;
363
+ status: ModelStatus | null;
364
+ reasoning: boolean;
365
+ tool_call: boolean;
366
+ structured_output: boolean | null;
367
+ attachment: boolean;
368
+ open_weights: boolean;
369
+ temperature: boolean | number | null;
370
+ reasoning_options: unknown | null;
371
+ context_limit: number | null;
372
+ output_limit: number | null;
373
+ modalities_in: Modality[];
374
+ modalities_out: Modality[];
375
+ release_date: string | null;
376
+ last_updated: string | null;
377
+ knowledge_cutoff: string | null;
378
+ pricing: Pricing;
379
+ /** Enrichment (models.json) — deferred with Portkey; null in the models.dev-only release. */
380
+ license: string | null;
381
+ links: unknown | null;
382
+ weights: unknown | null;
383
+ benchmarks: unknown | null;
384
+ /** The other serving rows in the same canonical_id group, each with its own price. */
385
+ served_by: ServedBy[];
386
+ bridge: ConfigureBridge;
387
+ }
388
+ export interface GetCatalogModelQuery {
389
+ /** reserved */
390
+ include?: string;
391
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bodhiapp/reference-api-types",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "TypeScript request/response types for the Bodhi Models Reference API (types only — no runtime).",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",