Compare commits
219
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78e6c1a2dd | ||
|
|
477ccffee8 | ||
|
|
4501589a20 | ||
|
|
0b643efd17 | ||
|
|
8a0ea15aca | ||
|
|
b3676fd77d | ||
|
|
f97a02078c | ||
|
|
2a7153fcef | ||
|
|
3396f15854 | ||
|
|
ccfd99b5e9 | ||
|
|
ef6eb88216 | ||
|
|
94e128244a | ||
|
|
ec6d07d41c | ||
|
|
4efbe58af8 | ||
|
|
a4fe8fc36b | ||
|
|
b24b44ca0a | ||
|
|
466d664bf9 | ||
|
|
340ef131e9 | ||
|
|
6ce69a706a | ||
|
|
3505674a1b | ||
|
|
cfeaef8f77 | ||
|
|
f73a5d571b | ||
|
|
62d31abff8 | ||
|
|
ee71ea7181 | ||
|
|
b038f40b64 | ||
|
|
4b7bdd9692 | ||
|
|
b73ef1a634 | ||
|
|
c11b5bb00b | ||
|
|
01bc1785b4 | ||
|
|
36b5847fa4 | ||
|
|
040beaf818 | ||
|
|
9f8e1a3858 | ||
|
|
ce7a1c0218 | ||
|
|
55e6c7a2ee | ||
|
|
8bacf496fe | ||
|
|
ac12cf1f43 | ||
|
|
06c7ea2303 | ||
|
|
92b6e9da53 | ||
|
|
660ff026a0 | ||
|
|
9a910a1fb3 | ||
|
|
7dc5f787b0 | ||
|
|
c25ddce07c | ||
|
|
e73a82e44e | ||
|
|
7de9710b5a | ||
|
|
d1a8dbcdde | ||
|
|
556ef84d11 | ||
|
|
f2020553ea | ||
|
|
ca0a7e17cb | ||
|
|
d2468eafb2 | ||
|
|
96d0f9beff | ||
|
|
7989be9f34 | ||
|
|
f30e44f4b5 | ||
|
|
1383177893 | ||
|
|
2e58165af9 | ||
|
|
f3466affc0 | ||
|
|
3697c99297 | ||
|
|
796dda2fd1 | ||
|
|
1d363cbd7f | ||
|
|
3758725979 | ||
|
|
c039e82f12 | ||
|
|
1e90242cdb | ||
|
|
277ac8577e | ||
|
|
6e5f35546d | ||
|
|
aa69da14d6 | ||
|
|
c7af5ba9be | ||
|
|
d6e9e6735f | ||
|
|
a987719410 | ||
|
|
9528528f69 | ||
|
|
fbad40d863 | ||
|
|
84559b598b | ||
|
|
9d45730db9 | ||
|
|
791089e4aa | ||
|
|
fcc4387187 | ||
|
|
6aa32ba566 | ||
|
|
459a563d2b | ||
|
|
739e5a7c8e | ||
|
|
efc87afa3a | ||
|
|
f616aa6a0b | ||
|
|
f77e75a567 | ||
|
|
651bd4d91a | ||
|
|
30b9170106 | ||
|
|
81e42c653c | ||
|
|
11f2a38594 | ||
|
|
6621be978f | ||
|
|
c8d72661d6 | ||
|
|
21b7cacc33 | ||
|
|
ac1dc14439 | ||
|
|
63acb799da | ||
|
|
2e6ebb6750 | ||
|
|
d8c2e15632 | ||
|
|
8a70160200 | ||
|
|
7ea1d4e15c | ||
|
|
1c71b1bf17 | ||
|
|
acc3126194 | ||
|
|
1f67addc01 | ||
|
|
bb011e71a7 | ||
|
|
3df181411f | ||
|
|
a1f588463c | ||
|
|
cb414c6886 | ||
|
|
4095e819c9 | ||
|
|
9367cc1825 | ||
|
|
96b9a04c4b | ||
|
|
d9de217dc4 | ||
|
|
64ea80d416 | ||
|
|
d3859517d1 | ||
|
|
985a144c5f | ||
|
|
5b05070eb4 | ||
|
|
dad245c5e1 | ||
|
|
bcff9bd6b2 | ||
|
|
561bdaa546 | ||
|
|
f4f210986c | ||
|
|
f4206f4eaa | ||
|
|
52e5b67bc4 | ||
|
|
d11b0e448c | ||
|
|
591745690e | ||
|
|
5a4bc9b383 | ||
|
|
a14171bcd4 | ||
|
|
0741c5a53c | ||
|
|
7a1ec8737b | ||
|
|
7c37c92c2d | ||
|
|
ec4ec6d441 | ||
|
|
d96da5ece6 | ||
|
|
0342c79d03 | ||
|
|
37136fc2f3 | ||
|
|
131eca9c5e | ||
|
|
3e38d46c4c | ||
|
|
989939773b | ||
|
|
4f1d5c511a | ||
|
|
34a21e07f2 | ||
|
|
979f5da0ca | ||
|
|
73b357e2ab | ||
|
|
97c71f1663 | ||
|
|
59c270bc85 | ||
|
|
a4c18f88ed | ||
|
|
3343a585ac | ||
|
|
f23db95550 | ||
|
|
556d9a9045 | ||
|
|
49991c8f8f | ||
|
|
20c1e810ce | ||
|
|
15d08b4540 | ||
|
|
14bbc303e5 | ||
|
|
02da63ed48 | ||
|
|
07daef8c54 | ||
|
|
b6ebe8696c | ||
|
|
ad654e71da | ||
|
|
508f4d48e1 | ||
|
|
cd7c70b4fe | ||
|
|
10e752ea84 | ||
|
|
4cdb4c700b | ||
|
|
d497a446eb | ||
|
|
745cf557b3 | ||
|
|
db295d6842 | ||
|
|
47c0eed41e | ||
|
|
e690980857 | ||
|
|
f5f7d1a167 | ||
|
|
cfbbb55c4d | ||
|
|
1956762cdf | ||
|
|
28571433f7 | ||
|
|
aef5e48bae | ||
|
|
8ba19639a7 | ||
|
|
0f9b4c9edc | ||
|
|
2a9b6256dc | ||
|
|
51633fe106 | ||
|
|
169b5c4331 | ||
|
|
9d0f0d6d56 | ||
|
|
1d2af0c97b | ||
|
|
cc14ae4370 | ||
|
|
ad9a3448d2 | ||
|
|
c6f9cf58e4 | ||
|
|
bba5809471 | ||
|
|
c0852f1b4f | ||
|
|
0fc3a3f635 | ||
|
|
68936dc062 | ||
|
|
ade9760060 | ||
|
|
2a8b90b197 | ||
|
|
8569f0dfef | ||
|
|
fc98ceb72e | ||
|
|
be7c5afc94 | ||
|
|
57e62c43b0 | ||
|
|
0898c35c9f | ||
|
|
46b23fb313 | ||
|
|
05fedc76cc | ||
|
|
2738f81d1a | ||
|
|
89b834086a | ||
|
|
1ab2ff8163 | ||
|
|
9468676683 | ||
|
|
6cdd2f054b | ||
|
|
b13abc9141 | ||
|
|
e5ba264751 | ||
|
|
a7811fb522 | ||
|
|
605fae75d9 | ||
|
|
bcab0885bc | ||
|
|
26b05268ae | ||
|
|
1aee13d2e5 | ||
|
|
0a924e6bb2 | ||
|
|
9769b2b11d | ||
|
|
1b0db099cf | ||
|
|
16ed78587c | ||
|
|
0b88965165 | ||
|
|
acc704ce39 | ||
|
|
51ad3b264e | ||
|
|
146b6c7084 | ||
|
|
0e3cbe3c64 | ||
|
|
604d4d66a4 | ||
|
|
f5090028b8 | ||
|
|
4bad8faf29 | ||
|
|
0df2ccf586 | ||
|
|
bafdc00b45 | ||
|
|
49840c013b | ||
|
|
eccae0b54e | ||
|
|
4cca29405f | ||
|
|
e40d9dd338 | ||
|
|
6a74991397 | ||
|
|
035999cb58 | ||
|
|
cec56bf1bc | ||
|
|
85f0cdcb2f | ||
|
|
9d60164243 | ||
|
|
9420048dfe | ||
|
|
8db6c27634 |
No files matched your search
@@ -10,6 +10,7 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
if: github.repository == 'anomalyco/models.dev'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -35,3 +36,4 @@ jobs:
|
||||
- run: bun sst deploy --stage=dev
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
CLOUDFLARE_DEFAULT_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_DEFAULT_ACCOUNT_ID }}
|
||||
@@ -2,7 +2,7 @@ name: Sync Model Catalogs
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "17 8 * * *"
|
||||
- cron: "17 * * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
@@ -13,16 +13,36 @@ permissions:
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
providers:
|
||||
if: github.repository == 'anomalyco/models.dev'
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.providers.outputs.matrix }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
|
||||
with:
|
||||
ref: dev
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@f4d14e03ff726c06358e5557344e1da148b56cf7
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
|
||||
- name: List sync providers
|
||||
id: providers
|
||||
run: echo "matrix=$(bun models:sync --list-providers)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
sync:
|
||||
needs: providers
|
||||
if: github.repository == 'anomalyco/models.dev'
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- group: aggregators
|
||||
title: "chore(sync): update aggregator model catalogs"
|
||||
branch: automation/sync-models-aggregators
|
||||
labels: automation,model-sync,sync-group:aggregators,provider:openrouter
|
||||
matrix: ${{ fromJSON(needs.providers.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@@ -39,9 +59,15 @@ jobs:
|
||||
run: bun install
|
||||
|
||||
- name: Sync model catalogs
|
||||
run: bun models:sync ${{ matrix.group }}
|
||||
run: bun models:sync ${{ matrix.provider }}
|
||||
env:
|
||||
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
|
||||
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
|
||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
||||
GOOGLE_GENERATIVE_AI_API_KEY: ${{ secrets.GOOGLE_GENERATIVE_AI_API_KEY }}
|
||||
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
|
||||
CLOUDFLARE_WORKERS_AI_SYNC_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_WORKERS_AI_SYNC_ACCOUNT_ID }}
|
||||
CLOUDFLARE_WORKERS_AI_SYNC_API_TOKEN: ${{ secrets.CLOUDFLARE_WORKERS_AI_SYNC_API_TOKEN }}
|
||||
|
||||
- name: Validate models
|
||||
run: bun validate
|
||||
@@ -49,9 +75,9 @@ jobs:
|
||||
- name: Create pull request
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
BRANCH: ${{ matrix.branch }}
|
||||
LABELS: ${{ matrix.labels }}
|
||||
TITLE: ${{ matrix.title }}
|
||||
BRANCH: automation/sync-models-${{ matrix.provider }}
|
||||
LABELS: automation,model-sync,provider:${{ matrix.provider }}
|
||||
TITLE: "chore(sync): update ${{ matrix.name }} model catalog"
|
||||
run: |
|
||||
if [ -z "$(git status --porcelain -- providers)" ]; then
|
||||
echo "No model catalog changes found."
|
||||
@@ -60,6 +86,7 @@ jobs:
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git fetch --no-tags --depth=1 origin "+refs/heads/$BRANCH:refs/remotes/origin/$BRANCH" || true
|
||||
git checkout -B "$BRANCH"
|
||||
git add providers
|
||||
git commit -m "$TITLE"
|
||||
|
||||
@@ -1,428 +1,5 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
import path from "node:path";
|
||||
import { mkdir, readdir, rm } from "node:fs/promises";
|
||||
import { z } from "zod";
|
||||
import { main } from "../src/sync/index.js";
|
||||
|
||||
import { AuthoredModel, AuthoredModelShape } from "../src/schema.js";
|
||||
import { cloudflareWorkersAi } from "./sync/cloudflare-workers-ai.js";
|
||||
import { google } from "./sync/google.js";
|
||||
import { openrouter } from "./sync/openrouter.js";
|
||||
import { xai } from "./sync/xai.js";
|
||||
|
||||
const ExistingModel = AuthoredModelShape.partial()
|
||||
.extend({
|
||||
extends: z
|
||||
.object({
|
||||
from: z.string(),
|
||||
omit: z.array(z.string()).optional(),
|
||||
})
|
||||
.strict()
|
||||
.optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type ExistingModel = z.infer<typeof ExistingModel>;
|
||||
export type SyncedModel = Omit<z.infer<typeof AuthoredModelShape>, "id">;
|
||||
|
||||
export interface SyncProvider<SourceModel> {
|
||||
id: string;
|
||||
name: string;
|
||||
modelsDir: string;
|
||||
skipCreates?: boolean;
|
||||
sourceID?(model: SourceModel): string;
|
||||
skippedNotice?(ids: string[]): string[];
|
||||
fetchModels(): Promise<unknown>;
|
||||
parseModels(raw: unknown): SourceModel[];
|
||||
translateModel(
|
||||
model: SourceModel,
|
||||
context: { existing(id: string): ExistingModel | undefined },
|
||||
): { id: string; model: SyncedModel } | undefined;
|
||||
}
|
||||
|
||||
export interface SyncResult {
|
||||
id: string;
|
||||
name: string;
|
||||
status: "changed" | "unchanged";
|
||||
created: number;
|
||||
updated: number;
|
||||
deleted: number;
|
||||
unchanged: number;
|
||||
notices: string[];
|
||||
files: Array<{ status: "created" | "updated" | "deleted"; path: string }>;
|
||||
}
|
||||
|
||||
export const providers: {
|
||||
"cloudflare-workers-ai": SyncProvider<any>;
|
||||
google: SyncProvider<any>;
|
||||
openrouter: SyncProvider<any>;
|
||||
xai: SyncProvider<any>;
|
||||
} = {
|
||||
"cloudflare-workers-ai": cloudflareWorkersAi,
|
||||
google,
|
||||
openrouter,
|
||||
xai,
|
||||
};
|
||||
|
||||
export const groups = {
|
||||
aggregators: ["openrouter"],
|
||||
cloudflare: ["cloudflare-workers-ai"],
|
||||
direct: ["google", "xai"],
|
||||
} as const;
|
||||
|
||||
type ProviderID = keyof typeof providers;
|
||||
|
||||
interface SyncOptions {
|
||||
dryRun?: boolean;
|
||||
newOnly?: boolean;
|
||||
}
|
||||
|
||||
export async function syncProviderByID(id: ProviderID, options: SyncOptions = {}) {
|
||||
return syncProvider(providers[id], options);
|
||||
}
|
||||
|
||||
export async function syncProvider<SourceModel>(
|
||||
provider: SyncProvider<SourceModel>,
|
||||
options: SyncOptions = {},
|
||||
): Promise<SyncResult> {
|
||||
console.log(`\nSyncing ${provider.name}...`);
|
||||
|
||||
const existing = await readExisting(provider.modelsDir);
|
||||
const sourceModels = provider.parseModels(await provider.fetchModels());
|
||||
const desired = new Map<string, { model: z.infer<typeof AuthoredModel>; content: string }>();
|
||||
const skippedRemote: string[] = [];
|
||||
|
||||
for (const sourceModel of sourceModels) {
|
||||
const translated = provider.translateModel(sourceModel, {
|
||||
existing(id) {
|
||||
return existing.get(`${id}.toml`)?.toml;
|
||||
},
|
||||
});
|
||||
if (translated === undefined) {
|
||||
if (provider.skipCreates) skippedRemote.push(provider.sourceID?.(sourceModel) ?? "unknown");
|
||||
continue;
|
||||
}
|
||||
|
||||
const relativePath = `${translated.id}.toml`;
|
||||
if (provider.skipCreates && !existing.has(relativePath)) {
|
||||
skippedRemote.push(translated.id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (desired.has(relativePath)) {
|
||||
throw new Error(`Duplicate synced model path: ${provider.id}/${relativePath}`);
|
||||
}
|
||||
|
||||
const parsed = AuthoredModel.safeParse({
|
||||
id: translated.id,
|
||||
...translated.model,
|
||||
});
|
||||
if (!parsed.success) {
|
||||
parsed.error.cause = { provider: provider.id, path: relativePath };
|
||||
throw parsed.error;
|
||||
}
|
||||
|
||||
desired.set(relativePath, {
|
||||
model: parsed.data,
|
||||
content: formatToml(parsed.data),
|
||||
});
|
||||
}
|
||||
|
||||
const files: SyncResult["files"] = [];
|
||||
let unchanged = 0;
|
||||
|
||||
for (const [relativePath, file] of desired) {
|
||||
const filePath = path.join(provider.modelsDir, relativePath);
|
||||
const current = existing.get(relativePath);
|
||||
|
||||
if (current === undefined) {
|
||||
files.push({ status: "created", path: filePath });
|
||||
if (options.dryRun) {
|
||||
console.log(`Would create ${relativePath}`);
|
||||
} else {
|
||||
await mkdir(path.dirname(filePath), { recursive: true });
|
||||
await Bun.write(filePath, file.content);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sameModel(relativePath, current.toml, file.model)) {
|
||||
if (options.newOnly) {
|
||||
unchanged++;
|
||||
continue;
|
||||
}
|
||||
|
||||
files.push({ status: "updated", path: filePath });
|
||||
if (options.dryRun) {
|
||||
console.log(`Would update ${relativePath}`);
|
||||
} else {
|
||||
if (current.symlink) await rm(filePath, { force: true });
|
||||
await Bun.write(filePath, file.content);
|
||||
}
|
||||
} else {
|
||||
unchanged++;
|
||||
}
|
||||
}
|
||||
|
||||
for (const relativePath of existing.keys()) {
|
||||
if (desired.has(relativePath)) continue;
|
||||
if (options.newOnly) {
|
||||
console.log(`Skipping removal in new-only mode: ${relativePath}`);
|
||||
unchanged++;
|
||||
continue;
|
||||
}
|
||||
|
||||
const filePath = path.join(provider.modelsDir, relativePath);
|
||||
files.push({ status: "deleted", path: filePath });
|
||||
if (options.dryRun) {
|
||||
console.log(`Would remove ${relativePath}`);
|
||||
} else {
|
||||
await rm(filePath, { force: true });
|
||||
}
|
||||
}
|
||||
|
||||
const result = summarize(provider, files, unchanged, provider.skippedNotice?.(skippedRemote) ?? []);
|
||||
console.log(
|
||||
`${options.dryRun ? "Dry run: " : ""}${result.created} created, ${result.updated} updated, ${result.deleted} removed, ${result.unchanged} unchanged`,
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function syncTargets(target: string, options: SyncOptions = {}) {
|
||||
const ids = target in groups
|
||||
? groups[target as keyof typeof groups]
|
||||
: target in providers
|
||||
? [target as ProviderID]
|
||||
: undefined;
|
||||
|
||||
if (ids === undefined) {
|
||||
throw new Error(`Unknown sync target: ${target}`);
|
||||
}
|
||||
|
||||
const results: SyncResult[] = [];
|
||||
for (const id of ids) {
|
||||
results.push(await syncProviderByID(id as ProviderID, options));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
async function readExisting(modelsDir: string) {
|
||||
const existing = new Map<string, { text: string; toml: ExistingModel; symlink: boolean }>();
|
||||
|
||||
for (const { file, symlink } of await tomlFiles(modelsDir)) {
|
||||
const text = await Bun.file(path.join(modelsDir, file)).text();
|
||||
const parsed = ExistingModel.safeParse(Bun.TOML.parse(text));
|
||||
if (!parsed.success) {
|
||||
parsed.error.cause = { path: path.join(modelsDir, file) };
|
||||
throw parsed.error;
|
||||
}
|
||||
existing.set(file, { text, toml: parsed.data, symlink });
|
||||
}
|
||||
|
||||
return existing;
|
||||
}
|
||||
|
||||
async function tomlFiles(root: string, dir = "") {
|
||||
const result: Array<{ file: string; symlink: boolean }> = [];
|
||||
|
||||
for (const entry of await readdir(path.join(root, dir), { withFileTypes: true })) {
|
||||
const file = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
result.push(...await tomlFiles(root, file));
|
||||
} else if (entry.name.endsWith(".toml") && (entry.isFile() || entry.isSymbolicLink())) {
|
||||
result.push({ file, symlink: entry.isSymbolicLink() });
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function summarize(
|
||||
provider: { id: string; name: string },
|
||||
files: SyncResult["files"],
|
||||
unchanged: number,
|
||||
notices: string[],
|
||||
): SyncResult {
|
||||
return {
|
||||
id: provider.id,
|
||||
name: provider.name,
|
||||
status: files.length > 0 ? "changed" : "unchanged",
|
||||
created: files.filter((file) => file.status === "created").length,
|
||||
updated: files.filter((file) => file.status === "updated").length,
|
||||
deleted: files.filter((file) => file.status === "deleted").length,
|
||||
unchanged,
|
||||
notices,
|
||||
files,
|
||||
};
|
||||
}
|
||||
|
||||
function sameModel(
|
||||
relativePath: string,
|
||||
current: ExistingModel,
|
||||
desired: z.infer<typeof AuthoredModel>,
|
||||
) {
|
||||
const parsed = AuthoredModel.safeParse({
|
||||
id: relativePath.slice(0, -5),
|
||||
...current,
|
||||
});
|
||||
return parsed.success && stable(parsed.data) === stable(desired);
|
||||
}
|
||||
|
||||
function stable(value: unknown): string {
|
||||
if (Array.isArray(value)) {
|
||||
const items = value.map(stable);
|
||||
const ordered = value.every((item) => item === null || typeof item !== "object")
|
||||
? items.sort()
|
||||
: items;
|
||||
return `[${ordered.join(",")}]`;
|
||||
}
|
||||
if (value !== null && typeof value === "object") {
|
||||
return `{${Object.entries(value)
|
||||
.filter(([, item]) => item !== undefined)
|
||||
.sort(([a], [b]) => a.localeCompare(b))
|
||||
.map(([key, item]) => `${JSON.stringify(key)}:${stable(item)}`)
|
||||
.join(",")}}`;
|
||||
}
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
|
||||
async function writeReport(target: string, results: SyncResult[]) {
|
||||
await mkdir(".sync", { recursive: true });
|
||||
|
||||
const lines = [
|
||||
`Updates model TOMLs for the \`${target}\` sync target.`,
|
||||
"",
|
||||
"| Provider | Status | Created | Updated | Deleted |",
|
||||
"| --- | --- | ---: | ---: | ---: |",
|
||||
];
|
||||
|
||||
for (const result of results) {
|
||||
lines.push(
|
||||
`| ${result.name} | ${result.status} | ${result.created} | ${result.updated} | ${result.deleted} |`,
|
||||
);
|
||||
}
|
||||
|
||||
for (const result of results.filter((item) => item.files.length > 0)) {
|
||||
lines.push("", `<details><summary>${result.name} changed files</summary>`, "");
|
||||
for (const file of result.files) {
|
||||
lines.push(`- ${file.status}: \`${file.path}\``);
|
||||
}
|
||||
lines.push("", "</details>");
|
||||
}
|
||||
|
||||
const noticeResults = results.filter((item) => item.notices.length > 0);
|
||||
if (noticeResults.length > 0) {
|
||||
lines.push("", "## Notices");
|
||||
for (const result of noticeResults) {
|
||||
lines.push("", `### ${result.name}`);
|
||||
for (const notice of result.notices) {
|
||||
lines.push(`- ${notice}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lines.push("", "This PR was created automatically by the daily model sync workflow.");
|
||||
await Bun.write(".sync/model-sync-report.md", `${lines.join("\n")}\n`);
|
||||
}
|
||||
|
||||
function quote(value: string) {
|
||||
return `"${value.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
||||
}
|
||||
|
||||
function formatInteger(n: number) {
|
||||
return String(n).replace(/\B(?=(\d{3})+(?!\d))/g, "_");
|
||||
}
|
||||
|
||||
function formatNumber(n: number) {
|
||||
return Number.isInteger(n) ? formatInteger(n) : String(n);
|
||||
}
|
||||
|
||||
function formatToml(model: z.infer<typeof AuthoredModel>) {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push(`name = ${quote(model.name)}`);
|
||||
if (model.family !== undefined) lines.push(`family = ${quote(model.family)}`);
|
||||
lines.push(`release_date = ${quote(model.release_date)}`);
|
||||
lines.push(`last_updated = ${quote(model.last_updated)}`);
|
||||
lines.push(`attachment = ${model.attachment}`);
|
||||
lines.push(`reasoning = ${model.reasoning}`);
|
||||
if (model.temperature !== undefined) lines.push(`temperature = ${model.temperature}`);
|
||||
lines.push(`tool_call = ${model.tool_call}`);
|
||||
if (model.structured_output !== undefined) {
|
||||
lines.push(`structured_output = ${model.structured_output}`);
|
||||
}
|
||||
if (model.knowledge !== undefined) lines.push(`knowledge = ${quote(model.knowledge)}`);
|
||||
lines.push(`open_weights = ${model.open_weights}`);
|
||||
if (model.status !== undefined) lines.push(`status = ${quote(model.status)}`);
|
||||
|
||||
if (model.interleaved !== undefined) {
|
||||
lines.push("");
|
||||
if (model.interleaved === true) {
|
||||
lines.push("interleaved = true");
|
||||
} else {
|
||||
lines.push("[interleaved]");
|
||||
lines.push(`field = ${quote(model.interleaved.field)}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (model.cost !== undefined) {
|
||||
lines.push("", "[cost]");
|
||||
lines.push(`input = ${formatNumber(model.cost.input)}`);
|
||||
lines.push(`output = ${formatNumber(model.cost.output)}`);
|
||||
if (model.cost.reasoning !== undefined) {
|
||||
lines.push(`reasoning = ${formatNumber(model.cost.reasoning)}`);
|
||||
}
|
||||
if (model.cost.cache_read !== undefined) {
|
||||
lines.push(`cache_read = ${formatNumber(model.cost.cache_read)}`);
|
||||
}
|
||||
if (model.cost.cache_write !== undefined) {
|
||||
lines.push(`cache_write = ${formatNumber(model.cost.cache_write)}`);
|
||||
}
|
||||
if (model.cost.input_audio !== undefined) {
|
||||
lines.push(`input_audio = ${formatNumber(model.cost.input_audio)}`);
|
||||
}
|
||||
if (model.cost.output_audio !== undefined) {
|
||||
lines.push(`output_audio = ${formatNumber(model.cost.output_audio)}`);
|
||||
}
|
||||
|
||||
for (const tier of model.cost.tiers ?? []) {
|
||||
lines.push("", "[[cost.tiers]]");
|
||||
lines.push(`tier = { size = ${formatInteger(tier.tier.size)} }`);
|
||||
lines.push(`input = ${formatNumber(tier.input)}`);
|
||||
lines.push(`output = ${formatNumber(tier.output)}`);
|
||||
if (tier.reasoning !== undefined) lines.push(`reasoning = ${formatNumber(tier.reasoning)}`);
|
||||
if (tier.cache_read !== undefined) lines.push(`cache_read = ${formatNumber(tier.cache_read)}`);
|
||||
if (tier.cache_write !== undefined) lines.push(`cache_write = ${formatNumber(tier.cache_write)}`);
|
||||
}
|
||||
}
|
||||
|
||||
lines.push("", "[limit]");
|
||||
lines.push(`context = ${formatInteger(model.limit.context)}`);
|
||||
if (model.limit.input !== undefined) lines.push(`input = ${formatInteger(model.limit.input)}`);
|
||||
lines.push(`output = ${formatInteger(model.limit.output)}`);
|
||||
|
||||
lines.push("", "[modalities]");
|
||||
lines.push(`input = [${model.modalities.input.map(quote).join(", ")}]`);
|
||||
lines.push(`output = [${model.modalities.output.map(quote).join(", ")}]`);
|
||||
|
||||
return `${lines.join("\n")}\n`;
|
||||
}
|
||||
|
||||
export async function main(args = process.argv.slice(2)) {
|
||||
const target = args.find((arg) => !arg.startsWith("-")) ?? "aggregators";
|
||||
const results = await syncTargets(target, {
|
||||
dryRun: args.includes("--dry-run"),
|
||||
newOnly: args.includes("--new-only"),
|
||||
});
|
||||
|
||||
await writeReport(target, results);
|
||||
|
||||
console.log("\nSync summary");
|
||||
for (const result of results) {
|
||||
console.log(
|
||||
`${result.name}: ${result.created} created, ${result.updated} updated, ${result.deleted} deleted`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (import.meta.main) await main();
|
||||
await main();
|
||||
@@ -1,144 +0,0 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { ModelFamilyValues } from "../../src/family.js";
|
||||
import type { ExistingModel, SyncProvider } from "../sync-models.js";
|
||||
|
||||
const API_ENDPOINT = "https://openrouter.ai/api/v1/models";
|
||||
|
||||
export const OpenRouterModel = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
created: z.number(),
|
||||
hugging_face_id: z.string().nullable(),
|
||||
knowledge_cutoff: z.string().nullable(),
|
||||
context_length: z.number(),
|
||||
architecture: z.object({
|
||||
input_modalities: z.array(z.string()),
|
||||
output_modalities: z.array(z.string()),
|
||||
}),
|
||||
pricing: z.object({
|
||||
prompt: z.string(),
|
||||
completion: z.string(),
|
||||
internal_reasoning: z.string().optional(),
|
||||
input_cache_read: z.string().optional(),
|
||||
input_cache_write: z.string().optional(),
|
||||
}),
|
||||
top_provider: z.object({
|
||||
context_length: z.number().nullable(),
|
||||
max_completion_tokens: z.number().nullable(),
|
||||
}),
|
||||
supported_parameters: z.array(z.string()),
|
||||
});
|
||||
|
||||
export const OpenRouterResponse = z.object({
|
||||
data: z.array(OpenRouterModel),
|
||||
}).passthrough();
|
||||
|
||||
export type OpenRouterModel = z.infer<typeof OpenRouterModel>;
|
||||
|
||||
export const openrouter = {
|
||||
id: "openrouter",
|
||||
name: "OpenRouter",
|
||||
modelsDir: "providers/openrouter/models",
|
||||
async fetchModels() {
|
||||
const headers = process.env.OPENROUTER_API_KEY
|
||||
? { Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}` }
|
||||
: undefined;
|
||||
const response = await fetch(API_ENDPOINT, { headers });
|
||||
if (!response.ok) {
|
||||
throw new Error(`OpenRouter request failed: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
return response.json();
|
||||
},
|
||||
parseModels(raw) {
|
||||
return OpenRouterResponse.parse(raw).data;
|
||||
},
|
||||
translateModel(model, context) {
|
||||
return {
|
||||
id: model.id,
|
||||
model: buildOpenRouterModel(model, context.existing(model.id)),
|
||||
};
|
||||
},
|
||||
} satisfies SyncProvider<OpenRouterModel>;
|
||||
|
||||
function dateFromTimestamp(timestamp: number) {
|
||||
return new Date(timestamp * 1000).toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
function price(value: string | undefined) {
|
||||
if (value === undefined) return undefined;
|
||||
const number = Number(value);
|
||||
return Number.isFinite(number) && number >= 0
|
||||
? Math.round(number * 1_000_000_000_000) / 1_000_000
|
||||
: undefined;
|
||||
}
|
||||
|
||||
type Modality = "text" | "audio" | "image" | "video" | "pdf";
|
||||
|
||||
function modalities(values: string[], fallback: Modality[]): Modality[] {
|
||||
const allowed = new Set<Modality>(["text", "audio", "image", "video", "pdf"]);
|
||||
const result = values
|
||||
.map((value) => value.toLowerCase())
|
||||
.map((value) => value === "file" ? "pdf" : value)
|
||||
.filter((value): value is Modality => allowed.has(value as Modality));
|
||||
return [...new Set(result.length > 0 ? result : fallback)];
|
||||
}
|
||||
|
||||
function inferFamily(model: OpenRouterModel, name: string) {
|
||||
const target = `${model.id} ${name}`.toLowerCase();
|
||||
return [...ModelFamilyValues]
|
||||
.sort((a, b) => b.length - a.length)
|
||||
.find((family) => {
|
||||
const value = family.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
if (family === "o") {
|
||||
return new RegExp(`(^|[^a-z0-9])${value}(?=\\d|$|[^a-z0-9])`).test(target);
|
||||
}
|
||||
return new RegExp(`(^|[^a-z0-9])${value}(?=$|[^a-z0-9])`).test(target);
|
||||
});
|
||||
}
|
||||
|
||||
export function buildOpenRouterModel(model: OpenRouterModel, existing: ExistingModel | undefined) {
|
||||
const params = new Set(model.supported_parameters);
|
||||
const name = model.name.replace(/^[^:]+:\s+/, "");
|
||||
const input = modalities(model.architecture.input_modalities, ["text"]);
|
||||
const output = modalities(model.architecture.output_modalities, ["text"]);
|
||||
const prompt = price(model.pricing.prompt);
|
||||
const completion = price(model.pricing.completion);
|
||||
const reasoning = params.has("reasoning") || params.has("include_reasoning");
|
||||
const context = model.top_provider.context_length ?? model.context_length;
|
||||
const family = inferFamily(model, name);
|
||||
|
||||
return {
|
||||
name,
|
||||
family: existing?.family === "o" && family !== "o"
|
||||
? family
|
||||
: (existing?.family ?? family),
|
||||
release_date: dateFromTimestamp(model.created),
|
||||
last_updated: dateFromTimestamp(model.created),
|
||||
attachment: input.some((value) => value !== "text"),
|
||||
reasoning,
|
||||
temperature: params.has("temperature"),
|
||||
tool_call: params.has("tools") || params.has("tool_choice"),
|
||||
structured_output: params.has("structured_outputs"),
|
||||
knowledge: model.knowledge_cutoff?.slice(0, 10) ?? existing?.knowledge,
|
||||
open_weights: Boolean(model.hugging_face_id),
|
||||
status: existing?.status,
|
||||
interleaved: existing?.interleaved,
|
||||
cost: prompt !== undefined && completion !== undefined
|
||||
? {
|
||||
input: prompt,
|
||||
output: completion,
|
||||
reasoning: reasoning ? price(model.pricing.internal_reasoning) : undefined,
|
||||
cache_read: price(model.pricing.input_cache_read),
|
||||
cache_write: price(model.pricing.input_cache_write),
|
||||
tiers: existing?.cost?.tiers,
|
||||
}
|
||||
: existing?.cost,
|
||||
limit: {
|
||||
context,
|
||||
input: existing?.limit?.input,
|
||||
output: model.top_provider.max_completion_tokens ?? existing?.limit?.output ?? context,
|
||||
},
|
||||
modalities: { input, output },
|
||||
};
|
||||
}
|
||||
@@ -49,6 +49,7 @@ export const ModelFamilyValues = [
|
||||
"qwen",
|
||||
"qwen3.5",
|
||||
"qwen3.6",
|
||||
"qwen3.7-max",
|
||||
"qwen-free",
|
||||
|
||||
// DeepSeek
|
||||
@@ -116,6 +117,8 @@ export const ModelFamilyValues = [
|
||||
"minimax",
|
||||
"minimax-m2.5",
|
||||
"minimax-m2.7",
|
||||
"minimax-m3",
|
||||
"minimax-m3-free",
|
||||
"minimax-free",
|
||||
|
||||
// Hunyuan
|
||||
@@ -215,6 +218,7 @@ export const ModelFamilyValues = [
|
||||
"mimo-v2-omni",
|
||||
"mimo-v2.5-pro",
|
||||
"mimo-v2.5",
|
||||
"mimo-v2.5-free",
|
||||
"mimo-pro-free",
|
||||
"mimo-omni-free",
|
||||
"mimo-flash-free",
|
||||
|
||||
@@ -81,6 +81,19 @@ export async function generate(directory: string) {
|
||||
result[providerID] = provider.data;
|
||||
}
|
||||
|
||||
const nameToProviderID = new Map<string, string>();
|
||||
for (const provider of Object.values(result)) {
|
||||
const nameKey = provider.name.toLowerCase();
|
||||
const existingID = nameToProviderID.get(nameKey);
|
||||
if (existingID !== undefined) {
|
||||
throw new Error(
|
||||
`Duplicate provider name "${provider.name}" used by both "${existingID}" and "${provider.id}". Provider names must be unique.`,
|
||||
{ cause: { providerIDs: [existingID, provider.id], name: provider.name } },
|
||||
);
|
||||
}
|
||||
nameToProviderID.set(nameKey, provider.id);
|
||||
}
|
||||
|
||||
for (const pendingModel of extendsModels) {
|
||||
const [providerID, modelID] = pendingModel.model.extends.from.split("/");
|
||||
const baseModel = result[providerID]?.models[modelID];
|
||||
|
||||
+54
-27
@@ -21,31 +21,53 @@ const JsonValue: z.ZodType<JsonValue> = z.lazy(() =>
|
||||
]),
|
||||
);
|
||||
|
||||
const Cost = z
|
||||
.object({
|
||||
input: z.number().min(0, "Input price cannot be negative"),
|
||||
output: z.number().min(0, "Output price cannot be negative"),
|
||||
reasoning: z
|
||||
.number()
|
||||
.min(0, "Reasoning price cannot be negative")
|
||||
.optional(),
|
||||
cache_read: z
|
||||
.number()
|
||||
.min(0, "Cache read price cannot be negative")
|
||||
.optional(),
|
||||
cache_write: z
|
||||
.number()
|
||||
.min(0, "Cache write price cannot be negative")
|
||||
.optional(),
|
||||
input_audio: z
|
||||
.number()
|
||||
.min(0, "Audio input price cannot be negative")
|
||||
.optional(),
|
||||
output_audio: z
|
||||
.number()
|
||||
.min(0, "Audio output price cannot be negative")
|
||||
.optional(),
|
||||
});
|
||||
const ReasoningOption = z.discriminatedUnion("type", [
|
||||
z
|
||||
.object({
|
||||
type: z.literal("effort"),
|
||||
values: z.array(z.enum(["none", "low", "medium", "high", "xhigh", "max"])),
|
||||
})
|
||||
.strict(),
|
||||
z
|
||||
.object({
|
||||
type: z.literal("budget_tokens"),
|
||||
min: z.number().min(0, "Minimum reasoning budget cannot be negative").optional(),
|
||||
max: z.number().min(0, "Maximum reasoning budget cannot be negative").optional(),
|
||||
})
|
||||
.strict(),
|
||||
]).refine(
|
||||
(data) =>
|
||||
data.type !== "budget_tokens" ||
|
||||
data.min === undefined ||
|
||||
data.max === undefined ||
|
||||
data.min <= data.max,
|
||||
{
|
||||
message: "Minimum reasoning budget cannot exceed maximum reasoning budget",
|
||||
path: ["min"],
|
||||
},
|
||||
);
|
||||
|
||||
const Cost = z.object({
|
||||
input: z.number().min(0, "Input price cannot be negative"),
|
||||
output: z.number().min(0, "Output price cannot be negative"),
|
||||
reasoning: z.number().min(0, "Reasoning price cannot be negative").optional(),
|
||||
cache_read: z
|
||||
.number()
|
||||
.min(0, "Cache read price cannot be negative")
|
||||
.optional(),
|
||||
cache_write: z
|
||||
.number()
|
||||
.min(0, "Cache write price cannot be negative")
|
||||
.optional(),
|
||||
input_audio: z
|
||||
.number()
|
||||
.min(0, "Audio input price cannot be negative")
|
||||
.optional(),
|
||||
output_audio: z
|
||||
.number()
|
||||
.min(0, "Audio output price cannot be negative")
|
||||
.optional(),
|
||||
});
|
||||
|
||||
const CostTier = Cost.extend({
|
||||
tier: z
|
||||
@@ -72,6 +94,7 @@ const ModelBase = z.object({
|
||||
family: ModelFamily.optional(),
|
||||
attachment: z.boolean(),
|
||||
reasoning: z.boolean(),
|
||||
reasoning_options: z.array(ReasoningOption).optional(),
|
||||
tool_call: z.boolean(),
|
||||
interleaved: z
|
||||
.union([
|
||||
@@ -140,7 +163,9 @@ function refineModel<T extends z.ZodTypeAny>(schema: T) {
|
||||
return schema
|
||||
.refine(
|
||||
(data) => {
|
||||
return !(data.reasoning === false && data.cost?.reasoning !== undefined);
|
||||
return !(
|
||||
data.reasoning === false && data.cost?.reasoning !== undefined
|
||||
);
|
||||
},
|
||||
{
|
||||
message: "Cannot set cost.reasoning when reasoning is false",
|
||||
@@ -152,7 +177,9 @@ function refineModel<T extends z.ZodTypeAny>(schema: T) {
|
||||
const tiers = data.cost?.tiers;
|
||||
if (tiers === undefined) return true;
|
||||
|
||||
const sizes = tiers.map((tier: { tier: { size: number } }) => tier.tier.size);
|
||||
const sizes = tiers.map(
|
||||
(tier: { tier: { size: number } }) => tier.tier.size,
|
||||
);
|
||||
return new Set(sizes).size === sizes.length;
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,484 @@
|
||||
import path from "node:path";
|
||||
import { mkdir, readdir, rm } from "node:fs/promises";
|
||||
import { z } from "zod";
|
||||
|
||||
import { AuthoredModel, AuthoredModelShape } from "../schema.js";
|
||||
import { cloudflareWorkersAi } from "./providers/cloudflare-workers-ai.js";
|
||||
import { google } from "./providers/google.js";
|
||||
import { openrouter } from "./providers/openrouter.js";
|
||||
import { ovhcloud } from "./providers/ovhcloud.js";
|
||||
import { xai } from "./providers/xai.js";
|
||||
|
||||
const ExtendsConfig = z
|
||||
.object({
|
||||
from: z.string(),
|
||||
omit: z.array(z.string()).optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
const ExistingExtendsConfig = z
|
||||
.object({
|
||||
from: z.string(),
|
||||
omit: z.array(z.string()).optional(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
const ExistingModel = AuthoredModelShape.partial()
|
||||
.extend({
|
||||
extends: ExistingExtendsConfig.optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
const SyncedExtendsModel = AuthoredModelShape.partial()
|
||||
.extend({
|
||||
id: z.string(),
|
||||
extends: ExtendsConfig,
|
||||
})
|
||||
.strict();
|
||||
|
||||
const SyncedAuthoredModel = z.union([AuthoredModel, SyncedExtendsModel]);
|
||||
|
||||
export type ExistingModel = z.infer<typeof ExistingModel>;
|
||||
export type SyncedFullModel = Omit<z.infer<typeof AuthoredModelShape>, "id">;
|
||||
export type SyncedExtendsModel = Omit<z.infer<typeof SyncedExtendsModel>, "id">;
|
||||
export type SyncedModel = SyncedFullModel | SyncedExtendsModel;
|
||||
|
||||
export interface SyncProvider<SourceModel> {
|
||||
id: string;
|
||||
name: string;
|
||||
modelsDir: string;
|
||||
skipCreates?: boolean;
|
||||
sourceID?(model: SourceModel): string;
|
||||
skippedNotice?(ids: string[]): string[];
|
||||
fetchModels(): Promise<unknown>;
|
||||
parseModels(raw: unknown): SourceModel[];
|
||||
translateModel(
|
||||
model: SourceModel,
|
||||
context: { existing(id: string): ExistingModel | undefined },
|
||||
): { id: string; model: SyncedModel } | undefined;
|
||||
}
|
||||
|
||||
export interface SyncResult {
|
||||
id: string;
|
||||
name: string;
|
||||
status: "changed" | "unchanged";
|
||||
created: number;
|
||||
updated: number;
|
||||
deleted: number;
|
||||
unchanged: number;
|
||||
notices: string[];
|
||||
files: Array<{ status: "created" | "updated" | "deleted"; path: string }>;
|
||||
}
|
||||
|
||||
export const providers: {
|
||||
"cloudflare-workers-ai": SyncProvider<any>;
|
||||
google: SyncProvider<any>;
|
||||
openrouter: SyncProvider<any>;
|
||||
ovhcloud: SyncProvider<any>;
|
||||
xai: SyncProvider<any>;
|
||||
} = {
|
||||
"cloudflare-workers-ai": cloudflareWorkersAi,
|
||||
google,
|
||||
openrouter,
|
||||
ovhcloud,
|
||||
xai,
|
||||
};
|
||||
|
||||
export const groups = {
|
||||
aggregators: ["openrouter"],
|
||||
cloudflare: ["cloudflare-workers-ai"],
|
||||
direct: ["google", "ovhcloud", "xai"],
|
||||
} as const;
|
||||
|
||||
type ProviderID = keyof typeof providers;
|
||||
|
||||
interface SyncOptions {
|
||||
dryRun?: boolean;
|
||||
newOnly?: boolean;
|
||||
}
|
||||
|
||||
export async function syncProviderByID(id: ProviderID, options: SyncOptions = {}) {
|
||||
return syncProvider(providers[id], options);
|
||||
}
|
||||
|
||||
export async function syncProvider<SourceModel>(
|
||||
provider: SyncProvider<SourceModel>,
|
||||
options: SyncOptions = {},
|
||||
): Promise<SyncResult> {
|
||||
console.log(`\nSyncing ${provider.name}...`);
|
||||
|
||||
const existing = await readExisting(provider.modelsDir);
|
||||
const sourceModels = provider.parseModels(await provider.fetchModels());
|
||||
const desired = new Map<string, { model: z.infer<typeof SyncedAuthoredModel>; content: string }>();
|
||||
const skippedRemote: string[] = [];
|
||||
|
||||
for (const sourceModel of sourceModels) {
|
||||
const translated = provider.translateModel(sourceModel, {
|
||||
existing(id) {
|
||||
return existing.get(`${id}.toml`)?.toml;
|
||||
},
|
||||
});
|
||||
if (translated === undefined) {
|
||||
if (provider.skipCreates) skippedRemote.push(provider.sourceID?.(sourceModel) ?? "unknown");
|
||||
continue;
|
||||
}
|
||||
|
||||
const relativePath = `${translated.id}.toml`;
|
||||
if (provider.skipCreates && !existing.has(relativePath)) {
|
||||
skippedRemote.push(translated.id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (desired.has(relativePath)) {
|
||||
throw new Error(`Duplicate synced model path: ${provider.id}/${relativePath}`);
|
||||
}
|
||||
|
||||
const parsed = SyncedAuthoredModel.safeParse({
|
||||
id: translated.id,
|
||||
...translated.model,
|
||||
});
|
||||
if (!parsed.success) {
|
||||
parsed.error.cause = { provider: provider.id, path: relativePath };
|
||||
throw parsed.error;
|
||||
}
|
||||
|
||||
desired.set(relativePath, {
|
||||
model: parsed.data,
|
||||
content: formatToml(parsed.data),
|
||||
});
|
||||
}
|
||||
|
||||
const files: SyncResult["files"] = [];
|
||||
let unchanged = 0;
|
||||
|
||||
for (const [relativePath, file] of desired) {
|
||||
const filePath = path.join(provider.modelsDir, relativePath);
|
||||
const current = existing.get(relativePath);
|
||||
|
||||
if (current === undefined) {
|
||||
files.push({ status: "created", path: filePath });
|
||||
if (options.dryRun) {
|
||||
console.log(`Would create ${relativePath}`);
|
||||
} else {
|
||||
await mkdir(path.dirname(filePath), { recursive: true });
|
||||
await Bun.write(filePath, file.content);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!sameModel(relativePath, current.toml, file.model)) {
|
||||
if (options.newOnly) {
|
||||
unchanged++;
|
||||
continue;
|
||||
}
|
||||
|
||||
files.push({ status: "updated", path: filePath });
|
||||
if (options.dryRun) {
|
||||
console.log(`Would update ${relativePath}`);
|
||||
} else {
|
||||
if (current.symlink) await rm(filePath, { force: true });
|
||||
await Bun.write(filePath, file.content);
|
||||
}
|
||||
} else {
|
||||
unchanged++;
|
||||
}
|
||||
}
|
||||
|
||||
for (const relativePath of existing.keys()) {
|
||||
if (desired.has(relativePath)) continue;
|
||||
if (options.newOnly) {
|
||||
console.log(`Skipping removal in new-only mode: ${relativePath}`);
|
||||
unchanged++;
|
||||
continue;
|
||||
}
|
||||
|
||||
const filePath = path.join(provider.modelsDir, relativePath);
|
||||
files.push({ status: "deleted", path: filePath });
|
||||
if (options.dryRun) {
|
||||
console.log(`Would remove ${relativePath}`);
|
||||
} else {
|
||||
await rm(filePath, { force: true });
|
||||
}
|
||||
}
|
||||
|
||||
const result = summarize(provider, files, unchanged, provider.skippedNotice?.(skippedRemote) ?? []);
|
||||
console.log(
|
||||
`${options.dryRun ? "Dry run: " : ""}${result.created} created, ${result.updated} updated, ${result.deleted} removed, ${result.unchanged} unchanged`,
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function syncTargets(target: string, options: SyncOptions = {}) {
|
||||
const ids = target in groups
|
||||
? groups[target as keyof typeof groups]
|
||||
: target in providers
|
||||
? [target as ProviderID]
|
||||
: undefined;
|
||||
|
||||
if (ids === undefined) {
|
||||
throw new Error(`Unknown sync target: ${target}`);
|
||||
}
|
||||
|
||||
const results: SyncResult[] = [];
|
||||
for (const id of ids) {
|
||||
results.push(await syncProviderByID(id as ProviderID, options));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
export function syncProviderMatrix() {
|
||||
return {
|
||||
include: Object.values(providers).map((provider) => ({
|
||||
provider: provider.id,
|
||||
name: provider.name,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
async function readExisting(modelsDir: string) {
|
||||
const existing = new Map<string, { text: string; toml: ExistingModel; symlink: boolean }>();
|
||||
|
||||
for (const { file, symlink } of await tomlFiles(modelsDir)) {
|
||||
const text = await Bun.file(path.join(modelsDir, file)).text();
|
||||
const parsed = ExistingModel.safeParse(Bun.TOML.parse(text));
|
||||
if (!parsed.success) {
|
||||
parsed.error.cause = { path: path.join(modelsDir, file) };
|
||||
throw parsed.error;
|
||||
}
|
||||
existing.set(file, { text, toml: parsed.data, symlink });
|
||||
}
|
||||
|
||||
return existing;
|
||||
}
|
||||
|
||||
async function tomlFiles(root: string, dir = "") {
|
||||
const result: Array<{ file: string; symlink: boolean }> = [];
|
||||
|
||||
for (const entry of await readdir(path.join(root, dir), { withFileTypes: true })) {
|
||||
const file = path.join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
result.push(...await tomlFiles(root, file));
|
||||
} else if (entry.name.endsWith(".toml") && (entry.isFile() || entry.isSymbolicLink())) {
|
||||
result.push({ file, symlink: entry.isSymbolicLink() });
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function summarize(
|
||||
provider: { id: string; name: string },
|
||||
files: SyncResult["files"],
|
||||
unchanged: number,
|
||||
notices: string[],
|
||||
): SyncResult {
|
||||
return {
|
||||
id: provider.id,
|
||||
name: provider.name,
|
||||
status: files.length > 0 ? "changed" : "unchanged",
|
||||
created: files.filter((file) => file.status === "created").length,
|
||||
updated: files.filter((file) => file.status === "updated").length,
|
||||
deleted: files.filter((file) => file.status === "deleted").length,
|
||||
unchanged,
|
||||
notices,
|
||||
files,
|
||||
};
|
||||
}
|
||||
|
||||
function sameModel(
|
||||
relativePath: string,
|
||||
current: ExistingModel,
|
||||
desired: z.infer<typeof SyncedAuthoredModel>,
|
||||
) {
|
||||
const parsed = SyncedAuthoredModel.safeParse({
|
||||
id: relativePath.slice(0, -5),
|
||||
...current,
|
||||
});
|
||||
return parsed.success && stable(parsed.data) === stable(desired);
|
||||
}
|
||||
|
||||
function stable(value: unknown): string {
|
||||
if (Array.isArray(value)) {
|
||||
const items = value.map(stable);
|
||||
const ordered = value.every((item) => item === null || typeof item !== "object")
|
||||
? items.sort()
|
||||
: items;
|
||||
return `[${ordered.join(",")}]`;
|
||||
}
|
||||
if (value !== null && typeof value === "object") {
|
||||
return `{${Object.entries(value)
|
||||
.filter(([, item]) => item !== undefined)
|
||||
.sort(([a], [b]) => a.localeCompare(b))
|
||||
.map(([key, item]) => `${JSON.stringify(key)}:${stable(item)}`)
|
||||
.join(",")}}`;
|
||||
}
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
|
||||
async function writeReport(target: string, results: SyncResult[]) {
|
||||
await mkdir(".sync", { recursive: true });
|
||||
|
||||
const lines = [
|
||||
`Updates model TOMLs for the \`${target}\` sync target.`,
|
||||
"",
|
||||
"| Provider | Status | Created | Updated | Deleted |",
|
||||
"| --- | --- | ---: | ---: | ---: |",
|
||||
];
|
||||
|
||||
for (const result of results) {
|
||||
lines.push(
|
||||
`| ${result.name} | ${result.status} | ${result.created} | ${result.updated} | ${result.deleted} |`,
|
||||
);
|
||||
}
|
||||
|
||||
for (const result of results.filter((item) => item.files.length > 0)) {
|
||||
lines.push("", `<details><summary>${result.name} changed files</summary>`, "");
|
||||
for (const file of result.files) {
|
||||
lines.push(`- ${file.status}: \`${file.path}\``);
|
||||
}
|
||||
lines.push("", "</details>");
|
||||
}
|
||||
|
||||
const noticeResults = results.filter((item) => item.notices.length > 0);
|
||||
if (noticeResults.length > 0) {
|
||||
lines.push("", "## Notices");
|
||||
for (const result of noticeResults) {
|
||||
lines.push("", `### ${result.name}`);
|
||||
for (const notice of result.notices) {
|
||||
lines.push(`- ${notice}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lines.push("", "This PR was created automatically by the daily model sync workflow.");
|
||||
await Bun.write(".sync/model-sync-report.md", `${lines.join("\n")}\n`);
|
||||
}
|
||||
|
||||
function quote(value: string) {
|
||||
return `"${value.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
|
||||
}
|
||||
|
||||
function formatInteger(n: number) {
|
||||
return String(n).replace(/\B(?=(\d{3})+(?!\d))/g, "_");
|
||||
}
|
||||
|
||||
function formatNumber(n: number) {
|
||||
return Number.isInteger(n) ? formatInteger(n) : String(n);
|
||||
}
|
||||
|
||||
function formatToml(model: z.infer<typeof SyncedAuthoredModel>) {
|
||||
const lines: string[] = [];
|
||||
const extendsLines: string[] = [];
|
||||
|
||||
if ("extends" in model) {
|
||||
extendsLines.push("[extends]");
|
||||
extendsLines.push(`from = ${quote(model.extends.from)}`);
|
||||
if (model.extends.omit !== undefined) {
|
||||
extendsLines.push(`omit = [${model.extends.omit.map(quote).join(", ")}]`);
|
||||
}
|
||||
}
|
||||
|
||||
if (model.name !== undefined) lines.push(`name = ${quote(model.name)}`);
|
||||
if (model.family !== undefined) lines.push(`family = ${quote(model.family)}`);
|
||||
if (model.release_date !== undefined) lines.push(`release_date = ${quote(model.release_date)}`);
|
||||
if (model.last_updated !== undefined) lines.push(`last_updated = ${quote(model.last_updated)}`);
|
||||
if (model.attachment !== undefined) lines.push(`attachment = ${model.attachment}`);
|
||||
if (model.reasoning !== undefined) lines.push(`reasoning = ${model.reasoning}`);
|
||||
if (model.temperature !== undefined) lines.push(`temperature = ${model.temperature}`);
|
||||
if (model.tool_call !== undefined) lines.push(`tool_call = ${model.tool_call}`);
|
||||
if (model.structured_output !== undefined) {
|
||||
lines.push(`structured_output = ${model.structured_output}`);
|
||||
}
|
||||
if (model.knowledge !== undefined) lines.push(`knowledge = ${quote(model.knowledge)}`);
|
||||
if (model.open_weights !== undefined) lines.push(`open_weights = ${model.open_weights}`);
|
||||
if (model.status !== undefined) lines.push(`status = ${quote(model.status)}`);
|
||||
|
||||
if (extendsLines.length > 0) {
|
||||
if (lines.length > 0) lines.push("");
|
||||
lines.push(...extendsLines);
|
||||
}
|
||||
|
||||
if (model.interleaved !== undefined) {
|
||||
lines.push("");
|
||||
if (model.interleaved === true) {
|
||||
lines.push("interleaved = true");
|
||||
} else {
|
||||
lines.push("[interleaved]");
|
||||
lines.push(`field = ${quote(model.interleaved.field)}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (model.cost !== undefined) {
|
||||
lines.push("", "[cost]");
|
||||
lines.push(`input = ${formatNumber(model.cost.input)}`);
|
||||
lines.push(`output = ${formatNumber(model.cost.output)}`);
|
||||
if (model.cost.reasoning !== undefined) {
|
||||
lines.push(`reasoning = ${formatNumber(model.cost.reasoning)}`);
|
||||
}
|
||||
if (model.cost.cache_read !== undefined) {
|
||||
lines.push(`cache_read = ${formatNumber(model.cost.cache_read)}`);
|
||||
}
|
||||
if (model.cost.cache_write !== undefined) {
|
||||
lines.push(`cache_write = ${formatNumber(model.cost.cache_write)}`);
|
||||
}
|
||||
if (model.cost.input_audio !== undefined) {
|
||||
lines.push(`input_audio = ${formatNumber(model.cost.input_audio)}`);
|
||||
}
|
||||
if (model.cost.output_audio !== undefined) {
|
||||
lines.push(`output_audio = ${formatNumber(model.cost.output_audio)}`);
|
||||
}
|
||||
|
||||
for (const tier of model.cost.tiers ?? []) {
|
||||
lines.push("", "[[cost.tiers]]");
|
||||
lines.push(`tier = { size = ${formatInteger(tier.tier.size)} }`);
|
||||
lines.push(`input = ${formatNumber(tier.input)}`);
|
||||
lines.push(`output = ${formatNumber(tier.output)}`);
|
||||
if (tier.reasoning !== undefined) lines.push(`reasoning = ${formatNumber(tier.reasoning)}`);
|
||||
if (tier.cache_read !== undefined) lines.push(`cache_read = ${formatNumber(tier.cache_read)}`);
|
||||
if (tier.cache_write !== undefined) lines.push(`cache_write = ${formatNumber(tier.cache_write)}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (model.limit !== undefined) {
|
||||
lines.push("", "[limit]");
|
||||
if (model.limit.context !== undefined) lines.push(`context = ${formatInteger(model.limit.context)}`);
|
||||
if (model.limit.input !== undefined) lines.push(`input = ${formatInteger(model.limit.input)}`);
|
||||
if (model.limit.output !== undefined) lines.push(`output = ${formatInteger(model.limit.output)}`);
|
||||
}
|
||||
|
||||
if (model.modalities !== undefined) {
|
||||
lines.push("", "[modalities]");
|
||||
if (model.modalities.input !== undefined) {
|
||||
lines.push(`input = [${model.modalities.input.map(quote).join(", ")}]`);
|
||||
}
|
||||
if (model.modalities.output !== undefined) {
|
||||
lines.push(`output = [${model.modalities.output.map(quote).join(", ")}]`);
|
||||
}
|
||||
}
|
||||
|
||||
return `${lines.join("\n")}\n`;
|
||||
}
|
||||
|
||||
export async function main(args = process.argv.slice(2)) {
|
||||
if (args.includes("--list-providers")) {
|
||||
console.log(JSON.stringify(syncProviderMatrix()));
|
||||
return;
|
||||
}
|
||||
|
||||
const target = args.find((arg) => !arg.startsWith("-")) ?? "aggregators";
|
||||
const results = await syncTargets(target, {
|
||||
dryRun: args.includes("--dry-run"),
|
||||
newOnly: args.includes("--new-only"),
|
||||
});
|
||||
|
||||
await writeReport(target, results);
|
||||
|
||||
console.log("\nSync summary");
|
||||
for (const result of results) {
|
||||
console.log(
|
||||
`${result.name}: ${result.created} created, ${result.updated} updated, ${result.deleted} deleted`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (import.meta.main) await main();
|
||||
+6
-4
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import type { ExistingModel, SyncProvider } from "../sync-models.js";
|
||||
import type { ExistingModel, SyncProvider } from "../index.js";
|
||||
import {
|
||||
buildOpenRouterModel,
|
||||
OpenRouterModel,
|
||||
@@ -48,10 +48,12 @@ export const cloudflareWorkersAi = {
|
||||
name: "Cloudflare Workers AI",
|
||||
modelsDir: "providers/cloudflare-workers-ai/models",
|
||||
async fetchModels() {
|
||||
const accountID = process.env.CLOUDFLARE_ACCOUNT_ID;
|
||||
const token = process.env.CLOUDFLARE_API_TOKEN ?? process.env.CLOUDFLARE_API_KEY;
|
||||
const accountID = process.env.CLOUDFLARE_WORKERS_AI_SYNC_ACCOUNT_ID;
|
||||
const token = process.env.CLOUDFLARE_WORKERS_AI_SYNC_API_TOKEN;
|
||||
if (accountID === undefined || token === undefined) {
|
||||
throw new Error("Cloudflare Workers AI sync requires CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN");
|
||||
throw new Error(
|
||||
"Cloudflare Workers AI sync requires CLOUDFLARE_WORKERS_AI_SYNC_ACCOUNT_ID and CLOUDFLARE_WORKERS_AI_SYNC_API_TOKEN",
|
||||
);
|
||||
}
|
||||
|
||||
const first = await fetchPage(accountID, token, 1);
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import type { ExistingModel, SyncProvider, SyncedModel } from "../sync-models.js";
|
||||
import type { ExistingModel, SyncProvider, SyncedModel } from "../index.js";
|
||||
|
||||
const API_ENDPOINT = "https://generativelanguage.googleapis.com/v1beta/models";
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
import { z } from "zod";
|
||||
import { readFileSync, readdirSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import { ModelFamilyValues } from "../../family.js";
|
||||
import type { ExistingModel, SyncProvider, SyncedFullModel, SyncedModel } from "../index.js";
|
||||
|
||||
const API_ENDPOINT = "https://openrouter.ai/api/v1/models";
|
||||
const PROVIDERS_DIR = path.join(import.meta.dirname, "..", "..", "..", "..", "..", "providers");
|
||||
const modelFilesByProvider = new Map<string, Set<string>>();
|
||||
const canonicalTomlByModel = new Map<string, Record<string, unknown>>();
|
||||
|
||||
const CANONICAL_PROVIDER_PREFIXES = {
|
||||
anthropic: "anthropic",
|
||||
cohere: "cohere",
|
||||
deepseek: "deepseek",
|
||||
google: "google",
|
||||
meta: "llama",
|
||||
"meta-llama": "llama",
|
||||
minimax: "minimax",
|
||||
mistralai: "mistral",
|
||||
moonshotai: "moonshotai",
|
||||
openai: "openai",
|
||||
"x-ai": "xai",
|
||||
xai: "xai",
|
||||
xiaomi: "xiaomi",
|
||||
zai: "zai",
|
||||
"z-ai": "zai",
|
||||
} as const;
|
||||
|
||||
export const OpenRouterModel = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
created: z.number(),
|
||||
hugging_face_id: z.string().nullable(),
|
||||
knowledge_cutoff: z.string().nullable(),
|
||||
context_length: z.number(),
|
||||
architecture: z.object({
|
||||
input_modalities: z.array(z.string()),
|
||||
output_modalities: z.array(z.string()),
|
||||
}),
|
||||
pricing: z.object({
|
||||
prompt: z.string(),
|
||||
completion: z.string(),
|
||||
internal_reasoning: z.string().optional(),
|
||||
input_cache_read: z.string().optional(),
|
||||
input_cache_write: z.string().optional(),
|
||||
}),
|
||||
top_provider: z.object({
|
||||
context_length: z.number().nullable(),
|
||||
max_completion_tokens: z.number().nullable(),
|
||||
}),
|
||||
supported_parameters: z.array(z.string()),
|
||||
});
|
||||
|
||||
export const OpenRouterResponse = z.object({
|
||||
data: z.array(OpenRouterModel),
|
||||
}).passthrough();
|
||||
|
||||
export type OpenRouterModel = z.infer<typeof OpenRouterModel>;
|
||||
|
||||
export const openrouter = {
|
||||
id: "openrouter",
|
||||
name: "OpenRouter",
|
||||
modelsDir: "providers/openrouter/models",
|
||||
async fetchModels() {
|
||||
const headers = process.env.OPENROUTER_API_KEY
|
||||
? { Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}` }
|
||||
: undefined;
|
||||
const response = await fetch(API_ENDPOINT, { headers });
|
||||
if (!response.ok) {
|
||||
throw new Error(`OpenRouter request failed: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
return response.json();
|
||||
},
|
||||
parseModels(raw) {
|
||||
return OpenRouterResponse.parse(raw).data;
|
||||
},
|
||||
translateModel(model, context) {
|
||||
return {
|
||||
id: model.id,
|
||||
model: buildOpenRouterModel(model, context.existing(model.id)),
|
||||
};
|
||||
},
|
||||
} satisfies SyncProvider<OpenRouterModel>;
|
||||
|
||||
function dateFromTimestamp(timestamp: number) {
|
||||
return new Date(timestamp * 1000).toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
function price(value: string | undefined) {
|
||||
if (value === undefined) return undefined;
|
||||
const number = Number(value);
|
||||
return Number.isFinite(number) && number >= 0
|
||||
? Math.round(number * 1_000_000_000_000) / 1_000_000
|
||||
: undefined;
|
||||
}
|
||||
|
||||
type Modality = "text" | "audio" | "image" | "video" | "pdf";
|
||||
|
||||
function modalities(values: string[], fallback: Modality[]): Modality[] {
|
||||
const allowed = new Set<Modality>(["text", "audio", "image", "video", "pdf"]);
|
||||
const result = values
|
||||
.map((value) => value.toLowerCase())
|
||||
.map((value) => value === "file" ? "pdf" : value)
|
||||
.filter((value): value is Modality => allowed.has(value as Modality));
|
||||
return [...new Set(result.length > 0 ? result : fallback)];
|
||||
}
|
||||
|
||||
function inferFamily(model: OpenRouterModel, name: string) {
|
||||
const target = `${model.id} ${name}`.toLowerCase();
|
||||
return [...ModelFamilyValues]
|
||||
.sort((a, b) => b.length - a.length)
|
||||
.find((family) => {
|
||||
const value = family.toLowerCase().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
if (family === "o") {
|
||||
return new RegExp(`(^|[^a-z0-9])${value}(?=\\d|$|[^a-z0-9])`).test(target);
|
||||
}
|
||||
return new RegExp(`(^|[^a-z0-9])${value}(?=$|[^a-z0-9])`).test(target);
|
||||
});
|
||||
}
|
||||
|
||||
export function buildOpenRouterModel(model: OpenRouterModel, existing: ExistingModel | undefined): SyncedModel {
|
||||
const params = new Set(model.supported_parameters);
|
||||
const name = model.name.replace(/^[^:]+:\s+/, "");
|
||||
const input = modalities(model.architecture.input_modalities, ["text"]);
|
||||
const output = modalities(model.architecture.output_modalities, ["text"]);
|
||||
const prompt = price(model.pricing.prompt);
|
||||
const completion = price(model.pricing.completion);
|
||||
const reasoning = params.has("reasoning") || params.has("include_reasoning");
|
||||
const context = model.top_provider.context_length ?? model.context_length;
|
||||
const family = inferFamily(model, name);
|
||||
const releaseDate = dateFromTimestamp(model.created);
|
||||
const familyValue = existing?.family === "o" && family !== "o"
|
||||
? family
|
||||
: (existing?.family ?? family);
|
||||
const attachment = input.some((value) => value !== "text");
|
||||
const toolCall = params.has("tools") || params.has("tool_choice");
|
||||
const structuredOutput = params.has("structured_outputs");
|
||||
const knowledge = model.knowledge_cutoff?.slice(0, 10) ?? existing?.knowledge;
|
||||
const openWeights = Boolean(model.hugging_face_id);
|
||||
const cost = prompt !== undefined && completion !== undefined
|
||||
? {
|
||||
input: prompt,
|
||||
output: completion,
|
||||
reasoning: reasoning ? price(model.pricing.internal_reasoning) : undefined,
|
||||
cache_read: price(model.pricing.input_cache_read),
|
||||
cache_write: price(model.pricing.input_cache_write),
|
||||
tiers: existing?.cost?.tiers,
|
||||
}
|
||||
: existing?.cost;
|
||||
const limit = {
|
||||
context,
|
||||
input: existing?.limit?.input,
|
||||
output: model.top_provider.max_completion_tokens ?? existing?.limit?.output ?? context,
|
||||
};
|
||||
const canonical = resolveCanonicalModel(model.id);
|
||||
|
||||
if (canonical !== undefined) {
|
||||
return {
|
||||
extends: {
|
||||
from: canonical.from,
|
||||
omit: canonicalOmit(canonical.provider, canonical.modelID, cost, limit),
|
||||
},
|
||||
...canonicalRuntimeOverrides(canonical.provider, canonical.modelID, {
|
||||
name: model.id.endsWith(":free") ? name : undefined,
|
||||
attachment,
|
||||
reasoning,
|
||||
}),
|
||||
temperature: params.has("temperature"),
|
||||
tool_call: toolCall,
|
||||
structured_output: structuredOutput,
|
||||
status: existing?.status,
|
||||
interleaved: existing?.interleaved,
|
||||
cost,
|
||||
limit,
|
||||
modalities: { input, output },
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
name,
|
||||
family: familyValue,
|
||||
release_date: releaseDate,
|
||||
last_updated: releaseDate,
|
||||
attachment,
|
||||
reasoning,
|
||||
temperature: params.has("temperature"),
|
||||
tool_call: toolCall,
|
||||
structured_output: structuredOutput,
|
||||
knowledge,
|
||||
open_weights: openWeights,
|
||||
status: existing?.status,
|
||||
interleaved: existing?.interleaved,
|
||||
cost,
|
||||
limit,
|
||||
modalities: { input, output },
|
||||
} satisfies SyncedFullModel;
|
||||
}
|
||||
|
||||
function resolveCanonicalModel(openrouterID: string) {
|
||||
const [prefix, ...modelParts] = openrouterID.split("/");
|
||||
if (prefix === undefined || modelParts.length === 0) return undefined;
|
||||
if (openrouterID.startsWith("~/") || prefix.startsWith("~")) return undefined;
|
||||
|
||||
const provider = CANONICAL_PROVIDER_PREFIXES[prefix as keyof typeof CANONICAL_PROVIDER_PREFIXES];
|
||||
if (provider === undefined) return undefined;
|
||||
|
||||
const modelID = modelParts.join("/").replace(/:free$/, "");
|
||||
const candidates = canonicalCandidates(provider, modelID);
|
||||
const match = candidates.find((candidate) => {
|
||||
return canonicalModelExists(provider, candidate);
|
||||
});
|
||||
|
||||
return match === undefined
|
||||
? undefined
|
||||
: {
|
||||
from: `${provider}/${match}`,
|
||||
provider,
|
||||
modelID: match,
|
||||
};
|
||||
}
|
||||
|
||||
function canonicalModelExists(provider: string, modelID: string) {
|
||||
let files = modelFilesByProvider.get(provider);
|
||||
if (files === undefined) {
|
||||
try {
|
||||
files = new Set(readdirSync(path.join(PROVIDERS_DIR, provider, "models")));
|
||||
} catch {
|
||||
files = new Set();
|
||||
}
|
||||
modelFilesByProvider.set(provider, files);
|
||||
}
|
||||
return files.has(`${modelID}.toml`);
|
||||
}
|
||||
|
||||
function canonicalOmit(
|
||||
provider: string,
|
||||
modelID: string,
|
||||
cost: SyncedFullModel["cost"],
|
||||
limit: SyncedFullModel["limit"],
|
||||
) {
|
||||
const toml = canonicalToml(provider, modelID);
|
||||
const omit = ["provider", "experimental"].filter((key) => toml[key] !== undefined);
|
||||
|
||||
const baseCost = toml.cost;
|
||||
if (baseCost !== undefined && baseCost !== null && typeof baseCost === "object" && !Array.isArray(baseCost)) {
|
||||
if (cost === undefined) {
|
||||
omit.push("cost");
|
||||
} else {
|
||||
for (const key of ["reasoning", "cache_read", "cache_write", "input_audio", "output_audio", "tiers"] as const) {
|
||||
if ((baseCost as Record<string, unknown>)[key] !== undefined && cost[key] === undefined) {
|
||||
omit.push(`cost.${key}`);
|
||||
}
|
||||
}
|
||||
if (hasLegacyContextOver200k(baseCost) && cost.tiers === undefined) {
|
||||
omit.push("cost.context_over_200k");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const baseLimit = toml.limit;
|
||||
if (
|
||||
baseLimit !== undefined &&
|
||||
baseLimit !== null &&
|
||||
typeof baseLimit === "object" &&
|
||||
!Array.isArray(baseLimit) &&
|
||||
(baseLimit as Record<string, unknown>).input !== undefined &&
|
||||
limit.input === undefined
|
||||
) {
|
||||
omit.push("limit.input");
|
||||
}
|
||||
|
||||
return omit.length > 0 ? omit : undefined;
|
||||
}
|
||||
|
||||
function hasLegacyContextOver200k(cost: object) {
|
||||
const tiers = (cost as { tiers?: unknown }).tiers;
|
||||
if (!Array.isArray(tiers) || tiers.length !== 1) return false;
|
||||
|
||||
const tier = tiers[0];
|
||||
if (tier === null || typeof tier !== "object" || Array.isArray(tier)) return false;
|
||||
const tierConfig = (tier as { tier?: unknown }).tier;
|
||||
if (tierConfig === null || typeof tierConfig !== "object" || Array.isArray(tierConfig)) return false;
|
||||
|
||||
const size = (tierConfig as { size?: unknown }).size;
|
||||
return typeof size === "number" && size >= 200_000;
|
||||
}
|
||||
|
||||
function canonicalRuntimeOverrides(
|
||||
provider: string,
|
||||
modelID: string,
|
||||
values: Pick<SyncedFullModel, "name" | "attachment" | "reasoning">,
|
||||
) {
|
||||
const toml = canonicalToml(provider, modelID);
|
||||
return Object.fromEntries(
|
||||
Object.entries(values).filter(([key, value]) => value !== undefined && toml[key] !== value),
|
||||
);
|
||||
}
|
||||
|
||||
function canonicalToml(provider: string, modelID: string) {
|
||||
const key = `${provider}/${modelID}`;
|
||||
let toml = canonicalTomlByModel.get(key);
|
||||
if (toml === undefined) {
|
||||
const filePath = path.join(PROVIDERS_DIR, provider, "models", `${modelID}.toml`);
|
||||
toml = Bun.TOML.parse(readFileSync(filePath, "utf8")) as Record<string, unknown>;
|
||||
canonicalTomlByModel.set(key, toml);
|
||||
}
|
||||
return toml;
|
||||
}
|
||||
|
||||
function canonicalCandidates(provider: string, modelID: string) {
|
||||
const candidates = [modelID];
|
||||
|
||||
if (provider === "anthropic") {
|
||||
candidates.push(modelID.replace(/(claude-(?:opus|sonnet|haiku)-\d+)\.(\d+)/, "$1-$2"));
|
||||
candidates.push(modelID.replace(/^claude-3\.5-/, "claude-3-5-"));
|
||||
}
|
||||
|
||||
if (provider === "llama") {
|
||||
candidates.push(modelID.replace(/^llama-(\d+)-(\d+)/, "llama-$1.$2"));
|
||||
candidates.push(modelID.replace(/^llama-(4)-(maverick|scout)$/, "llama-$1-$2-17b"));
|
||||
}
|
||||
|
||||
if (provider === "mistral") {
|
||||
candidates.push(modelID.replace(/-latest$/, ""));
|
||||
}
|
||||
|
||||
if (provider === "minimax") {
|
||||
candidates.push(modelID.replace(/^minimax-m/, "MiniMax-M"));
|
||||
}
|
||||
|
||||
return [...new Set(candidates)];
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import type { ExistingModel, SyncedFullModel, SyncProvider, SyncedModel } from "../index.js";
|
||||
|
||||
const API_ENDPOINT = "https://catalog.endpoints.ai.ovh.net/rest/v2/openrouter";
|
||||
|
||||
export const OvhcloudModel = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
created: z.number(),
|
||||
hugging_face_id: z.string().nullable().optional(),
|
||||
context_length: z.number(),
|
||||
max_output_length: z.number().optional(),
|
||||
input_modalities: z.array(z.string()).optional(),
|
||||
output_modalities: z.array(z.string()).optional(),
|
||||
pricing: z
|
||||
.object({
|
||||
prompt: z.string().optional(),
|
||||
completion: z.string().optional(),
|
||||
input_cache_reads: z.string().optional(),
|
||||
input_cache_writes: z.string().optional(),
|
||||
})
|
||||
.passthrough()
|
||||
.optional(),
|
||||
supported_features: z.array(z.string()).optional(),
|
||||
supported_sampling_parameters: z.array(z.string()).optional(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
export const OvhcloudResponse = z
|
||||
.object({
|
||||
data: z.array(OvhcloudModel),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
export type OvhcloudModel = z.infer<typeof OvhcloudModel>;
|
||||
|
||||
export const ovhcloud = {
|
||||
id: "ovhcloud",
|
||||
name: "OVHcloud AI Endpoints",
|
||||
modelsDir: "providers/ovhcloud/models",
|
||||
async fetchModels() {
|
||||
const response = await fetch(API_ENDPOINT);
|
||||
if (!response.ok) {
|
||||
throw new Error(`OVHcloud request failed: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
return response.json();
|
||||
},
|
||||
parseModels(raw) {
|
||||
return OvhcloudResponse.parse(raw).data;
|
||||
},
|
||||
translateModel(model, context) {
|
||||
return {
|
||||
id: model.id.toLowerCase(),
|
||||
model: buildOvhcloudModel(model, context.existing(model.id.toLowerCase())),
|
||||
};
|
||||
},
|
||||
} satisfies SyncProvider<OvhcloudModel>;
|
||||
|
||||
function dateFromTimestamp(timestamp: number) {
|
||||
return new Date(timestamp * 1000).toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
function price(value: string | undefined) {
|
||||
if (value === undefined) return undefined;
|
||||
const number = Number(value);
|
||||
return Number.isFinite(number) && number >= 0
|
||||
? Math.round(number * 1_000_000_000_000) / 1_000_000
|
||||
: undefined;
|
||||
}
|
||||
|
||||
type Modality = "text" | "audio" | "image" | "video" | "pdf";
|
||||
|
||||
function modalities(values: string[], fallback: Modality[]): Modality[] {
|
||||
const allowed = new Set<Modality>(["text", "audio", "image", "video", "pdf"]);
|
||||
const result = values
|
||||
.map((value) => value.toLowerCase())
|
||||
.map((value) => (value === "file" ? "pdf" : value))
|
||||
.filter((value): value is Modality => allowed.has(value as Modality));
|
||||
return [...new Set(result.length > 0 ? result : fallback)];
|
||||
}
|
||||
|
||||
export function buildOvhcloudModel(
|
||||
model: OvhcloudModel,
|
||||
existing: ExistingModel | undefined,
|
||||
): SyncedModel {
|
||||
const features = new Set(model.supported_features ?? []);
|
||||
const samplingParameters = new Set(model.supported_sampling_parameters ?? []);
|
||||
const input = modalities(model.input_modalities ?? ["text"], ["text"]);
|
||||
const output = modalities(model.output_modalities ?? ["text"], ["text"]);
|
||||
const attachment = input.some((value) => value !== "text");
|
||||
const reasoning = features.has("reasoning");
|
||||
const toolCall = features.has("tools");
|
||||
const structuredOutput = features.has("structured_outputs");
|
||||
const temperature = samplingParameters.has("temperature");
|
||||
const openWeights = Boolean(model.hugging_face_id);
|
||||
const releaseDate = existing?.release_date ?? dateFromTimestamp(model.created);
|
||||
const lastUpdated = existing?.last_updated ?? releaseDate;
|
||||
|
||||
const inputCost = price(model.pricing?.prompt);
|
||||
const outputCost = price(model.pricing?.completion);
|
||||
const cacheRead = price(model.pricing?.input_cache_reads);
|
||||
const cacheWrite = price(model.pricing?.input_cache_writes);
|
||||
const cost =
|
||||
(inputCost ?? 0) > 0 || (outputCost ?? 0) > 0
|
||||
? {
|
||||
input: inputCost ?? 0,
|
||||
output: outputCost ?? 0,
|
||||
cache_read: cacheRead !== undefined && cacheRead > 0 ? cacheRead : undefined,
|
||||
cache_write: cacheWrite !== undefined && cacheWrite > 0 ? cacheWrite : undefined,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
name: model.name,
|
||||
family: existing?.family,
|
||||
release_date: releaseDate,
|
||||
last_updated: lastUpdated,
|
||||
attachment,
|
||||
reasoning,
|
||||
temperature: temperature || undefined,
|
||||
tool_call: toolCall,
|
||||
structured_output: structuredOutput || undefined,
|
||||
knowledge: existing?.knowledge,
|
||||
open_weights: openWeights,
|
||||
status: existing?.status,
|
||||
interleaved: existing?.interleaved,
|
||||
cost,
|
||||
limit: {
|
||||
context: model.context_length,
|
||||
input: existing?.limit?.input,
|
||||
output: model.max_output_length ?? existing?.limit?.output ?? model.context_length,
|
||||
},
|
||||
modalities: { input, output },
|
||||
} satisfies SyncedFullModel;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import type { ExistingModel, SyncProvider, SyncedModel } from "../sync-models.js";
|
||||
import type { ExistingModel, SyncProvider, SyncedModel } from "../index.js";
|
||||
|
||||
const API_BASE = "https://api.x.ai/v1";
|
||||
|
||||
@@ -137,6 +137,11 @@ function tokenPrice(value: number | undefined) {
|
||||
return value / 10_000;
|
||||
}
|
||||
|
||||
function preservedCostTiers(existing: ExistingModel) {
|
||||
// The xAI models API exposes base pricing only; long-context tiers are curated from xAI docs/console.
|
||||
return existing.cost?.tiers;
|
||||
}
|
||||
|
||||
function cost(model: XAIModel, existing: ExistingModel) {
|
||||
const input = tokenPrice(model.prompt_text_token_price);
|
||||
const output = tokenPrice(model.completion_text_token_price);
|
||||
@@ -150,7 +155,7 @@ function cost(model: XAIModel, existing: ExistingModel) {
|
||||
cache_write: existing.cost?.cache_write,
|
||||
input_audio: existing.cost?.input_audio,
|
||||
output_audio: existing.cost?.output_audio,
|
||||
tiers: existing.cost?.tiers,
|
||||
tiers: preservedCostTiers(existing),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
[extends]
|
||||
from = "alibaba/qwen3.6-flash"
|
||||
@@ -0,0 +1,2 @@
|
||||
[extends]
|
||||
from = "alibaba/qwen3.7-max"
|
||||
@@ -0,0 +1,2 @@
|
||||
[extends]
|
||||
from = "alibaba/qwen3.6-flash"
|
||||
@@ -0,0 +1,2 @@
|
||||
[extends]
|
||||
from = "alibaba/qwen3.7-max"
|
||||
@@ -0,0 +1,2 @@
|
||||
[extends]
|
||||
from = "alibaba/qwen3.6-flash"
|
||||
@@ -0,0 +1,2 @@
|
||||
[extends]
|
||||
from = "alibaba/qwen3.7-max"
|
||||
@@ -0,0 +1,23 @@
|
||||
name = "Qwen3.6 Flash"
|
||||
family = "qwen3.6"
|
||||
release_date = "2026-04-27"
|
||||
last_updated = "2026-04-27"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 0.1875
|
||||
output = 1.125
|
||||
cache_write = 0.234375
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 65_536
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "video"]
|
||||
output = ["text"]
|
||||
@@ -0,0 +1,23 @@
|
||||
name = "Qwen3.7 Max"
|
||||
family = "qwen"
|
||||
release_date = "2026-05-21"
|
||||
last_updated = "2026-05-21"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 2.50
|
||||
output = 7.50
|
||||
cache_read = 0.50
|
||||
cache_write = 3.125
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 65_536
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -0,0 +1,3 @@
|
||||
[extends]
|
||||
from = "anthropic/claude-opus-4-8"
|
||||
omit = ["experimental.modes.fast"]
|
||||
@@ -0,0 +1,5 @@
|
||||
name = "Claude Opus 4.8 (AU)"
|
||||
|
||||
[extends]
|
||||
from = "anthropic/claude-opus-4-8"
|
||||
omit = ["experimental.modes.fast"]
|
||||
@@ -4,3 +4,9 @@ structured_output = true
|
||||
[extends]
|
||||
from = "anthropic/claude-opus-4-6"
|
||||
omit = ["experimental.modes.fast"]
|
||||
|
||||
[cost]
|
||||
input = 5.50
|
||||
output = 27.50
|
||||
cache_read = 0.55
|
||||
cache_write = 6.875
|
||||
@@ -10,10 +10,10 @@ knowledge = "2026-01-31"
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 5.00
|
||||
output = 25.00
|
||||
cache_read = 0.50
|
||||
cache_write = 6.25
|
||||
input = 5.50
|
||||
output = 27.50
|
||||
cache_read = 0.55
|
||||
cache_write = 6.875
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
name = "Claude Opus 4.8 (EU)"
|
||||
|
||||
[extends]
|
||||
from = "anthropic/claude-opus-4-8"
|
||||
omit = ["experimental.modes.fast"]
|
||||
|
||||
[cost]
|
||||
input = 5.50
|
||||
output = 27.50
|
||||
cache_read = 0.55
|
||||
cache_write = 6.875
|
||||
@@ -11,10 +11,10 @@ knowledge = "2025-07-31"
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 3.00
|
||||
output = 15.00
|
||||
cache_read = 0.30
|
||||
cache_write = 3.75
|
||||
input = 3.30
|
||||
output = 16.50
|
||||
cache_read = 0.33
|
||||
cache_write = 4.125
|
||||
|
||||
[limit]
|
||||
context = 200_000
|
||||
|
||||
@@ -3,3 +3,9 @@ structured_output = true
|
||||
|
||||
[extends]
|
||||
from = "anthropic/claude-sonnet-4-6"
|
||||
|
||||
[cost]
|
||||
input = 3.30
|
||||
output = 16.50
|
||||
cache_read = 0.33
|
||||
cache_write = 4.125
|
||||
@@ -0,0 +1,5 @@
|
||||
name = "Claude Opus 4.8 (Global)"
|
||||
|
||||
[extends]
|
||||
from = "anthropic/claude-opus-4-8"
|
||||
omit = ["experimental.modes.fast"]
|
||||
@@ -0,0 +1,5 @@
|
||||
name = "Claude Opus 4.8 (JP)"
|
||||
|
||||
[extends]
|
||||
from = "anthropic/claude-opus-4-8"
|
||||
omit = ["experimental.modes.fast"]
|
||||
@@ -0,0 +1,5 @@
|
||||
name = "Claude Opus 4.8 (US)"
|
||||
|
||||
[extends]
|
||||
from = "anthropic/claude-opus-4-8"
|
||||
omit = ["experimental.modes.fast"]
|
||||
@@ -9,6 +9,10 @@ tool_call = true
|
||||
knowledge = "2024-10-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 3.00
|
||||
output = 15.00
|
||||
|
||||
@@ -9,6 +9,10 @@ tool_call = true
|
||||
knowledge = "2025-02-28"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 1.00
|
||||
output = 5.00
|
||||
|
||||
@@ -9,6 +9,10 @@ tool_call = true
|
||||
knowledge = "2025-02-28"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 1.00
|
||||
output = 5.00
|
||||
|
||||
@@ -9,6 +9,10 @@ tool_call = true
|
||||
knowledge = "2025-03-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 15.00
|
||||
output = 75.00
|
||||
|
||||
@@ -9,6 +9,10 @@ tool_call = true
|
||||
knowledge = "2025-03-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 15.00
|
||||
output = 75.00
|
||||
|
||||
@@ -9,6 +9,10 @@ tool_call = true
|
||||
knowledge = "2025-03-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 15.00
|
||||
output = 75.00
|
||||
|
||||
@@ -9,6 +9,10 @@ tool_call = true
|
||||
knowledge = "2025-03-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 15.00
|
||||
output = 75.00
|
||||
|
||||
@@ -9,6 +9,14 @@ tool_call = true
|
||||
knowledge = "2025-03-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "effort"
|
||||
values = ["low", "medium", "high"]
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 5.00
|
||||
output = 25.00
|
||||
|
||||
@@ -9,6 +9,14 @@ tool_call = true
|
||||
knowledge = "2025-03-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "effort"
|
||||
values = ["low", "medium", "high"]
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 5.00
|
||||
output = 25.00
|
||||
|
||||
@@ -9,6 +9,14 @@ tool_call = true
|
||||
knowledge = "2025-05-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "effort"
|
||||
values = ["low", "medium", "high", "max"]
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 5.00
|
||||
output = 25.00
|
||||
|
||||
@@ -9,6 +9,10 @@ tool_call = true
|
||||
knowledge = "2026-01-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "effort"
|
||||
values = ["low", "medium", "high", "xhigh", "max"]
|
||||
|
||||
[cost]
|
||||
input = 5.00
|
||||
output = 25.00
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
name = "Claude Opus 4.8"
|
||||
family = "claude-opus"
|
||||
release_date = "2026-05-28"
|
||||
last_updated = "2026-05-28"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "effort"
|
||||
values = ["low", "medium", "high", "xhigh", "max"]
|
||||
|
||||
[cost]
|
||||
input = 5.00
|
||||
output = 25.00
|
||||
cache_read = 0.50
|
||||
cache_write = 6.25
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "pdf"]
|
||||
output = ["text"]
|
||||
|
||||
[experimental.modes.fast]
|
||||
cost = { input = 10.00, output = 50.00, cache_read = 1.00, cache_write = 12.50 }
|
||||
provider = { body = { speed = "fast" }, headers = { anthropic-beta = "fast-mode-2026-02-01" } }
|
||||
@@ -9,6 +9,10 @@ tool_call = true
|
||||
knowledge = "2025-03-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 3.00
|
||||
output = 15.00
|
||||
|
||||
@@ -9,6 +9,10 @@ tool_call = true
|
||||
knowledge = "2025-03-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 3.00
|
||||
output = 15.00
|
||||
|
||||
@@ -9,6 +9,10 @@ tool_call = true
|
||||
knowledge = "2025-07-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 3.00
|
||||
output = 15.00
|
||||
|
||||
@@ -9,6 +9,10 @@ tool_call = true
|
||||
knowledge = "2025-07-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 3.00
|
||||
output = 15.00
|
||||
|
||||
@@ -9,6 +9,14 @@ tool_call = true
|
||||
knowledge = "2025-08-31"
|
||||
open_weights = false
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "effort"
|
||||
values = ["low", "medium", "high", "max"]
|
||||
|
||||
[[reasoning_options]]
|
||||
type = "budget_tokens"
|
||||
min = 1_024
|
||||
|
||||
[cost]
|
||||
input = 3.00
|
||||
output = 15.00
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[extends]
|
||||
from = "anthropic/claude-opus-4-8"
|
||||
omit = ["experimental.modes.fast"]
|
||||
@@ -1,22 +0,0 @@
|
||||
name = "Gemma 3 12B It"
|
||||
family = "gemma"
|
||||
release_date = "2025-03-18"
|
||||
last_updated = "2025-03-18"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = false
|
||||
structured_output = false
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.345
|
||||
output = 0.556
|
||||
|
||||
[limit]
|
||||
context = 80_000
|
||||
output = 80_000
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,22 +0,0 @@
|
||||
name = "Llama 2 7B Chat fp16"
|
||||
family = "llama"
|
||||
release_date = "2023-11-07"
|
||||
last_updated = "2023-11-07"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = false
|
||||
structured_output = false
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.556
|
||||
output = 6.667
|
||||
|
||||
[limit]
|
||||
context = 4_096
|
||||
output = 4_096
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,22 +0,0 @@
|
||||
name = "Llama 3 8B Instruct"
|
||||
family = "llama"
|
||||
release_date = "2024-04-18"
|
||||
last_updated = "2024-04-18"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = false
|
||||
structured_output = false
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.282
|
||||
output = 0.827
|
||||
|
||||
[limit]
|
||||
context = 7_968
|
||||
output = 7_968
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,22 +0,0 @@
|
||||
name = "Llama 3.1 8B Instruct Awq"
|
||||
family = "llama"
|
||||
release_date = "2024-07-25"
|
||||
last_updated = "2024-07-25"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = false
|
||||
structured_output = false
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.123
|
||||
output = 0.266
|
||||
|
||||
[limit]
|
||||
context = 8_192
|
||||
output = 8_192
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,22 +0,0 @@
|
||||
name = "Mistral 7B Instruct V0.1"
|
||||
family = "mistral"
|
||||
release_date = "2023-11-07"
|
||||
last_updated = "2023-11-07"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = false
|
||||
structured_output = false
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.11
|
||||
output = 0.19
|
||||
|
||||
[limit]
|
||||
context = 2_824
|
||||
output = 2_824
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,27 +0,0 @@
|
||||
name = "Kimi K2.5"
|
||||
family = "kimi"
|
||||
release_date = "2026-01-27"
|
||||
last_updated = "2026-01-27"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
structured_output = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
knowledge = "2025-01"
|
||||
open_weights = true
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0.60
|
||||
output = 3.00
|
||||
cache_read = 0.10
|
||||
|
||||
[limit]
|
||||
context = 256_000
|
||||
output = 256_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
+9
-9
@@ -1,22 +1,22 @@
|
||||
name = "Qwen 3 235B Instruct"
|
||||
family = "qwen"
|
||||
name = "DeepSeek V3.2"
|
||||
family = "deepseek"
|
||||
release_date = "2025-07-22"
|
||||
last_updated = "2025-07-22"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
knowledge = "2025-04"
|
||||
tool_call = true
|
||||
open_weights = true
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 0.6
|
||||
output = 1.2
|
||||
input = 0.18
|
||||
output = 0.35
|
||||
cache_read = 0.04
|
||||
|
||||
[limit]
|
||||
context = 131_000
|
||||
output = 32_000
|
||||
context = 163_840
|
||||
output = 163_840
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
output = ["text"]
|
||||
@@ -0,0 +1,14 @@
|
||||
[extends]
|
||||
from = "deepseek/deepseek-v4-flash"
|
||||
|
||||
[cost]
|
||||
input = 0.12
|
||||
output = 0.21
|
||||
cache_read = 0.003
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 131_072
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
@@ -0,0 +1,14 @@
|
||||
[extends]
|
||||
from = "deepseek/deepseek-v4-pro"
|
||||
|
||||
[cost]
|
||||
input = 0.80
|
||||
output = 1.60
|
||||
cache_read = 0.02
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 131_072
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
@@ -0,0 +1,14 @@
|
||||
[extends]
|
||||
from = "deepseek/deepseek-v4-pro"
|
||||
|
||||
[cost]
|
||||
input = 0.35
|
||||
output = 0.80
|
||||
cache_read = 0.003
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 131_072
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
@@ -0,0 +1,14 @@
|
||||
[extends]
|
||||
from = "google/gemma-4-31b-it"
|
||||
|
||||
[cost]
|
||||
input = 0.10
|
||||
output = 0.30
|
||||
cache_read = 0.02
|
||||
|
||||
[limit]
|
||||
context = 262_144
|
||||
output = 262_144
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
@@ -0,0 +1,14 @@
|
||||
[extends]
|
||||
from = "zhipuai/glm-4.7-flash"
|
||||
|
||||
[cost]
|
||||
input = 0.04
|
||||
output = 0.30
|
||||
cache_read = 0.008
|
||||
|
||||
[limit]
|
||||
context = 202_752
|
||||
output = 131_072
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
@@ -0,0 +1,14 @@
|
||||
[extends]
|
||||
from = "zhipuai/glm-4.7"
|
||||
|
||||
[cost]
|
||||
input = 0.25
|
||||
output = 1.10
|
||||
cache_read = 0.05
|
||||
|
||||
[limit]
|
||||
context = 202_752
|
||||
output = 202_752
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
@@ -0,0 +1,14 @@
|
||||
[extends]
|
||||
from = "zhipuai/glm-5.1"
|
||||
|
||||
[cost]
|
||||
input = 0.45
|
||||
output = 2.15
|
||||
cache_read = 0.08
|
||||
|
||||
[limit]
|
||||
context = 202_752
|
||||
output = 202_752
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
@@ -0,0 +1,14 @@
|
||||
[extends]
|
||||
from = "zhipuai/glm-5"
|
||||
|
||||
[cost]
|
||||
input = 0.48
|
||||
output = 1.90
|
||||
cache_read = 0.10
|
||||
|
||||
[limit]
|
||||
context = 202_752
|
||||
output = 202_752
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
+8
-9
@@ -1,21 +1,20 @@
|
||||
name = "Trinity Large Preview"
|
||||
family = "trinity"
|
||||
name = "Greg 1 Mini"
|
||||
release_date = "2026-01-27"
|
||||
last_updated = "2026-01-27"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = true
|
||||
tool_call = false
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 0.15
|
||||
output = 0.45
|
||||
input = 0.07
|
||||
output = 0.15
|
||||
cache_read = 0.01
|
||||
|
||||
[limit]
|
||||
context = 131_000
|
||||
output = 131_000
|
||||
context = 229_376
|
||||
output = 229_376
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
@@ -0,0 +1,21 @@
|
||||
name = "Greg 1 Super"
|
||||
release_date = "2026-01-27"
|
||||
last_updated = "2026-01-27"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = false
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 1.00
|
||||
output = 5.00
|
||||
cache_read = 0.20
|
||||
|
||||
[limit]
|
||||
context = 229_376
|
||||
output = 229_376
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,21 +1,20 @@
|
||||
name = "Kimi K2 Instruct"
|
||||
family = "kimi"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
tool_call = true
|
||||
temperature = true
|
||||
open_weights = true
|
||||
knowledge = "2024-04"
|
||||
name = "Greg 1 Normal"
|
||||
release_date = "2026-01-27"
|
||||
last_updated = "2026-01-27"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = false
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 0.55
|
||||
output = 2.75
|
||||
input = 0.10
|
||||
output = 0.30
|
||||
cache_read = 0.02
|
||||
|
||||
[limit]
|
||||
context = 254_000
|
||||
output = 32_768
|
||||
context = 229_376
|
||||
output = 229_376
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
@@ -0,0 +1,21 @@
|
||||
name = "Greg (Roleplay)"
|
||||
release_date = "2026-01-27"
|
||||
last_updated = "2026-01-27"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = false
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 0.10
|
||||
output = 0.30
|
||||
cache_read = 0.02
|
||||
|
||||
[limit]
|
||||
context = 229_376
|
||||
output = 229_376
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -0,0 +1,26 @@
|
||||
name = "Kimi K2.5 (Lightning)"
|
||||
family = "kimi-k2.5"
|
||||
release_date = "2026-02-06"
|
||||
last_updated = "2026-02-06"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = false
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = true
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 1.00
|
||||
output = 3.00
|
||||
cache_read = 0.20
|
||||
|
||||
[limit]
|
||||
context = 131_072
|
||||
output = 32_768
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "video"]
|
||||
output = ["text"]
|
||||
@@ -0,0 +1,14 @@
|
||||
[extends]
|
||||
from = "moonshotai/kimi-k2.5"
|
||||
|
||||
[cost]
|
||||
input = 0.35
|
||||
output = 1.70
|
||||
cache_read = 0.07
|
||||
|
||||
[limit]
|
||||
context = 262_144
|
||||
output = 262_144
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
@@ -0,0 +1,10 @@
|
||||
[extends]
|
||||
from = "moonshotai/kimi-k2.6"
|
||||
|
||||
[cost]
|
||||
input = 0.50
|
||||
output = 1.99
|
||||
cache_read = 0.05
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
@@ -0,0 +1,10 @@
|
||||
[extends]
|
||||
from = "xiaomi/mimo-v2.5-pro"
|
||||
|
||||
[cost]
|
||||
input = 0.40
|
||||
output = 0.80
|
||||
cache_read = 0.003
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
@@ -0,0 +1,16 @@
|
||||
reasoning = false
|
||||
|
||||
[extends]
|
||||
from = "minimax/MiniMax-M2.5"
|
||||
|
||||
[cost]
|
||||
input = 0.11
|
||||
output = 0.95
|
||||
cache_read = 0.02
|
||||
|
||||
[limit]
|
||||
context = 204_800
|
||||
output = 131_072
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
@@ -0,0 +1,14 @@
|
||||
[extends]
|
||||
from = "alibaba/qwen3.5-397b-a17b"
|
||||
|
||||
[cost]
|
||||
input = 0.35
|
||||
output = 1.75
|
||||
cache_read = 0.07
|
||||
|
||||
[limit]
|
||||
context = 262_144
|
||||
output = 262_144
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
@@ -0,0 +1,26 @@
|
||||
name = "Qwen3.5 9B"
|
||||
family = "qwen"
|
||||
release_date = "2026-03-13"
|
||||
last_updated = "2026-03-13"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = true
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0.04
|
||||
output = 0.15
|
||||
cache_read = 0.008
|
||||
|
||||
[limit]
|
||||
context = 262_144
|
||||
output = 262_144
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "video", "audio"]
|
||||
output = ["text"]
|
||||
@@ -0,0 +1,14 @@
|
||||
[extends]
|
||||
from = "alibaba/qwen3.6-27b"
|
||||
|
||||
[cost]
|
||||
input = 0.20
|
||||
output = 1.50
|
||||
cache_read = 0.04
|
||||
|
||||
[limit]
|
||||
context = 262_144
|
||||
output = 262_144
|
||||
|
||||
[provider]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
@@ -0,0 +1,5 @@
|
||||
name = "CrofAI"
|
||||
env = ["CROF_API_KEY"]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
api = "https://crof.ai/v1"
|
||||
doc = "https://crof.ai/docs"
|
||||
@@ -16,7 +16,7 @@ field = "reasoning_content"
|
||||
[cost]
|
||||
input = 0.14
|
||||
output = 0.28
|
||||
cache_read = 0.028
|
||||
cache_read = 0.0028
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
|
||||
@@ -14,9 +14,9 @@ open_weights = true
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 1.74
|
||||
output = 3.48
|
||||
cache_read = 0.145
|
||||
input = 0.435
|
||||
output = 0.87
|
||||
cache_read = 0.003625
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
name = "Claude Opus 4.8"
|
||||
family = "claude-opus"
|
||||
release_date = "2026-05-28"
|
||||
last_updated = "2026-05-29"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 5.00
|
||||
output = 25.00
|
||||
cache_read = 0.50
|
||||
cache_write = 6.25
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
@@ -0,0 +1,17 @@
|
||||
name = "Deepseek V4 Flash"
|
||||
family = "deepseek"
|
||||
release_date = "2026-05-27"
|
||||
last_updated = "2026-05-29"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
|
||||
[limit]
|
||||
context = 262_144
|
||||
output = 8_192
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,22 +0,0 @@
|
||||
name = "DeepSeek V3.1"
|
||||
family = "deepseek"
|
||||
release_date = "2025-08-21"
|
||||
last_updated = "2025-08-21"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
knowledge = "2025-07"
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.56
|
||||
output = 1.68
|
||||
|
||||
[limit]
|
||||
context = 163_840
|
||||
output = 163_840
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,26 +0,0 @@
|
||||
name = "DeepSeek V3.2"
|
||||
family = "deepseek"
|
||||
release_date = "2025-12-01"
|
||||
last_updated = "2025-12-01"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
knowledge = "2025-09"
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.56
|
||||
output = 1.68
|
||||
cache_read = 0.28
|
||||
|
||||
[limit]
|
||||
context = 160_000
|
||||
output = 160_000
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
@@ -4,4 +4,4 @@ from = "deepseek/deepseek-v4-pro"
|
||||
[cost]
|
||||
input = 1.74
|
||||
output = 3.48
|
||||
cache_read = 0.15
|
||||
cache_read = 0.145
|
||||
@@ -1,22 +0,0 @@
|
||||
name = "GLM 4.5 Air"
|
||||
family = "glm-air"
|
||||
release_date = "2025-08-01"
|
||||
last_updated = "2025-08-01"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
knowledge = "2025-04"
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.22
|
||||
output = 0.88
|
||||
|
||||
[limit]
|
||||
context = 131_072
|
||||
output = 131_072
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,25 +0,0 @@
|
||||
name = "GLM 4.5"
|
||||
family = "glm"
|
||||
release_date = "2025-07-29"
|
||||
last_updated = "2025-07-29"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
knowledge = "2025-04"
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.55
|
||||
output = 2.19
|
||||
|
||||
[limit]
|
||||
context = 131_072
|
||||
output = 131_072
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
@@ -1,26 +0,0 @@
|
||||
name = "GLM 4.7"
|
||||
family = "glm"
|
||||
release_date = "2025-12-22"
|
||||
last_updated = "2025-12-22"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
knowledge = "2025-04"
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.60
|
||||
output = 2.20
|
||||
cache_read = 0.30
|
||||
|
||||
[limit]
|
||||
context = 198_000
|
||||
output = 198_000
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
@@ -11,6 +11,7 @@ open_weights = true
|
||||
[cost]
|
||||
input = 0.15
|
||||
output = 0.60
|
||||
cache_read = 0.015
|
||||
|
||||
[limit]
|
||||
context = 131_072
|
||||
|
||||
@@ -9,8 +9,9 @@ tool_call = true
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.05
|
||||
output = 0.20
|
||||
input = 0.07
|
||||
output = 0.30
|
||||
cache_read = 0.035
|
||||
|
||||
[limit]
|
||||
context = 131_072
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
name = "Kimi K2 Instruct"
|
||||
family = "kimi"
|
||||
release_date = "2025-07-11"
|
||||
last_updated = "2025-07-11"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
knowledge = "2024-10"
|
||||
tool_call = true
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 1.00
|
||||
output = 3.00
|
||||
|
||||
[limit]
|
||||
context = 128_000
|
||||
output = 16_384
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,25 +0,0 @@
|
||||
name = "Kimi K2 Thinking"
|
||||
family = "kimi-thinking"
|
||||
release_date = "2025-11-06"
|
||||
last_updated = "2025-11-06"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
cache_read = 0.30
|
||||
input = 0.60
|
||||
output = 2.50
|
||||
|
||||
[limit]
|
||||
context = 256_000
|
||||
output = 256_000
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
@@ -11,7 +11,7 @@ open_weights = true
|
||||
[cost]
|
||||
input = 0.30
|
||||
output = 1.20
|
||||
cache_read = 0.03
|
||||
cache_read = 0.06
|
||||
|
||||
[limit]
|
||||
context = 196_608
|
||||
|
||||
+7
-7
@@ -1,7 +1,7 @@
|
||||
name = "GLM 5"
|
||||
name = "GLM 5.1 Fast"
|
||||
family = "glm"
|
||||
release_date = "2026-02-11"
|
||||
last_updated = "2026-02-11"
|
||||
release_date = "2026-04-01"
|
||||
last_updated = "2026-04-01"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
@@ -9,12 +9,12 @@ tool_call = true
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 1.00
|
||||
output = 3.20
|
||||
cache_read = 0.50
|
||||
input = 2.80
|
||||
output = 8.80
|
||||
cache_read = 0.52
|
||||
|
||||
[limit]
|
||||
context = 202_752
|
||||
context = 202_800
|
||||
output = 131_072
|
||||
|
||||
[modalities]
|
||||
+8
-9
@@ -1,8 +1,7 @@
|
||||
name = "Kimi K2.5 Turbo"
|
||||
name = "Kimi K2.6 Turbo"
|
||||
family = "kimi-thinking"
|
||||
release_date = "2026-01-27"
|
||||
last_updated = "2026-01-27"
|
||||
knowledge = "2025-01"
|
||||
release_date = "2026-04-17"
|
||||
last_updated = "2026-04-17"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
@@ -10,13 +9,13 @@ tool_call = true
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
cache_read = 0
|
||||
input = 0
|
||||
output = 0
|
||||
cache_read = 0.30
|
||||
input = 2.00
|
||||
output = 8.00
|
||||
|
||||
[limit]
|
||||
context = 256_000
|
||||
output = 256_000
|
||||
context = 262_000
|
||||
output = 262_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image"]
|
||||
@@ -1,23 +1,7 @@
|
||||
name = "Claude Haiku 4.5"
|
||||
family = "claude-haiku"
|
||||
release_date = "2025-10-15"
|
||||
last_updated = "2025-10-15"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
knowledge = "2025-02-28"
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 0
|
||||
output = 0
|
||||
[extends]
|
||||
from = "anthropic/claude-haiku-4-5"
|
||||
|
||||
[limit]
|
||||
context = 144_000
|
||||
output = 32_000
|
||||
input = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
context = 200_000
|
||||
input = 136_000
|
||||
output = 64_000
|
||||
@@ -1,23 +1,7 @@
|
||||
name = "Claude Opus 4.5"
|
||||
family = "claude-opus"
|
||||
release_date = "2025-11-24"
|
||||
last_updated = "2025-08-01"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
knowledge = "2025-03-31"
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 0
|
||||
output = 0
|
||||
[extends]
|
||||
from = "anthropic/claude-opus-4-5"
|
||||
|
||||
[limit]
|
||||
context = 160_000
|
||||
context = 200_000
|
||||
input = 168_000
|
||||
output = 32_000
|
||||
input = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
@@ -1,23 +1,7 @@
|
||||
name = "Claude Opus 4.6"
|
||||
family = "claude-opus"
|
||||
release_date = "2026-02-05"
|
||||
last_updated = "2026-02-05"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
knowledge = "2025-05-31"
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 0
|
||||
output = 0
|
||||
[extends]
|
||||
from = "anthropic/claude-opus-4-6"
|
||||
|
||||
[limit]
|
||||
context = 144_000
|
||||
output = 64_000
|
||||
input = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
context = 200_000
|
||||
input = 168_000
|
||||
output = 32_000
|
||||
@@ -1,23 +1,7 @@
|
||||
name = "Claude Opus 4.7"
|
||||
family = "claude-opus"
|
||||
release_date = "2026-04-16"
|
||||
last_updated = "2026-04-16"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
tool_call = true
|
||||
knowledge = "2026-01-31"
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 0
|
||||
output = 0
|
||||
[extends]
|
||||
from = "anthropic/claude-opus-4-7"
|
||||
|
||||
[limit]
|
||||
context = 144_000
|
||||
output = 64_000
|
||||
input = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
context = 200_000
|
||||
input = 168_000
|
||||
output = 32_000
|
||||
@@ -0,0 +1,7 @@
|
||||
[extends]
|
||||
from = "anthropic/claude-opus-4-8"
|
||||
|
||||
[limit]
|
||||
context = 200_000
|
||||
input = 168_000
|
||||
output = 64_000
|
||||
@@ -1,23 +0,0 @@
|
||||
name = "Claude Opus 4.1"
|
||||
family = "claude-opus"
|
||||
status = "deprecated"
|
||||
release_date = "2025-08-05"
|
||||
last_updated = "2025-08-05"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = false
|
||||
knowledge = "2025-03-31"
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 0
|
||||
output = 0
|
||||
|
||||
[limit]
|
||||
context = 80_000
|
||||
output = 16_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
Loaded 100 of 548 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user