Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

openrouter.models.ts

58 lines1.6 KB

1/**
2 * Hand-written wrapper. DO NOT regenerate this file.
3 *
4 * The model data lives in `openrouter.models.json` (regenerated by
5 * `fetch-openrouter-models.ts`). This wrapper re-exports it typed so
6 * consumers can keep `import { models } from './openrouter.models'`.
7 *
8 * The data is loaded via `JSON.parse(readFileSync(...))` rather than an
9 * `import ... with { type: 'json' }` attribute so the loader doesn't have
10 * to support JSON import attributes.
11 */
12​
13import { readFileSync } from 'node:fs'
14import { dirname, resolve } from 'node:path'
15import { fileURLToPath } from 'node:url'
16​
17export interface OpenRouterModel {
18 id: string
19 canonical_slug?: string
20 hugging_face_id?: string | null
21 name: string
22 created?: number
23 description?: string
24 context_length: number
25 architecture: {
26 modality: string
27 input_modalities: Array<string>
28 output_modalities: Array<string>
29 tokenizer?: string
30 instruct_type?: string | null
31 }
32​
33 pricing: {
34 prompt: string
35 completion: string
36 audio?: string
37 request?: string
38 image?: string
39 web_search?: string
40 internal_reasoning?: string
41 input_cache_read?: string
42 input_cache_write?: string
43 }
44 top_provider: {
45 context_length: number
46 max_completion_tokens: number | null
47 is_moderated: boolean
48 }
49 per_request_limits?: Record<string, string> | null
50 supported_parameters?: Array<string>
52​
53const __dirname = dirname(fileURLToPath(import.meta.url))
54const DATA_PATH = resolve(__dirname, 'openrouter.models.json')
55​
56export const models: Array<OpenRouterModel> = JSON.parse(
57 readFileSync(DATA_PATH, 'utf-8'),