Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
589619e2aa | ||
|
|
041b6a3aef |
No files matched your search
@@ -1,83 +0,0 @@
|
||||
name: Sync Model Catalogs
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "17 8 * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
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
|
||||
|
||||
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: Sync model catalogs
|
||||
run: bun models:sync ${{ matrix.group }}
|
||||
env:
|
||||
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
|
||||
|
||||
- name: Validate models
|
||||
run: bun validate
|
||||
|
||||
- name: Create pull request
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
BRANCH: ${{ matrix.branch }}
|
||||
LABELS: ${{ matrix.labels }}
|
||||
TITLE: ${{ matrix.title }}
|
||||
run: |
|
||||
if [ -z "$(git status --porcelain -- providers)" ]; then
|
||||
echo "No model catalog changes found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git checkout -B "$BRANCH"
|
||||
git add providers
|
||||
git commit -m "$TITLE"
|
||||
git push --force-with-lease origin "$BRANCH"
|
||||
|
||||
label_args=()
|
||||
IFS=',' read -ra labels <<< "$LABELS"
|
||||
for label in "${labels[@]}"; do
|
||||
gh label create "$label" --color "0E8A16" --description "Automated model catalog sync" >/dev/null 2>&1 || true
|
||||
label_args+=(--label "$label")
|
||||
done
|
||||
|
||||
pr_number="$(gh pr list --head "$BRANCH" --base dev --json number --jq '.[0].number')"
|
||||
if [ -n "$pr_number" ]; then
|
||||
gh pr edit "$pr_number" --title "$TITLE" --body-file .sync/model-sync-report.md
|
||||
for label in "${labels[@]}"; do
|
||||
gh pr edit "$pr_number" --add-label "$label"
|
||||
done
|
||||
else
|
||||
gh pr create --base dev --head "$BRANCH" --title "$TITLE" --body-file .sync/model-sync-report.md "${label_args[@]}"
|
||||
fi
|
||||
@@ -5,7 +5,7 @@
|
||||
"": {
|
||||
"name": "models.dev",
|
||||
"dependencies": {
|
||||
"@cloudflare/workers-types": "^4.20260424.1",
|
||||
"@cloudflare/workers-types": "^4.20250801.0",
|
||||
"sst": "3.17.23",
|
||||
},
|
||||
},
|
||||
@@ -32,7 +32,6 @@
|
||||
"packages/web": {
|
||||
"name": "@models.dev/web",
|
||||
"dependencies": {
|
||||
"@tanstack/virtual-core": "^3.14.0",
|
||||
"hono": "^4.8.0",
|
||||
"models.dev": "workspace:*",
|
||||
},
|
||||
@@ -50,7 +49,7 @@
|
||||
"zod": "3.24.2",
|
||||
},
|
||||
"packages": {
|
||||
"@cloudflare/workers-types": ["@cloudflare/workers-types@4.20260424.1", "", {}, "sha512-0DLJ9yEk1KKzPbqop80Gw/P1wkKKzawmipULiJWdBXIBCoMvE0OVWms3IrL/Q/G7tfmPop9yF4XlZ69k9JLYng=="],
|
||||
"@cloudflare/workers-types": ["@cloudflare/workers-types@4.20250801.0", "", {}, "sha512-BQmMdoOGClY23TesgkR1PeGrPvPsSFD/zW7pDzWZHkOEsqkPk2A91h52bP8GbtKYTl1vdaYjQgJlGsP6Ih4G0w=="],
|
||||
|
||||
"@modelcontextprotocol/sdk": ["@modelcontextprotocol/sdk@1.6.1", "", { "dependencies": { "content-type": "^1.0.5", "cors": "^2.8.5", "eventsource": "^3.0.2", "express": "^5.0.1", "express-rate-limit": "^7.5.0", "pkce-challenge": "^4.1.0", "raw-body": "^3.0.0", "zod": "^3.23.8", "zod-to-json-schema": "^3.24.1" } }, "sha512-oxzMzYCkZHMntzuyerehK3fV6A2Kwh5BD6CGEJSVDU2QNEhfLOptf2X7esQgaHZXHZY0oHmMsOtIDLP71UJXgA=="],
|
||||
|
||||
@@ -58,11 +57,9 @@
|
||||
|
||||
"@models.dev/web": ["@models.dev/web@workspace:packages/web"],
|
||||
|
||||
"@tanstack/virtual-core": ["@tanstack/virtual-core@3.14.0", "", {}, "sha512-JLANqGy/D6k4Ujmh8Tr25lGimuOXNiaVyXaCAZS0W+1390sADdGnyUdSWNIfd49gebtIxGMij4IktRVzrdr12Q=="],
|
||||
|
||||
"@tsconfig/bun": ["@tsconfig/bun@1.0.8", "", {}, "sha512-JlJaRaS4hBTypxtFe8WhnwV8blf0R+3yehLk8XuyxUYNx6VXsKCjACSCvOYEFUiqlhlBWxtYCn/zRlOb8BzBQg=="],
|
||||
|
||||
"@types/bun": ["@types/bun@1.3.0", "", { "dependencies": { "bun-types": "1.3.0" } }, "sha512-+lAGCYjXjip2qY375xX/scJeVRmZ5cY0wyHYyCYxNcdEXrQ4AOe3gACgd4iQ8ksOslJtW4VNxBJ8llUwc3a6AA=="],
|
||||
"@types/bun": ["@types/bun@1.2.16", "", { "dependencies": { "bun-types": "1.2.16" } }, "sha512-1aCZJ/6nSiViw339RsaNhkNoEloLaPzZhxMOYEa7OzRzO41IGg5n/7I43/ZIAW/c+Q6cT12Vf7fOZOoVIzb5BQ=="],
|
||||
|
||||
"@types/node": ["@types/node@22.13.9", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-acBjXdRJ3A6Pb3tqnw9HZmyR3Fiol3aGxRCK1x3d+6CDAMjl7I649wpSd+yNURCjbOUGu9tqtLKnTGxmK6CyGw=="],
|
||||
|
||||
@@ -82,7 +79,7 @@
|
||||
|
||||
"buffer": ["buffer@4.9.2", "", { "dependencies": { "base64-js": "^1.0.2", "ieee754": "^1.1.4", "isarray": "^1.0.0" } }, "sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg=="],
|
||||
|
||||
"bun-types": ["bun-types@1.3.0", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-u8X0thhx+yJ0KmkxuEo9HAtdfgCBaM/aI9K90VQcQioAmkVp3SG3FkwWGibUFz3WdXAdcsqOcbU40lK7tbHdkQ=="],
|
||||
"bun-types": ["bun-types@1.2.16", "", { "dependencies": { "@types/node": "*" } }, "sha512-ciXLrHV4PXax9vHvUrkvun9VPVGOVwbbbBF/Ev1cXz12lyEZMoJpIJABOfPcN9gDJRaiKF9MVbSygLg4NXu3/A=="],
|
||||
|
||||
"bytes": ["bytes@3.1.2", "", {}, "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg=="],
|
||||
|
||||
@@ -328,6 +325,8 @@
|
||||
|
||||
"http-errors/statuses": ["statuses@2.0.1", "", {}, "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ=="],
|
||||
|
||||
"models.dev/@types/bun": ["@types/bun@1.3.0", "", { "dependencies": { "bun-types": "1.3.0" } }, "sha512-+lAGCYjXjip2qY375xX/scJeVRmZ5cY0wyHYyCYxNcdEXrQ4AOe3gACgd4iQ8ksOslJtW4VNxBJ8llUwc3a6AA=="],
|
||||
|
||||
"opencontrol/@tsconfig/bun": ["@tsconfig/bun@1.0.7", "", {}, "sha512-udGrGJBNQdXGVulehc1aWT73wkR9wdaGBtB6yL70RJsqwW/yJhIg6ZbRlPOfIUiFNrnBuYLBi9CSmMKfDC7dvA=="],
|
||||
|
||||
"opencontrol/hono": ["hono@4.7.4", "", {}, "sha512-Pst8FuGqz3L7tFF+u9Pu70eI0xa5S3LPUmrNd5Jm8nTHze9FxLTK9Kaj5g/k4UcwuJSXTP65SyHOPLrffpcAJg=="],
|
||||
@@ -335,5 +334,11 @@
|
||||
"openid-client/jose": ["jose@4.15.9", "", {}, "sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA=="],
|
||||
|
||||
"bun-types/@types/node/undici-types": ["undici-types@7.8.0", "", {}, "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="],
|
||||
|
||||
"models.dev/@types/bun/bun-types": ["bun-types@1.3.0", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-u8X0thhx+yJ0KmkxuEo9HAtdfgCBaM/aI9K90VQcQioAmkVp3SG3FkwWGibUFz3WdXAdcsqOcbU40lK7tbHdkQ=="],
|
||||
|
||||
"models.dev/@types/bun/bun-types/@types/node": ["@types/node@24.0.3", "", { "dependencies": { "undici-types": "~7.8.0" } }, "sha512-R4I/kzCYAdRLzfiCabn9hxWfbuHS573x+r0dJMkkzThEa7pbrcDWK+9zu3e7aBOouf+rQAciqPFMnxwr0aWgKg=="],
|
||||
|
||||
"models.dev/@types/bun/bun-types/@types/node/undici-types": ["undici-types@7.8.0", "", {}, "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="],
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{"data":[{"id":"anthropic/claude-opus-4.7-fast","canonical_slug":"anthropic/claude-4.7-opus-fast-20260512","hugging_face_id":null,"name":"Anthropic: Claude Opus 4.7 (Fast)","created":1778613011,"description":"Fast-mode variant of [Opus 4.7](/anthropic/claude-opus-4.7) - identical capabilities with higher output speed at premium 6x pricing.\n\nLearn more in Anthropic's docs: https://platform.claude.com/docs/en/build-with-claude/fast-mode","context_length":1000000,"architecture":{"modality":"text+image+file->text","input_modalities":["text","image","file"],"output_modalities":["text"],"tokenizer":"Claude","instruct_type":null},"pricing":{"prompt":"0.00003","completion":"0.00015","web_search":"0.01","input_cache_read":"0.000003","input_cache_write":"0.0000375"},"top_provider":{"context_length":1000000,"max_completion_tokens":128000,"is_moderated":true},"per_request_limits":null,"supported_parameters":["include_reasoning","max_tokens","reasoning","response_format","stop","structured_outputs","tool_choice","tools","verbosity"],"default_parameters":{"temperature":null,"top_p":null,"top_k":null,"frequency_penalty":null,"presence_penalty":null,"repetition_penalty":null},"supported_voices":null,"knowledge_cutoff":null,"expiration_date":null,"links":{"details":"/api/v1/models/anthropic/claude-4.7-opus-fast-20260512/endpoints"}},{"id":"perceptron/perceptron-mk1","canonical_slug":"perceptron/perceptron-mk1-20260512","hugging_face_id":null,"name":"Perceptron: Perceptron Mk1","created":1778597029,"description":"Perceptron Mk1 (Mark One) is Perceptron's highest-quality vision-language model for video and embodied reasoning.** It accepts image and video inputs paired with natural language queries, and produces detailed visual understanding...","context_length":32768,"architecture":{"modality":"text+image+video->text","input_modalities":["text","image","video"],"output_modalities":["text"],"tokenizer":"Other","instruct_type":null},"pricing":{"prompt":"0.00000015","completion":"0.0000015"},"top_provider":{"context_length":32768,"max_completion_tokens":8192,"is_moderated":false},"per_request_limits":null,"supported_parameters":["frequency_penalty","include_reasoning","max_tokens","presence_penalty","reasoning","structured_outputs","temperature","top_k","top_p"],"default_parameters":{"temperature":null,"top_p":null,"top_k":null,"frequency_penalty":null,"presence_penalty":null,"repetition_penalty":null},"supported_voices":null,"knowledge_cutoff":null,"expiration_date":null,"links":{"details":"/api/v1/models/perceptron/perceptron-mk1-20260512/endpoints"}},{"id":"inclusionai/ring-2.6-1t:free","canonical_slug":"inclusionai/ring-2.6-1t-20260508","hugging_face_id":null,"name":"inclusionAI: Ring-2.6-1T (free)","created":1778247440,"description":"Ring-2.6-1T is a 1T-parameter-scale thinking model with 63B active parameters, built for real-world agent workflows that require both strong capability and operational efficiency. It is optimized for coding agents, tool...","context_length":262144,"architecture":{"modality":"text->text","input_modalities":["text"],"output_modalities":["text"],"tokenizer":"Other","instruct_type":null},"pricing":{"prompt":"0","completion":"0"},"top_provider":{"context_length":262144,"max_completion_tokens":65536,"is_moderated":false},"per_request_limits":null,"supported_parameters":["frequency_penalty","include_reasoning","max_tokens","presence_penalty","reasoning","repetition_penalty","seed","stop","temperature","tool_choice","tools","top_k","top_p"],"default_parameters":{"temperature":null,"top_p":null,"top_k":null,"frequency_penalty":null,"presence_penalty":null,"repetition_penalty":null},"supported_voices":null,"knowledge_cutoff":null,"expiration_date":null,"links":{"details":"/api/v1/models/inclusionai/ring-2.6-1t-20260508/endpoints"}},{"id":"google/gemini-3.1-flash-lite","canonical_slug":"google/gemini-3.1-flash-lite-20260507","hugging_face_id":null,"name":"Google: Gemini 3.1 Flash Lite","created":1778168828,"description":"Gemini 3.1 Flash Lite is Google’s GA high-efficiency multimodal model optimized for low-latency, high-volume workloads. It supports text, image, video, audio, and PDF inputs, and is designed for lightweight agentic...","context_length":1048576,"architecture":{"modality":"text+image+file+audio+video->text","input_modalities":["text","image","video","file","audio"],"output_modalities":["text"],"tokenizer":"Gemini","instruct_type":null},"pricing":{"prompt":"0.00000025","completion":"0.0000015","image":"0.00000025","audio":"0.0000005","web_search":"0.014","internal_reasoning":"0.0000015","input_cache_read":"0.000000025","input_cache_write":"0.00000008333333333333334"},"top_provider":{"context_length":1048576,"max_completion_tokens":65536,"is_moderated":false},"per_request_limits":null,"supported_parameters":["include_reasoning","max_tokens","reasoning","response_format","seed","stop","structured_outputs","temperature","tool_choice","tools","top_p"],"default_parameters":{"temperature":nulLine truncated
|
||||
+2
-7
@@ -17,18 +17,13 @@
|
||||
"scripts": {
|
||||
"validate": "bun ./packages/core/script/validate.ts",
|
||||
"compare:migrations": "bun ./packages/core/script/compare-model-migrations.ts",
|
||||
"chutes:generate": "bun ./packages/core/script/generate-chutes.ts",
|
||||
"databricks:generate": "bun ./packages/core/script/generate-databricks.ts",
|
||||
"helicone:generate": "bun ./packages/core/script/generate-helicone.ts",
|
||||
"venice:generate": "bun ./packages/core/script/generate-venice.ts",
|
||||
"vercel:generate": "bun ./packages/core/script/generate-vercel.ts",
|
||||
"wandb:generate": "bun ./packages/core/script/generate-wandb.ts",
|
||||
"digitalocean:generate": "bun ./packages/core/script/generate-digitalocean.ts",
|
||||
"ambient:generate": "bun ./packages/core/script/generate-ambient.ts",
|
||||
"models:sync": "bun ./packages/core/script/sync-models.ts"
|
||||
"wandb:generate": "bun ./packages/core/script/generate-wandb.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cloudflare/workers-types": "^4.20260424.1",
|
||||
"@cloudflare/workers-types": "^4.20250801.0",
|
||||
"sst": "3.17.23"
|
||||
}
|
||||
}
|
||||
@@ -1,172 +0,0 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
/**
|
||||
* Generates Ambient model TOML files from https://api.ambient.xyz/v1/models.
|
||||
*
|
||||
* Emits `[extends]`-format TOMLs that inherit upstream metadata
|
||||
* (family, release_date, knowledge, capabilities) from the canonical
|
||||
* provider model, and override only the fields Ambient's API reports:
|
||||
* cost, limit, modalities.
|
||||
*
|
||||
* Flags:
|
||||
* --dry-run Preview generated TOMLs without writing files.
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import path from "node:path";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
|
||||
const API_ENDPOINT = "https://api.ambient.xyz/v1/models";
|
||||
|
||||
// Allowlist for the initial rollout.
|
||||
const ALLOWLIST = new Set<string>([
|
||||
"zai-org/GLM-5.1-FP8",
|
||||
"moonshotai/kimi-k2.6",
|
||||
]);
|
||||
|
||||
// Maps Ambient model IDs to canonical <provider>/<model> in this repo.
|
||||
// The generated TOML uses this path as `[extends].from` so capabilities
|
||||
// and metadata propagate from the upstream provider automatically.
|
||||
const EXTENDS_MAP: Record<string, string> = {
|
||||
"zai-org/GLM-5.1-FP8": "zai/glm-5.1",
|
||||
"moonshotai/kimi-k2.6": "moonshotai/kimi-k2.6",
|
||||
};
|
||||
|
||||
const Pricing = z
|
||||
.object({
|
||||
prompt: z.string(),
|
||||
completion: z.string(),
|
||||
input_cache_read: z.string().optional(),
|
||||
input_cache_write: z.string().optional(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
const AmbientModel = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
context_length: z.number(),
|
||||
max_output_length: z.number(),
|
||||
input_modalities: z.array(z.string()),
|
||||
output_modalities: z.array(z.string()),
|
||||
pricing: Pricing,
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
const AmbientResponse = z
|
||||
.object({
|
||||
object: z.literal("list"),
|
||||
data: z.array(AmbientModel),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
const ALLOWED_MODALITIES = new Set(["text", "audio", "image", "video", "pdf"]);
|
||||
|
||||
function modalities(values: string[]): string[] {
|
||||
return values
|
||||
.map((v) => v.toLowerCase())
|
||||
.filter((v) => ALLOWED_MODALITIES.has(v));
|
||||
}
|
||||
|
||||
function perMTok(price: string): number {
|
||||
const n = parseFloat(price);
|
||||
if (!Number.isFinite(n)) {
|
||||
throw new Error(`Invalid price: ${price}`);
|
||||
}
|
||||
// Round to 6 decimals to absorb float noise from per-token strings.
|
||||
return Math.round(n * 1_000_000 * 1_000_000) / 1_000_000;
|
||||
}
|
||||
|
||||
function formatToml(
|
||||
model: z.infer<typeof AmbientModel>,
|
||||
extendsFrom: string,
|
||||
): string {
|
||||
const lines: string[] = [];
|
||||
lines.push("[extends]");
|
||||
lines.push(`from = "${extendsFrom}"`);
|
||||
lines.push("");
|
||||
|
||||
lines.push("[cost]");
|
||||
lines.push(`input = ${perMTok(model.pricing.prompt)}`);
|
||||
lines.push(`output = ${perMTok(model.pricing.completion)}`);
|
||||
if (model.pricing.input_cache_read !== undefined) {
|
||||
lines.push(`cache_read = ${perMTok(model.pricing.input_cache_read)}`);
|
||||
}
|
||||
if (model.pricing.input_cache_write !== undefined) {
|
||||
lines.push(`cache_write = ${perMTok(model.pricing.input_cache_write)}`);
|
||||
}
|
||||
lines.push("");
|
||||
|
||||
lines.push("[limit]");
|
||||
lines.push(`context = ${model.context_length}`);
|
||||
lines.push(`output = ${model.max_output_length}`);
|
||||
lines.push("");
|
||||
|
||||
const input = modalities(model.input_modalities);
|
||||
const output = modalities(model.output_modalities);
|
||||
lines.push("[modalities]");
|
||||
lines.push(`input = [${input.map((m) => `"${m}"`).join(", ")}]`);
|
||||
lines.push(`output = [${output.map((m) => `"${m}"`).join(", ")}]`);
|
||||
|
||||
return lines.join("\n") + "\n";
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const dryRun = process.argv.includes("--dry-run");
|
||||
|
||||
const outDir = path.join(
|
||||
import.meta.dirname,
|
||||
"..",
|
||||
"..",
|
||||
"..",
|
||||
"providers",
|
||||
"ambient",
|
||||
"models",
|
||||
);
|
||||
|
||||
const res = await fetch(API_ENDPOINT);
|
||||
if (!res.ok) {
|
||||
console.error(`Fetch failed: ${res.status} ${res.statusText}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const parsed = AmbientResponse.safeParse(await res.json());
|
||||
if (!parsed.success) {
|
||||
console.error("Invalid Ambient response:", parsed.error.issues);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const selected = parsed.data.data.filter((m) => ALLOWLIST.has(m.id));
|
||||
const missing = [...ALLOWLIST].filter(
|
||||
(id) => !selected.some((m) => m.id === id),
|
||||
);
|
||||
if (missing.length > 0) {
|
||||
console.error(`Allowlisted models missing from API: ${missing.join(", ")}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let count = 0;
|
||||
for (const model of selected) {
|
||||
const extendsFrom = EXTENDS_MAP[model.id];
|
||||
if (!extendsFrom) {
|
||||
console.error(`No EXTENDS_MAP entry for ${model.id}; skipping`);
|
||||
continue;
|
||||
}
|
||||
const filePath = path.join(outDir, `${model.id}.toml`);
|
||||
const toml = formatToml(model, extendsFrom);
|
||||
if (dryRun) {
|
||||
console.log(`--- ${path.relative(process.cwd(), filePath)} ---`);
|
||||
console.log(toml);
|
||||
} else {
|
||||
await mkdir(path.dirname(filePath), { recursive: true });
|
||||
await Bun.write(filePath, toml);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
console.log(
|
||||
`${dryRun ? "Previewed" : "Wrote"} ${count} model file(s) under providers/ambient/models/`,
|
||||
);
|
||||
}
|
||||
|
||||
await main();
|
||||
@@ -1,589 +0,0 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
/**
|
||||
* Generates Chutes model TOML files from the Chutes LLM API.
|
||||
*
|
||||
* Flags:
|
||||
* --dry-run: Preview changes without writing files
|
||||
* --new-only: Only create new models, skip updating existing ones
|
||||
* --keep-orphans: Don't delete TOML files for models no longer in the API
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import path from "node:path";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
import { ModelFamilyValues } from "../src/family.js";
|
||||
|
||||
const API_ENDPOINT = "https://llm.chutes.ai/v1/models";
|
||||
|
||||
enum SkipZeroFields {
|
||||
LimitContext = "limit.context",
|
||||
LimitOutput = "limit.output",
|
||||
}
|
||||
|
||||
const Pricing = z.object({
|
||||
prompt: z.number().optional(),
|
||||
completion: z.number().optional(),
|
||||
input_cache_read: z.number().optional(),
|
||||
}).passthrough();
|
||||
|
||||
const ChutesModel = z.object({
|
||||
id: z.string(),
|
||||
created: z.number(),
|
||||
pricing: Pricing.optional(),
|
||||
context_length: z.number().optional(),
|
||||
max_output_length: z.number().optional(),
|
||||
max_model_len: z.number().optional(),
|
||||
input_modalities: z.array(z.string()).optional(),
|
||||
output_modalities: z.array(z.string()).optional(),
|
||||
supported_features: z.array(z.string()).optional(),
|
||||
supported_sampling_parameters: z.array(z.string()).optional(),
|
||||
quantization: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
const ChutesResponse = z.object({
|
||||
data: z.array(ChutesModel),
|
||||
}).passthrough();
|
||||
|
||||
interface ExistingModel {
|
||||
name?: string;
|
||||
family?: string;
|
||||
attachment?: boolean;
|
||||
reasoning?: boolean;
|
||||
tool_call?: boolean;
|
||||
structured_output?: boolean;
|
||||
temperature?: boolean;
|
||||
knowledge?: string;
|
||||
release_date?: string;
|
||||
last_updated?: string;
|
||||
open_weights?: boolean;
|
||||
interleaved?: boolean | { field: string };
|
||||
status?: string;
|
||||
cost?: {
|
||||
input?: number;
|
||||
output?: number;
|
||||
cache_read?: number;
|
||||
};
|
||||
limit?: {
|
||||
context?: number;
|
||||
output?: number;
|
||||
};
|
||||
modalities?: {
|
||||
input?: string[];
|
||||
output?: string[];
|
||||
};
|
||||
}
|
||||
|
||||
interface MergedModel {
|
||||
name: string;
|
||||
family?: string;
|
||||
attachment: boolean;
|
||||
reasoning: boolean;
|
||||
tool_call: boolean;
|
||||
structured_output?: boolean;
|
||||
temperature: boolean;
|
||||
knowledge?: string;
|
||||
release_date: string;
|
||||
last_updated: string;
|
||||
open_weights: boolean;
|
||||
interleaved?: boolean | { field: string };
|
||||
status?: string;
|
||||
cost?: {
|
||||
input: number;
|
||||
output: number;
|
||||
cache_read?: number;
|
||||
};
|
||||
limit: {
|
||||
context: number;
|
||||
output: number;
|
||||
};
|
||||
modalities: {
|
||||
input: string[];
|
||||
output: string[];
|
||||
};
|
||||
}
|
||||
|
||||
interface Changes {
|
||||
field: string;
|
||||
oldValue: string;
|
||||
newValue: string;
|
||||
}
|
||||
|
||||
// ── Utility functions ────────────────────────────────────────────────
|
||||
|
||||
function timestampToDate(timestamp: number): string {
|
||||
const date = new Date(timestamp * 1000);
|
||||
return date.toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
function getTodayDate(): string {
|
||||
return new Date().toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
function formatNumber(n: number): string {
|
||||
if (n >= 1000) {
|
||||
return n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "_");
|
||||
}
|
||||
return n.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Humanize a model ID into a readable name.
|
||||
* Strips the org prefix and replaces hyphens with spaces.
|
||||
* e.g. "Qwen/Qwen3-32B-TEE" → "Qwen3 32B TEE"
|
||||
*/
|
||||
function humanizeModelName(modelId: string): string {
|
||||
const parts = modelId.split("/");
|
||||
const modelPart = parts[parts.length - 1];
|
||||
return modelPart.replace(/-/g, " ");
|
||||
}
|
||||
|
||||
// ── Family inference ───────────
|
||||
|
||||
function isSubstring(target: string, family: string): boolean {
|
||||
return target.toLowerCase().includes(family.toLowerCase());
|
||||
}
|
||||
|
||||
function matchesFamily(target: string, family: string): boolean {
|
||||
const targetLower = target.toLowerCase();
|
||||
const familyLower = family.toLowerCase();
|
||||
let familyIdx = 0;
|
||||
|
||||
for (let i = 0; i < targetLower.length && familyIdx < familyLower.length; i++) {
|
||||
if (targetLower[i] === familyLower[familyIdx]) {
|
||||
familyIdx++;
|
||||
}
|
||||
}
|
||||
|
||||
return familyIdx === familyLower.length;
|
||||
}
|
||||
|
||||
function inferFamily(modelId: string, modelName: string): string | undefined {
|
||||
const sortedFamilies = [...ModelFamilyValues].sort((a, b) => b.length - a.length);
|
||||
|
||||
// First pass: try exact substring matches
|
||||
for (const family of sortedFamilies) {
|
||||
if (isSubstring(modelId, family)) {
|
||||
return family;
|
||||
}
|
||||
}
|
||||
|
||||
for (const family of sortedFamilies) {
|
||||
if (isSubstring(modelName, family)) {
|
||||
return family;
|
||||
}
|
||||
}
|
||||
|
||||
// Second pass: fall back to subsequence matching
|
||||
for (const family of sortedFamilies) {
|
||||
if (matchesFamily(modelId, family)) {
|
||||
return family;
|
||||
}
|
||||
}
|
||||
|
||||
for (const family of sortedFamilies) {
|
||||
if (matchesFamily(modelName, family)) {
|
||||
return family;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// ── Load existing TOML ───────────────────────────────────────────────
|
||||
|
||||
async function loadExistingModel(filePath: string): Promise<ExistingModel | null> {
|
||||
try {
|
||||
const file = Bun.file(filePath);
|
||||
if (!(await file.exists())) {
|
||||
return null;
|
||||
}
|
||||
const toml = await import(filePath, { with: { type: "toml" } }).then(
|
||||
(mod) => mod.default,
|
||||
);
|
||||
return toml as ExistingModel;
|
||||
} catch (e) {
|
||||
console.warn(`Warning: Failed to parse existing file ${filePath}:`, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Merge API data with existing TOML ────────────────────────────────
|
||||
|
||||
function mergeModel(
|
||||
apiModel: z.infer<typeof ChutesModel>,
|
||||
existing: ExistingModel | null,
|
||||
): MergedModel {
|
||||
const features = new Set(apiModel.supported_features ?? []);
|
||||
const samplingParams = new Set(apiModel.supported_sampling_parameters ?? []);
|
||||
const inputMods = apiModel.input_modalities ?? ["text"];
|
||||
const outputMods = apiModel.output_modalities ?? ["text"];
|
||||
|
||||
// Capabilities from API features
|
||||
const hasAttachment = inputMods.some((m) =>
|
||||
m === "image" || m === "video" || m === "pdf",
|
||||
);
|
||||
const hasReasoning = features.has("reasoning");
|
||||
const hasToolCall = features.has("tools");
|
||||
const hasStructuredOutput = features.has("structured_outputs");
|
||||
const hasTemperature = samplingParams.size > 0
|
||||
? samplingParams.has("temperature")
|
||||
: true; // default true if no sampling params info
|
||||
|
||||
// Preserve existing values when available (manually specified)
|
||||
const modelName = existing?.name ?? humanizeModelName(apiModel.id);
|
||||
const family = existing?.family ?? inferFamily(apiModel.id, modelName);
|
||||
const knowledge = existing?.knowledge;
|
||||
const interleaved = existing?.interleaved;
|
||||
const status = existing?.status;
|
||||
|
||||
// Release date: existing > API created timestamp > today
|
||||
const releaseDate = existing?.release_date
|
||||
?? timestampToDate(apiModel.created)
|
||||
?? getTodayDate();
|
||||
|
||||
// Context limit: prefer context_length, fallback to max_model_len
|
||||
const apiContext = apiModel.context_length ?? apiModel.max_model_len ?? 0;
|
||||
const contextLimit = apiContext > 0
|
||||
? apiContext
|
||||
: (existing?.limit?.context ?? 0);
|
||||
|
||||
// Output limit: prefer max_output_length, fallback to existing
|
||||
const apiOutput = apiModel.max_output_length ?? 0;
|
||||
const outputLimit = apiOutput > 0
|
||||
? apiOutput
|
||||
: (existing?.limit?.output ?? 0);
|
||||
|
||||
const merged: MergedModel = {
|
||||
name: modelName,
|
||||
family,
|
||||
attachment: hasAttachment,
|
||||
reasoning: hasReasoning,
|
||||
tool_call: hasToolCall,
|
||||
temperature: hasTemperature,
|
||||
release_date: releaseDate,
|
||||
last_updated: getTodayDate(),
|
||||
open_weights: true, // Chutes hosts open-weight models
|
||||
...(hasStructuredOutput && { structured_output: hasStructuredOutput }),
|
||||
...(knowledge && { knowledge }),
|
||||
...(interleaved !== undefined && { interleaved }),
|
||||
...(status && { status }),
|
||||
limit: {
|
||||
context: contextLimit,
|
||||
output: outputLimit,
|
||||
},
|
||||
modalities: {
|
||||
input: inputMods,
|
||||
output: outputMods,
|
||||
},
|
||||
};
|
||||
|
||||
// Cost: API values are already in USD per 1M tokens — use directly
|
||||
if (apiModel.pricing) {
|
||||
const inputPrice = apiModel.pricing.prompt;
|
||||
const outputPrice = apiModel.pricing.completion;
|
||||
const cacheReadPrice = apiModel.pricing.input_cache_read;
|
||||
|
||||
if (inputPrice !== undefined && outputPrice !== undefined) {
|
||||
merged.cost = {
|
||||
input: inputPrice,
|
||||
output: outputPrice,
|
||||
...(cacheReadPrice !== undefined && { cache_read: cacheReadPrice }),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
// ── TOML formatting ──────────────────────────────────────────────────
|
||||
|
||||
function formatToml(model: MergedModel): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push(`# Auto-generated by generate-chutes.ts — do not edit pricing, limits, or capabilities.`);
|
||||
lines.push(`# Manual overrides preserved on re-run: name, family, knowledge, interleaved, status`);
|
||||
lines.push(`name = "${model.name.replace(/"/g, '\\"')}"`);
|
||||
if (model.family) {
|
||||
lines.push(`family = "${model.family}"`);
|
||||
}
|
||||
lines.push(`release_date = "${model.release_date}"`);
|
||||
lines.push(`last_updated = "${model.last_updated}"`);
|
||||
lines.push(`attachment = ${model.attachment}`);
|
||||
lines.push(`reasoning = ${model.reasoning}`);
|
||||
lines.push(`temperature = ${model.temperature}`);
|
||||
lines.push(`tool_call = ${model.tool_call}`);
|
||||
if (model.structured_output !== undefined) {
|
||||
lines.push(`structured_output = ${model.structured_output}`);
|
||||
}
|
||||
lines.push(`open_weights = ${model.open_weights}`);
|
||||
if (model.knowledge) {
|
||||
lines.push(`knowledge = "${model.knowledge}"`);
|
||||
}
|
||||
if (model.status) {
|
||||
lines.push(`status = "${model.status}"`);
|
||||
}
|
||||
|
||||
if (model.cost) {
|
||||
lines.push("");
|
||||
lines.push(`[cost]`);
|
||||
lines.push(`input = ${model.cost.input}`);
|
||||
lines.push(`output = ${model.cost.output}`);
|
||||
if (model.cost.cache_read !== undefined) {
|
||||
lines.push(`cache_read = ${model.cost.cache_read}`);
|
||||
}
|
||||
}
|
||||
|
||||
lines.push("");
|
||||
lines.push(`[limit]`);
|
||||
lines.push(`context = ${formatNumber(model.limit.context)}`);
|
||||
lines.push(`output = ${formatNumber(model.limit.output)}`);
|
||||
|
||||
lines.push("");
|
||||
lines.push(`[modalities]`);
|
||||
lines.push(`input = [${model.modalities.input.map((m) => `"${m}"`).join(", ")}]`);
|
||||
lines.push(`output = [${model.modalities.output.map((m) => `"${m}"`).join(", ")}]`);
|
||||
|
||||
if (model.interleaved !== undefined) {
|
||||
lines.push("");
|
||||
if (model.interleaved === true) {
|
||||
lines.push(`interleaved = true`);
|
||||
} else if (typeof model.interleaved === "object") {
|
||||
lines.push(`[interleaved]`);
|
||||
lines.push(`field = "${model.interleaved.field}"`);
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join("\n") + "\n";
|
||||
}
|
||||
|
||||
// ── Change detection ─────────────────────────────────────────────────
|
||||
|
||||
function detectChanges(
|
||||
existing: ExistingModel | null,
|
||||
merged: MergedModel,
|
||||
): Changes[] {
|
||||
if (!existing) return [];
|
||||
|
||||
const changes: Changes[] = [];
|
||||
const EPSILON = 0.001;
|
||||
|
||||
const shouldSkipZero = (field: string, oldVal: unknown, newVal: unknown): boolean => {
|
||||
if (!Object.values(SkipZeroFields).includes(field as SkipZeroFields)) {
|
||||
return false;
|
||||
}
|
||||
return (typeof oldVal === "number" && oldVal === 0) || (typeof newVal === "number" && newVal === 0);
|
||||
};
|
||||
|
||||
const formatValue = (val: unknown): string => {
|
||||
if (typeof val === "number") return formatNumber(val);
|
||||
if (Array.isArray(val)) return `[${val.join(", ")}]`;
|
||||
if (val === undefined) return "(none)";
|
||||
return String(val);
|
||||
};
|
||||
|
||||
const isMaterialPriceDiff = (oldPrice: unknown, newPrice: unknown): boolean => {
|
||||
if (oldPrice === 0 && newPrice === undefined) return false;
|
||||
if (oldPrice !== undefined && newPrice !== undefined) {
|
||||
return Math.abs((oldPrice as number) - (newPrice as number)) > EPSILON;
|
||||
}
|
||||
return oldPrice !== newPrice;
|
||||
};
|
||||
|
||||
const compare = (field: string, oldVal: unknown, newVal: unknown) => {
|
||||
if (shouldSkipZero(field, oldVal, newVal)) return;
|
||||
|
||||
const isDiff = field.startsWith("cost.")
|
||||
? isMaterialPriceDiff(oldVal, newVal)
|
||||
: JSON.stringify(oldVal) !== JSON.stringify(newVal);
|
||||
|
||||
if (isDiff) {
|
||||
changes.push({
|
||||
field,
|
||||
oldValue: formatValue(oldVal),
|
||||
newValue: formatValue(newVal),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
compare("name", existing.name, merged.name);
|
||||
compare("family", existing.family, merged.family);
|
||||
compare("attachment", existing.attachment, merged.attachment);
|
||||
compare("reasoning", existing.reasoning, merged.reasoning);
|
||||
compare("tool_call", existing.tool_call, merged.tool_call);
|
||||
compare("structured_output", existing.structured_output, merged.structured_output);
|
||||
compare("open_weights", existing.open_weights, merged.open_weights);
|
||||
compare("release_date", existing.release_date, merged.release_date);
|
||||
compare("cost.input", existing.cost?.input, merged.cost?.input);
|
||||
compare("cost.output", existing.cost?.output, merged.cost?.output);
|
||||
compare("cost.cache_read", existing.cost?.cache_read, merged.cost?.cache_read);
|
||||
compare("limit.context", existing.limit?.context, merged.limit.context);
|
||||
compare("limit.output", existing.limit?.output, merged.limit.output);
|
||||
compare("modalities.input", existing.modalities?.input, merged.modalities.input);
|
||||
compare("modalities.output", existing.modalities?.output, merged.modalities.output);
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
||||
// ── Main ─────────────────────────────────────────────────────────────
|
||||
|
||||
async function main() {
|
||||
const args = process.argv.slice(2);
|
||||
const dryRun = args.includes("--dry-run");
|
||||
const newOnly = args.includes("--new-only");
|
||||
const keepOrphans = args.includes("--keep-orphans");
|
||||
|
||||
const modelsDir = path.join(
|
||||
import.meta.dirname,
|
||||
"..",
|
||||
"..",
|
||||
"..",
|
||||
"providers",
|
||||
"chutes",
|
||||
"models",
|
||||
);
|
||||
|
||||
console.log(`${dryRun ? "[DRY RUN] " : ""}${newOnly ? "[NEW ONLY] " : ""}${keepOrphans ? "[KEEP ORPHANS] " : ""}Fetching Chutes models from API...`);
|
||||
|
||||
const res = await fetch(API_ENDPOINT);
|
||||
if (!res.ok) {
|
||||
console.error(`Failed to fetch API: ${res.status} ${res.statusText}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const json = await res.json();
|
||||
const parsed = ChutesResponse.safeParse(json);
|
||||
if (!parsed.success) {
|
||||
console.error("Invalid API response:", parsed.error.errors);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const apiModels = parsed.data.data;
|
||||
|
||||
// Scan existing TOML files
|
||||
const existingFiles = new Set<string>();
|
||||
try {
|
||||
for await (const file of new Bun.Glob("**/*.toml").scan({
|
||||
cwd: modelsDir,
|
||||
absolute: false,
|
||||
})) {
|
||||
existingFiles.add(file);
|
||||
}
|
||||
} catch {
|
||||
}
|
||||
|
||||
console.log(`Found ${apiModels.length} models in API, ${existingFiles.size} existing files\n`);
|
||||
|
||||
const apiModelIds = new Set<string>();
|
||||
|
||||
let created = 0;
|
||||
let updated = 0;
|
||||
let unchanged = 0;
|
||||
|
||||
for (const apiModel of apiModels) {
|
||||
const relativePath = `${apiModel.id}.toml`;
|
||||
const filePath = path.join(modelsDir, relativePath);
|
||||
const dirPath = path.dirname(filePath);
|
||||
|
||||
apiModelIds.add(relativePath);
|
||||
|
||||
const existing = await loadExistingModel(filePath);
|
||||
const merged = mergeModel(apiModel, existing);
|
||||
const tomlContent = formatToml(merged);
|
||||
|
||||
if (existing === null) {
|
||||
created++;
|
||||
if (dryRun) {
|
||||
console.log(`[DRY RUN] Would create: ${relativePath}`);
|
||||
console.log(` name = "${merged.name}"`);
|
||||
if (merged.family) {
|
||||
console.log(` family = "${merged.family}" (inferred)`);
|
||||
}
|
||||
console.log("");
|
||||
} else {
|
||||
await mkdir(dirPath, { recursive: true });
|
||||
await Bun.write(filePath, tomlContent);
|
||||
console.log(`Created: ${relativePath}`);
|
||||
}
|
||||
} else {
|
||||
if (newOnly) {
|
||||
unchanged++;
|
||||
continue;
|
||||
}
|
||||
|
||||
const changes = detectChanges(existing, merged);
|
||||
const existingContent = await Bun.file(filePath).text();
|
||||
const formatChanged = existingContent !== tomlContent;
|
||||
|
||||
if (changes.length > 0 || formatChanged) {
|
||||
updated++;
|
||||
if (dryRun) {
|
||||
console.log(`[DRY RUN] Would update: ${relativePath}`);
|
||||
} else {
|
||||
await mkdir(dirPath, { recursive: true });
|
||||
await Bun.write(filePath, tomlContent);
|
||||
console.log(`Updated: ${relativePath}`);
|
||||
}
|
||||
for (const change of changes) {
|
||||
console.log(` ${change.field}: ${change.oldValue} → ${change.newValue}`);
|
||||
}
|
||||
if (changes.length === 0 && formatChanged) {
|
||||
console.log(` (format-only change)`);
|
||||
}
|
||||
console.log("");
|
||||
} else {
|
||||
unchanged++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle orphaned files (on disk but not in API)
|
||||
const orphaned: string[] = [];
|
||||
for (const file of existingFiles) {
|
||||
if (!apiModelIds.has(file)) {
|
||||
orphaned.push(file);
|
||||
const orphanPath = path.join(modelsDir, file);
|
||||
if (keepOrphans) {
|
||||
console.log(`Orphaned (kept): ${file}`);
|
||||
} else if (dryRun) {
|
||||
console.log(`[DRY RUN] Would delete: ${file}`);
|
||||
} else {
|
||||
await Bun.file(orphanPath).delete();
|
||||
console.log(`Deleted: ${file}`);
|
||||
|
||||
// Clean up empty parent directories
|
||||
const parentDir = path.dirname(orphanPath);
|
||||
try {
|
||||
const remaining = [];
|
||||
for await (const entry of new Bun.Glob("*").scan({ cwd: parentDir })) {
|
||||
remaining.push(entry);
|
||||
}
|
||||
if (remaining.length === 0) {
|
||||
const { rmdir } = await import("node:fs/promises");
|
||||
await rmdir(parentDir);
|
||||
console.log(` Removed empty directory: ${path.basename(parentDir)}/`);
|
||||
}
|
||||
} catch {
|
||||
// Directory not empty or other error, ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log("");
|
||||
if (dryRun) {
|
||||
console.log(
|
||||
`Summary: ${created} would be created, ${updated} would be updated, ${unchanged} unchanged, ${orphaned.length} would be deleted`,
|
||||
);
|
||||
} else if (keepOrphans) {
|
||||
console.log(
|
||||
`Summary: ${created} created, ${updated} updated, ${unchanged} unchanged, ${orphaned.length} orphaned (kept)`,
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
`Summary: ${created} created, ${updated} updated, ${unchanged} unchanged, ${orphaned.length} deleted`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await main();
|
||||
@@ -1,287 +0,0 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
/**
|
||||
* Generates Databricks model TOML files from the Foundation Model API endpoint.
|
||||
*
|
||||
* Each Databricks endpoint exposes a model from another provider (Anthropic,
|
||||
* OpenAI, Google, etc.), so the generated TOML uses [extends] to inherit
|
||||
* canonical metadata from that upstream provider's TOML in models.dev.
|
||||
*
|
||||
* Usage:
|
||||
* DATABRICKS_HOST=<host> DATABRICKS_TOKEN=<pat> bun run databricks:generate
|
||||
* bun run databricks:generate --workspace <host> --token <pat>
|
||||
*
|
||||
* Flags:
|
||||
* --dry-run: Preview changes without writing files
|
||||
* --new-only: Only create new models, skip updating existing ones
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import path from "node:path";
|
||||
import { mkdir, readFile } from "node:fs/promises";
|
||||
import { existsSync } from "node:fs";
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const flag = (name: string) => {
|
||||
const i = args.indexOf(`--${name}`);
|
||||
return i !== -1 ? args[i + 1] : undefined;
|
||||
};
|
||||
const dryRun = args.includes("--dry-run");
|
||||
const newOnly = args.includes("--new-only");
|
||||
|
||||
const host = flag("workspace") ?? process.env.DATABRICKS_HOST;
|
||||
const token = flag("token") ?? process.env.DATABRICKS_TOKEN;
|
||||
|
||||
if (!host || !token) {
|
||||
console.error(
|
||||
"Usage: DATABRICKS_HOST=<host> DATABRICKS_TOKEN=<pat> bun run databricks:generate",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const workspace = host.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
||||
const PROVIDERS_DIR = path.join(import.meta.dirname, "..", "..", "..", "providers");
|
||||
const MODELS_DIR = path.join(PROVIDERS_DIR, "databricks", "models");
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// API schemas
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const FoundationModel = z
|
||||
.object({
|
||||
ai_gateway_v2_supported: z.boolean().optional(),
|
||||
api_types: z.array(z.string()).optional(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
const ServedEntity = z
|
||||
.object({
|
||||
foundation_model: FoundationModel.optional(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
const Endpoint = z
|
||||
.object({
|
||||
name: z.string(),
|
||||
config: z
|
||||
.object({
|
||||
served_entities: z.array(ServedEntity).optional(),
|
||||
})
|
||||
.passthrough()
|
||||
.optional(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
const FoundationModelsResponse = z
|
||||
.object({
|
||||
endpoints: z.array(Endpoint),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Canonical resolution: map a Databricks endpoint name to a models.dev entry
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const PREFIX_TO_PROVIDER: [string, string][] = [
|
||||
["claude-", "anthropic"],
|
||||
["gpt-", "openai"],
|
||||
["gemini-", "google"],
|
||||
["mistral-", "mistral"],
|
||||
["mixtral-", "mistral"],
|
||||
];
|
||||
|
||||
type Resolution =
|
||||
| { type: "extends"; from: string }
|
||||
| { type: "inline"; content: string }
|
||||
| null;
|
||||
|
||||
async function resolveCanonical(endpointName: string): Promise<Resolution> {
|
||||
const bare = endpointName.replace(/^databricks-/, "");
|
||||
|
||||
// Models in provider subdirectories (e.g. openrouter/openai/gpt-oss-*)
|
||||
// can't use [extends] (schema requires provider/model format), so inline.
|
||||
if (bare.startsWith("gpt-oss-")) {
|
||||
const p = path.join(PROVIDERS_DIR, "openrouter", "models", "openai", `${bare}.toml`);
|
||||
if (existsSync(p)) {
|
||||
return { type: "inline", content: await readFile(p, "utf8") };
|
||||
}
|
||||
}
|
||||
|
||||
// Meta Llama: "meta-llama-3-3-70b-instruct" → "llama-3.3-70b-instruct"
|
||||
if (bare.startsWith("meta-llama-") || bare.startsWith("llama-")) {
|
||||
const llamaId = bare
|
||||
.replace(/^meta-llama-/, "llama-")
|
||||
.replace(/^(llama-\d+)-(\d+)-/, "$1.$2-");
|
||||
const p = path.join(PROVIDERS_DIR, "llama", "models", `${llamaId}.toml`);
|
||||
if (existsSync(p)) return { type: "extends", from: `llama/${llamaId}` };
|
||||
}
|
||||
|
||||
for (const [prefix, provider] of PREFIX_TO_PROVIDER) {
|
||||
if (!bare.startsWith(prefix)) continue;
|
||||
|
||||
const exact = path.join(PROVIDERS_DIR, provider, "models", `${bare}.toml`);
|
||||
if (existsSync(exact)) return { type: "extends", from: `${provider}/${bare}` };
|
||||
|
||||
// Try with hyphens-as-dots in version (e.g. gpt-5-4 → gpt-5.4)
|
||||
const dotted = bare.replace(/^((?:[a-z]+-)+\d+)-(\d)/, "$1.$2");
|
||||
if (dotted !== bare) {
|
||||
const dottedExact = path.join(PROVIDERS_DIR, provider, "models", `${dotted}.toml`);
|
||||
if (existsSync(dottedExact)) return { type: "extends", from: `${provider}/${dotted}` };
|
||||
}
|
||||
|
||||
// Fuzzy: longest filename that shares a prefix with bare or its dotted form
|
||||
const candidates = [bare, ...(dotted !== bare ? [dotted] : [])];
|
||||
const files: string[] = [];
|
||||
try {
|
||||
for await (const f of new Bun.Glob("*.toml").scan({
|
||||
cwd: path.join(PROVIDERS_DIR, provider, "models"),
|
||||
})) {
|
||||
files.push(f);
|
||||
}
|
||||
} catch {
|
||||
// provider directory may not exist
|
||||
}
|
||||
const match = files
|
||||
.map((f) => f.replace(/\.toml$/, ""))
|
||||
.filter((id) => candidates.some((c) => id.startsWith(c) || c.startsWith(id)))
|
||||
.sort((a, b) => b.length - a.length)[0];
|
||||
if (match) return { type: "extends", from: `${provider}/${match}` };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function formatToml(resolution: Resolution, endpointName: string): string {
|
||||
if (resolution?.type === "extends") {
|
||||
return `[extends]\nfrom = "${resolution.from}"\n`;
|
||||
}
|
||||
if (resolution?.type === "inline") {
|
||||
return resolution.content;
|
||||
}
|
||||
return `# TODO: fill in details for ${endpointName}\nname = "${endpointName}"\n`;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Main
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const IGNORE_PREFIXES = [
|
||||
"databricks-llama-",
|
||||
"databricks-meta-llama-",
|
||||
"databricks-qwen",
|
||||
"databricks-gemma-",
|
||||
];
|
||||
|
||||
async function main() {
|
||||
console.log(
|
||||
`${dryRun ? "[DRY RUN] " : ""}${newOnly ? "[NEW ONLY] " : ""}Fetching Databricks foundation-models...`,
|
||||
);
|
||||
|
||||
const url = `https://${workspace}/api/2.0/serving-endpoints:foundation-models`;
|
||||
const res = await fetch(url, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
if (!res.ok) {
|
||||
console.error(`Failed to fetch API: ${res.status} ${res.statusText}`);
|
||||
console.error(await res.text().catch(() => ""));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const json = await res.json();
|
||||
const parsed = FoundationModelsResponse.safeParse(json);
|
||||
if (!parsed.success) {
|
||||
console.error("Invalid API response:", parsed.error.errors);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const endpoints = parsed.data.endpoints.filter(
|
||||
(e) =>
|
||||
!IGNORE_PREFIXES.some((p) => e.name.startsWith(p)) &&
|
||||
e.config?.served_entities?.some(
|
||||
(se) =>
|
||||
se.foundation_model?.ai_gateway_v2_supported === true &&
|
||||
se.foundation_model?.api_types?.includes("mlflow/v1/chat/completions"),
|
||||
),
|
||||
);
|
||||
|
||||
const existingFiles = new Set<string>();
|
||||
try {
|
||||
for await (const f of new Bun.Glob("*.toml").scan({ cwd: MODELS_DIR })) {
|
||||
existingFiles.add(f);
|
||||
}
|
||||
} catch {
|
||||
// directory may not exist yet
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Found ${endpoints.length} models in API, ${existingFiles.size} existing files\n`,
|
||||
);
|
||||
|
||||
const apiModelIds = new Set<string>();
|
||||
let created = 0;
|
||||
let updated = 0;
|
||||
let unchanged = 0;
|
||||
|
||||
for (const ep of endpoints) {
|
||||
const filename = `${ep.name}.toml`;
|
||||
apiModelIds.add(filename);
|
||||
const filePath = path.join(MODELS_DIR, filename);
|
||||
|
||||
const resolution = await resolveCanonical(ep.name);
|
||||
const newContent = formatToml(resolution, ep.name);
|
||||
const tag = resolution?.type === "extends" ? `extends ${resolution.from}` : resolution?.type ?? "stub";
|
||||
|
||||
const existed = existsSync(filePath);
|
||||
if (!existed) {
|
||||
created++;
|
||||
if (dryRun) {
|
||||
console.log(`[DRY RUN] Would create: ${filename} → ${tag}`);
|
||||
} else {
|
||||
await mkdir(MODELS_DIR, { recursive: true });
|
||||
await Bun.write(filePath, newContent);
|
||||
console.log(`Created: ${filename} → ${tag}`);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (newOnly) {
|
||||
unchanged++;
|
||||
continue;
|
||||
}
|
||||
|
||||
const existingContent = await readFile(filePath, "utf8");
|
||||
if (existingContent === newContent) {
|
||||
unchanged++;
|
||||
continue;
|
||||
}
|
||||
|
||||
updated++;
|
||||
if (dryRun) {
|
||||
console.log(`[DRY RUN] Would update: ${filename} → ${tag}`);
|
||||
} else {
|
||||
await Bun.write(filePath, newContent);
|
||||
console.log(`Updated: ${filename} → ${tag}`);
|
||||
}
|
||||
}
|
||||
|
||||
const orphaned: string[] = [];
|
||||
for (const file of existingFiles) {
|
||||
if (!apiModelIds.has(file)) {
|
||||
orphaned.push(file);
|
||||
console.log(`Warning: Orphaned file (not in API): ${file}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("");
|
||||
if (dryRun) {
|
||||
console.log(
|
||||
`Summary: ${created} would be created, ${updated} would be updated, ${unchanged} unchanged, ${orphaned.length} orphaned`,
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
`Summary: ${created} created, ${updated} updated, ${unchanged} unchanged, ${orphaned.length} orphaned`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await main();
|
||||
@@ -1,732 +0,0 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
/**
|
||||
* Generates DigitalOcean model TOML files from two public APIs:
|
||||
*
|
||||
* - https://api.digitalocean.com/v2/gen-ai/models (model metadata, lifecycle, modalities, limits)
|
||||
* - https://www.digitalocean.com/api/static-content/v1/products (pricing, including >200k tiers)
|
||||
*
|
||||
* The v2 models API requires a DigitalOcean personal access token or model access key,
|
||||
* read from the DIGITALOCEAN_API_TOKEN environment variable (or --api-key flag).
|
||||
* The static-content pricing API is public and requires no auth.
|
||||
*
|
||||
* Cache pricing (cache_read, cache_write) is NOT available from any DO API and is
|
||||
* preserved from existing TOML files when present.
|
||||
*
|
||||
* Fields the APIs cannot provide (preserved from existing TOMLs, never overwritten):
|
||||
* family, knowledge, open_weights, interleaved, attachment, release_date,
|
||||
* cache_read, cache_write
|
||||
*
|
||||
* Flags:
|
||||
* --dry-run Preview changes without writing files
|
||||
* --new-only Only create new models, skip updating existing ones
|
||||
* --api-key=<key> DigitalOcean API key (overrides DIGITALOCEAN_API_TOKEN env var)
|
||||
*/
|
||||
|
||||
import { z } from "zod";
|
||||
import path from "node:path";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
import { ModelFamilyValues } from "../src/family.js";
|
||||
|
||||
const MODELS_API = "https://api.digitalocean.com/v2/gen-ai/models";
|
||||
const PRICING_API = "https://www.digitalocean.com/api/static-content/v1/products";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// v2 models API schema
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const DoModel = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
lifecycle_status: z.string(),
|
||||
type: z.string().optional(),
|
||||
thinking: z.boolean().optional(),
|
||||
context_window: z.union([z.number(), z.string()]).optional(),
|
||||
modalities: z
|
||||
.object({
|
||||
input: z.array(z.string()).optional(),
|
||||
output: z.array(z.string()).optional(),
|
||||
})
|
||||
.optional(),
|
||||
settings: z
|
||||
.array(
|
||||
z.object({
|
||||
name: z.string(),
|
||||
max: z.number().optional(),
|
||||
default_value: z.number().optional(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
created_at: z.string().optional(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
const DoModelsResponse = z
|
||||
.object({
|
||||
models: z.array(DoModel),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// static-content pricing API schema
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const PricingEntry = z
|
||||
.object({
|
||||
name: z.string(),
|
||||
slug: z.string(),
|
||||
model: z.string(),
|
||||
prompt_tokens: z.string().optional(), // "≤200k" | ">200k" | undefined
|
||||
price: z.object({ rate: z.number() }),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
const StaticContentResponse = z
|
||||
.object({
|
||||
gradient: z.object({
|
||||
models: z.array(PricingEntry),
|
||||
}),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Derived pricing map
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
interface ModelPricing {
|
||||
input: number;
|
||||
output: number;
|
||||
inputOver200k?: number;
|
||||
outputOver200k?: number;
|
||||
}
|
||||
|
||||
// Map marketing names from /v1/products to API model IDs from /v2/gen-ai/models.
|
||||
// The pricing API uses display names, not the machine IDs, so this table is the
|
||||
// join key. Add entries here when DO adds new models with tiered pricing.
|
||||
const PRICING_NAME_MAP: Record<string, string> = {
|
||||
// Anthropic
|
||||
"claude sonnet 4.6": "anthropic-claude-4.6-sonnet",
|
||||
"claude sonnet 4.5": "anthropic-claude-4.5-sonnet",
|
||||
"claude sonnet 4": "anthropic-claude-sonnet-4",
|
||||
"claude haiku 4.5": "anthropic-claude-haiku-4.5",
|
||||
"claude opus 4.6": "anthropic-claude-opus-4.6",
|
||||
"claude opus 4.5": "anthropic-claude-opus-4.5",
|
||||
"claude opus 4.1": "anthropic-claude-4.1-opus",
|
||||
"claude opus 4": "anthropic-claude-opus-4",
|
||||
// OpenAI
|
||||
"gpt-5.4": "openai-gpt-5.4",
|
||||
"gpt-5.4 mini": "openai-gpt-5.4-mini",
|
||||
"gpt-5.4 nano": "openai-gpt-5.4-nano",
|
||||
"gpt-5.4 pro": "openai-gpt-5.4-pro",
|
||||
"gpt-5.3-codex": "openai-gpt-5.3-codex",
|
||||
"gpt-5.2": "openai-gpt-5.2",
|
||||
"gpt-5.2 pro": "openai-gpt-5.2-pro",
|
||||
"gpt-5.1-codex-max": "openai-gpt-5.1-codex-max",
|
||||
"gpt-5": "openai-gpt-5",
|
||||
"gpt-5 mini": "openai-gpt-5-mini",
|
||||
"gpt-5 nano": "openai-gpt-5-nano",
|
||||
"gpt-4.1": "openai-gpt-4.1",
|
||||
"gpt image 1": "openai-gpt-image-1",
|
||||
"gpt image 1.5": "openai-gpt-image-1.5",
|
||||
"gpt-oss-120b": "openai-gpt-oss-120b",
|
||||
"gpt-oss-20b": "openai-gpt-oss-20b",
|
||||
"gpt-4o": "openai-gpt-4o",
|
||||
"gpt-4o mini": "openai-gpt-4o-mini",
|
||||
"o1": "openai-o1",
|
||||
"o3-mini": "openai-o3-mini",
|
||||
// DeepSeek
|
||||
"deepseek r1 distill llama 70b": "deepseek-r1-distill-llama-70b",
|
||||
// Llama
|
||||
"llama 3.3 70b": "llama3.3-70b-instruct",
|
||||
// DO-hosted
|
||||
"qwen3-32b": "alibaba-qwen3-32b",
|
||||
"minimax m2.5 (public preview)": "minimax-m2.5",
|
||||
"kimi k2.5": "kimi-k2.5",
|
||||
"nvidia nemotron 3 super 120b (public preview)": "nvidia-nemotron-3-super-120b",
|
||||
"glm 5": "glm-5",
|
||||
};
|
||||
|
||||
function normalizeDisplayName(raw: string): string {
|
||||
// Strip " Input Tokens" / " Output Tokens" suffix and lowercase
|
||||
return raw
|
||||
.replace(/\s+(input|output)\s+tokens$/i, "")
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
function buildPricingMap(entries: z.infer<typeof PricingEntry>[]): Map<string, ModelPricing> {
|
||||
const map = new Map<string, ModelPricing>();
|
||||
|
||||
for (const entry of entries) {
|
||||
const displayName = normalizeDisplayName(entry.name);
|
||||
const modelId = PRICING_NAME_MAP[displayName];
|
||||
if (!modelId) continue;
|
||||
|
||||
const isInput = entry.name.toLowerCase().includes("input tokens");
|
||||
const isOver200k = entry.prompt_tokens === ">200k";
|
||||
// Round to avoid float noise (e.g. 0.9900000000000001)
|
||||
const rate = Math.round(entry.price.rate * 10000) / 10000;
|
||||
|
||||
const existing = map.get(modelId) ?? ({} as ModelPricing);
|
||||
|
||||
if (isInput && isOver200k) existing.inputOver200k = rate;
|
||||
else if (!isInput && isOver200k) existing.outputOver200k = rate;
|
||||
else if (isInput) existing.input = rate;
|
||||
else existing.output = rate;
|
||||
|
||||
map.set(modelId, existing);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Existing TOML shape (fields we read and may preserve)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
interface ExistingModel {
|
||||
name?: string;
|
||||
family?: string;
|
||||
attachment?: boolean;
|
||||
reasoning?: boolean;
|
||||
tool_call?: boolean;
|
||||
structured_output?: boolean;
|
||||
temperature?: boolean;
|
||||
knowledge?: string;
|
||||
release_date?: string;
|
||||
last_updated?: string;
|
||||
open_weights?: boolean;
|
||||
interleaved?: boolean | { field: string };
|
||||
status?: string;
|
||||
cost?: {
|
||||
input?: number;
|
||||
output?: number;
|
||||
cache_read?: number;
|
||||
cache_write?: number;
|
||||
context_over_200k?: {
|
||||
input?: number;
|
||||
output?: number;
|
||||
cache_read?: number;
|
||||
cache_write?: number;
|
||||
context_min?: number;
|
||||
};
|
||||
tiers?: Array<{
|
||||
tier: {
|
||||
type?: "context";
|
||||
size: number;
|
||||
};
|
||||
input?: number;
|
||||
output?: number;
|
||||
cache_read?: number;
|
||||
cache_write?: number;
|
||||
}>;
|
||||
};
|
||||
limit?: {
|
||||
context?: number;
|
||||
input?: number;
|
||||
output?: number;
|
||||
};
|
||||
modalities?: {
|
||||
input?: string[];
|
||||
output?: string[];
|
||||
};
|
||||
}
|
||||
|
||||
async function loadExisting(filePath: string): Promise<ExistingModel | null> {
|
||||
const file = Bun.file(filePath);
|
||||
if (!(await file.exists())) return null;
|
||||
try {
|
||||
const mod = await import(filePath, { with: { type: "toml" } });
|
||||
return mod.default as ExistingModel;
|
||||
} catch (e) {
|
||||
console.warn(`Warning: failed to parse ${filePath}:`, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Merged model shape (what we write)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
interface MergedModel {
|
||||
name: string;
|
||||
family?: string;
|
||||
attachment: boolean;
|
||||
reasoning: boolean;
|
||||
tool_call: boolean;
|
||||
structured_output?: boolean;
|
||||
temperature: boolean;
|
||||
knowledge?: string;
|
||||
release_date: string;
|
||||
last_updated: string;
|
||||
open_weights: boolean;
|
||||
interleaved?: boolean | { field: string };
|
||||
status?: string;
|
||||
cost?: {
|
||||
input: number;
|
||||
output: number;
|
||||
cache_read?: number;
|
||||
cache_write?: number;
|
||||
context_over_200k?: {
|
||||
input: number;
|
||||
output: number;
|
||||
cache_read?: number;
|
||||
cache_write?: number;
|
||||
context_min?: number;
|
||||
};
|
||||
};
|
||||
limit: {
|
||||
context: number;
|
||||
output: number;
|
||||
};
|
||||
modalities: {
|
||||
input: string[];
|
||||
output: string[];
|
||||
};
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const VALID_INPUT_MODALITIES = new Set(["text", "audio", "image", "video", "pdf"]);
|
||||
const VALID_OUTPUT_MODALITIES = new Set(["text", "audio", "image", "video", "pdf"]);
|
||||
|
||||
function filterInputModalities(raw: string[]): string[] {
|
||||
return raw.filter((m) => VALID_INPUT_MODALITIES.has(m));
|
||||
}
|
||||
|
||||
function filterOutputModalities(raw: string[]): string[] {
|
||||
// "code" is not a valid modality in the schema — map to "text"
|
||||
return [...new Set(raw.map((m) => (m === "code" ? "text" : m)).filter((m) => VALID_OUTPUT_MODALITIES.has(m)))];
|
||||
}
|
||||
|
||||
function getTodayDate(): string {
|
||||
return new Date().toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
function formatNumber(n: number): string {
|
||||
return n >= 1000 ? n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "_") : n.toString();
|
||||
}
|
||||
|
||||
function inferFamily(modelId: string, modelName: string): string | undefined {
|
||||
const sorted = [...ModelFamilyValues].sort((a, b) => b.length - a.length);
|
||||
const targets = [modelId.toLowerCase(), modelName.toLowerCase()];
|
||||
for (const family of sorted) {
|
||||
const f = family.toLowerCase();
|
||||
for (const t of targets) {
|
||||
if (t.includes(f)) return family;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getExistingLongContextCost(existing: ExistingModel | null) {
|
||||
const tier = existing?.cost?.tiers?.find(
|
||||
(tier) =>
|
||||
(tier.tier.type === undefined || tier.tier.type === "context") &&
|
||||
tier.tier.size >= 200_000,
|
||||
);
|
||||
if (tier) {
|
||||
return {
|
||||
...tier,
|
||||
context_min: tier.tier.size,
|
||||
};
|
||||
}
|
||||
|
||||
return existing?.cost?.context_over_200k === undefined
|
||||
? undefined
|
||||
: {
|
||||
...existing.cost.context_over_200k,
|
||||
context_min: 200_000,
|
||||
};
|
||||
}
|
||||
|
||||
function getLongContextMin(cost: { context_min?: number }) {
|
||||
return cost.context_min ?? 200_000;
|
||||
}
|
||||
|
||||
function formatInlineNumber(n: number): string {
|
||||
return n >= 1000 ? n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "_") : n.toString();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Merge API data with existing TOML
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function mergeModel(
|
||||
apiModel: z.infer<typeof DoModel>,
|
||||
pricing: ModelPricing | undefined,
|
||||
existing: ExistingModel | null,
|
||||
): MergedModel {
|
||||
const rawInput = apiModel.modalities?.input ?? [];
|
||||
const rawOutput = apiModel.modalities?.output ?? [];
|
||||
const inputMods = filterInputModalities(rawInput.length > 0 ? rawInput : existing?.modalities?.input ?? ["text"]);
|
||||
const outputMods = filterOutputModalities(rawOutput.length > 0 ? rawOutput : existing?.modalities?.output ?? ["text"]);
|
||||
|
||||
const maxTokensSetting = apiModel.settings?.find((s) => s.name === "max_tokens");
|
||||
const maxTokens = maxTokensSetting?.max ?? existing?.limit?.output ?? 0;
|
||||
|
||||
const rawContext = apiModel.context_window;
|
||||
const contextWindow =
|
||||
rawContext !== undefined
|
||||
? typeof rawContext === "string"
|
||||
? parseInt(rawContext, 10)
|
||||
: rawContext
|
||||
: (existing?.limit?.context ?? 0);
|
||||
|
||||
const isDeprecated = apiModel.lifecycle_status === "end_of_life";
|
||||
|
||||
// Fields preserved from existing TOML (APIs don't provide these)
|
||||
const family = existing?.family ?? inferFamily(apiModel.id, apiModel.name);
|
||||
const knowledge = existing?.knowledge;
|
||||
const openWeights = existing?.open_weights ?? false;
|
||||
const interleaved = existing?.interleaved;
|
||||
const attachment = existing?.attachment ?? inputMods.some((m) => m !== "text");
|
||||
|
||||
// reasoning: trust existing if set, else use API thinking flag as a hint
|
||||
// (thinking flag is unreliable for non-LLM models so gate on output modality)
|
||||
const isTextOutput = outputMods.includes("text") && !outputMods.includes("image") && !outputMods.includes("video");
|
||||
const reasoning = existing?.reasoning ?? (isTextOutput && (apiModel.thinking ?? false));
|
||||
|
||||
// tool_call: no API signal, preserve existing or default true for text models
|
||||
const toolCall = existing?.tool_call ?? isTextOutput;
|
||||
|
||||
// temperature: no API signal, preserve or default true
|
||||
const temperature = existing?.temperature ?? true;
|
||||
|
||||
// structured_output: no API signal, preserve only
|
||||
const structuredOutput = existing?.structured_output;
|
||||
|
||||
const releaseDate = existing?.release_date ?? apiModel.created_at?.slice(0, 10) ?? getTodayDate();
|
||||
|
||||
const merged: MergedModel = {
|
||||
name: apiModel.name,
|
||||
family,
|
||||
attachment,
|
||||
reasoning,
|
||||
tool_call: toolCall,
|
||||
temperature,
|
||||
release_date: releaseDate,
|
||||
last_updated: getTodayDate(),
|
||||
open_weights: openWeights,
|
||||
...(structuredOutput !== undefined && { structured_output: structuredOutput }),
|
||||
...(knowledge && { knowledge }),
|
||||
...(interleaved !== undefined && { interleaved }),
|
||||
...(isDeprecated && { status: "deprecated" }),
|
||||
limit: { context: contextWindow, output: maxTokens },
|
||||
modalities: { input: inputMods, output: outputMods },
|
||||
};
|
||||
|
||||
// Pricing: static-content API is the sole source of truth for prices.
|
||||
// The v2 models API pricing is intentionally ignored. If a model has no
|
||||
// entry in the static-content API, preserve existing TOML prices.
|
||||
const inputPrice = pricing?.input ?? existing?.cost?.input;
|
||||
const outputPrice = pricing?.output ?? existing?.cost?.output;
|
||||
|
||||
if (inputPrice !== undefined && outputPrice !== undefined) {
|
||||
merged.cost = {
|
||||
input: inputPrice,
|
||||
output: outputPrice,
|
||||
// Always preserve cache pricing — not available from any DO API
|
||||
...(existing?.cost?.cache_read !== undefined && { cache_read: existing.cost.cache_read }),
|
||||
...(existing?.cost?.cache_write !== undefined && { cache_write: existing.cost.cache_write }),
|
||||
};
|
||||
|
||||
// Context-tiered pricing (>200k) from the static-content API
|
||||
const existingLongContextCost = getExistingLongContextCost(existing);
|
||||
if (pricing?.inputOver200k !== undefined && pricing?.outputOver200k !== undefined) {
|
||||
merged.cost.context_over_200k = {
|
||||
input: pricing.inputOver200k,
|
||||
output: pricing.outputOver200k,
|
||||
context_min: existingLongContextCost?.context_min ?? 200_000,
|
||||
...(existingLongContextCost?.cache_read !== undefined && {
|
||||
cache_read: existingLongContextCost.cache_read,
|
||||
}),
|
||||
...(existingLongContextCost?.cache_write !== undefined && {
|
||||
cache_write: existingLongContextCost.cache_write,
|
||||
}),
|
||||
};
|
||||
} else if (existingLongContextCost) {
|
||||
// Preserve manually-entered tiered pricing if API has no data
|
||||
merged.cost.context_over_200k = {
|
||||
input: existingLongContextCost.input ?? inputPrice,
|
||||
output: existingLongContextCost.output ?? outputPrice,
|
||||
context_min: existingLongContextCost.context_min,
|
||||
...(existingLongContextCost.cache_read !== undefined && {
|
||||
cache_read: existingLongContextCost.cache_read,
|
||||
}),
|
||||
...(existingLongContextCost.cache_write !== undefined && {
|
||||
cache_write: existingLongContextCost.cache_write,
|
||||
}),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// TOML serialiser
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function formatToml(model: MergedModel): string {
|
||||
const lines: string[] = [];
|
||||
|
||||
lines.push(`name = "${model.name.replace(/"/g, '\\"')}"`);
|
||||
if (model.family) lines.push(`family = "${model.family}"`);
|
||||
lines.push(`release_date = "${model.release_date}"`);
|
||||
lines.push(`last_updated = "${model.last_updated}"`);
|
||||
lines.push(`attachment = ${model.attachment}`);
|
||||
lines.push(`reasoning = ${model.reasoning}`);
|
||||
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) lines.push(`knowledge = "${model.knowledge}"`);
|
||||
lines.push(`open_weights = ${model.open_weights}`);
|
||||
if (model.status) lines.push(`status = "${model.status}"`);
|
||||
|
||||
if (model.interleaved !== undefined) {
|
||||
lines.push("");
|
||||
if (model.interleaved === true) {
|
||||
lines.push(`interleaved = true`);
|
||||
} else if (typeof model.interleaved === "object") {
|
||||
lines.push(`[interleaved]`);
|
||||
lines.push(`field = "${model.interleaved.field}"`);
|
||||
}
|
||||
}
|
||||
|
||||
if (model.cost) {
|
||||
lines.push("");
|
||||
lines.push(`[cost]`);
|
||||
lines.push(`input = ${model.cost.input}`);
|
||||
lines.push(`output = ${model.cost.output}`);
|
||||
if (model.cost.cache_read !== undefined) lines.push(`cache_read = ${model.cost.cache_read}`);
|
||||
if (model.cost.cache_write !== undefined) lines.push(`cache_write = ${model.cost.cache_write}`);
|
||||
|
||||
if (model.cost.context_over_200k) {
|
||||
lines.push("");
|
||||
lines.push(`[[cost.tiers]]`);
|
||||
lines.push(`tier = { size = ${formatInlineNumber(getLongContextMin(model.cost.context_over_200k))} }`);
|
||||
lines.push(`input = ${model.cost.context_over_200k.input}`);
|
||||
lines.push(`output = ${model.cost.context_over_200k.output}`);
|
||||
if (model.cost.context_over_200k.cache_read !== undefined)
|
||||
lines.push(`cache_read = ${model.cost.context_over_200k.cache_read}`);
|
||||
if (model.cost.context_over_200k.cache_write !== undefined)
|
||||
lines.push(`cache_write = ${model.cost.context_over_200k.cache_write}`);
|
||||
}
|
||||
}
|
||||
|
||||
lines.push("");
|
||||
lines.push(`[limit]`);
|
||||
lines.push(`context = ${formatNumber(model.limit.context)}`);
|
||||
lines.push(`output = ${formatNumber(model.limit.output)}`);
|
||||
|
||||
lines.push("");
|
||||
lines.push(`[modalities]`);
|
||||
lines.push(`input = [${model.modalities.input.map((m) => `"${m}"`).join(", ")}]`);
|
||||
lines.push(`output = [${model.modalities.output.map((m) => `"${m}"`).join(", ")}]`);
|
||||
|
||||
return lines.join("\n") + "\n";
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Change detection
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
interface Change {
|
||||
field: string;
|
||||
oldValue: string;
|
||||
newValue: string;
|
||||
}
|
||||
|
||||
function formatValue(val: unknown): string {
|
||||
if (val === undefined) return "(none)";
|
||||
if (Array.isArray(val)) return `[${val.join(", ")}]`;
|
||||
if (typeof val === "number") return formatNumber(val);
|
||||
return String(val);
|
||||
}
|
||||
|
||||
function detectChanges(existing: ExistingModel | null, merged: MergedModel): Change[] {
|
||||
if (!existing) return [];
|
||||
|
||||
const changes: Change[] = [];
|
||||
const EPSILON = 0.001;
|
||||
|
||||
const compare = (field: string, oldVal: unknown, newVal: unknown) => {
|
||||
if (oldVal === undefined && newVal === undefined) return;
|
||||
const isDiff = field.startsWith("cost.")
|
||||
? Math.abs((oldVal as number ?? 0) - (newVal as number ?? 0)) > EPSILON
|
||||
: JSON.stringify(oldVal) !== JSON.stringify(newVal);
|
||||
if (isDiff) changes.push({ field, oldValue: formatValue(oldVal), newValue: formatValue(newVal) });
|
||||
};
|
||||
|
||||
compare("name", existing.name, merged.name);
|
||||
compare("reasoning", existing.reasoning, merged.reasoning);
|
||||
compare("tool_call", existing.tool_call, merged.tool_call);
|
||||
compare("attachment", existing.attachment, merged.attachment);
|
||||
compare("status", existing.status, merged.status);
|
||||
compare("cost.input", existing.cost?.input, merged.cost?.input);
|
||||
compare("cost.output", existing.cost?.output, merged.cost?.output);
|
||||
const existingLongContextCost = getExistingLongContextCost(existing);
|
||||
compare("cost.context_over_200k.input", existingLongContextCost?.input, merged.cost?.context_over_200k?.input);
|
||||
compare("cost.context_over_200k.output", existingLongContextCost?.output, merged.cost?.context_over_200k?.output);
|
||||
compare("limit.context", existing.limit?.context, merged.limit.context);
|
||||
compare("limit.output", existing.limit?.output, merged.limit.output);
|
||||
compare("modalities.input", existing.modalities?.input, merged.modalities.input);
|
||||
compare("modalities.output", existing.modalities?.output, merged.modalities.output);
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Main
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function main() {
|
||||
const args = process.argv.slice(2);
|
||||
const dryRun = args.includes("--dry-run");
|
||||
const newOnly = args.includes("--new-only");
|
||||
|
||||
// Resolve API key
|
||||
const apiKeyArg = args.find((a) => a.startsWith("--api-key"));
|
||||
const apiKey =
|
||||
(apiKeyArg?.includes("=") ? apiKeyArg.split("=")[1] : args[args.indexOf(apiKeyArg!) + 1]) ??
|
||||
process.env.DIGITALOCEAN_API_TOKEN;
|
||||
|
||||
if (!apiKey) {
|
||||
console.error("Error: DIGITALOCEAN_API_TOKEN is required (or pass --api-key=<key>)");
|
||||
console.error("Get one from: https://cloud.digitalocean.com/account/api/tokens");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const modelsDir = path.join(import.meta.dirname, "..", "..", "..", "providers", "digitalocean", "models");
|
||||
|
||||
const prefix = dryRun ? "[DRY RUN] " : "";
|
||||
console.log(`${prefix}Fetching DigitalOcean models from API...`);
|
||||
|
||||
// Fetch both APIs in parallel
|
||||
const [modelsRes, pricingRes] = await Promise.all([
|
||||
fetch(MODELS_API, { headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" } }),
|
||||
fetch(PRICING_API, { headers: { "User-Agent": "models.dev/digitalocean-sync" } }),
|
||||
]);
|
||||
|
||||
if (!modelsRes.ok) {
|
||||
console.error(`Failed to fetch models API: ${modelsRes.status} ${modelsRes.statusText}`);
|
||||
if (modelsRes.status === 401 || modelsRes.status === 403)
|
||||
console.error("Check your DIGITALOCEAN_API_TOKEN has read access.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!pricingRes.ok) {
|
||||
console.error(`Failed to fetch pricing API: ${pricingRes.status} ${pricingRes.statusText}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const modelsParsed = DoModelsResponse.safeParse(await modelsRes.json());
|
||||
if (!modelsParsed.success) {
|
||||
console.error("Unexpected models API response:", modelsParsed.error.errors);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const pricingParsed = StaticContentResponse.safeParse(await pricingRes.json());
|
||||
if (!pricingParsed.success) {
|
||||
console.error("Unexpected pricing API response:", pricingParsed.error.errors);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const apiModels = modelsParsed.data.models;
|
||||
const pricingMap = buildPricingMap(pricingParsed.data.gradient.models);
|
||||
|
||||
// Collect existing TOML filenames for orphan detection
|
||||
const existingFiles = new Set<string>();
|
||||
for await (const file of new Bun.Glob("**/*.toml").scan({ cwd: modelsDir, absolute: false })) {
|
||||
existingFiles.add(file);
|
||||
}
|
||||
|
||||
console.log(`Found ${apiModels.length} models in API, ${existingFiles.size} existing TOML files\n`);
|
||||
|
||||
const apiModelFiles = new Set<string>();
|
||||
let created = 0;
|
||||
let updated = 0;
|
||||
let unchanged = 0;
|
||||
|
||||
for (const apiModel of apiModels) {
|
||||
// Skip non-text models that opencode can't use: image, video, audio, embedding, reranking
|
||||
const outputMods = filterOutputModalities(apiModel.modalities?.output ?? []);
|
||||
const isTextModel = outputMods.includes("text");
|
||||
const isEmbedding = apiModel.type === "embedding";
|
||||
const isReranking = apiModel.type === "reranking";
|
||||
if (!isTextModel || isEmbedding || isReranking) continue;
|
||||
|
||||
// Model IDs may contain slashes (e.g. fal-ai/flux/schnell) — use as subpath
|
||||
const relativePath = `${apiModel.id}.toml`;
|
||||
const filePath = path.join(modelsDir, relativePath);
|
||||
const dirPath = path.dirname(filePath);
|
||||
|
||||
apiModelFiles.add(relativePath);
|
||||
|
||||
const existing = await loadExisting(filePath);
|
||||
const pricing = pricingMap.get(apiModel.id);
|
||||
const merged = mergeModel(apiModel, pricing, existing);
|
||||
const toml = formatToml(merged);
|
||||
|
||||
if (existing === null) {
|
||||
created++;
|
||||
if (dryRun) {
|
||||
console.log(`[DRY RUN] Would create: ${relativePath}`);
|
||||
console.log(` name = "${merged.name}"`);
|
||||
if (pricing) console.log(` pricing: $${merged.cost?.input}/$${merged.cost?.output} per M tokens`);
|
||||
if (merged.family) console.log(` family = "${merged.family}" (inferred)`);
|
||||
console.log("");
|
||||
} else {
|
||||
await mkdir(dirPath, { recursive: true });
|
||||
await Bun.write(filePath, toml);
|
||||
console.log(`Created: ${relativePath}`);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (newOnly) {
|
||||
unchanged++;
|
||||
continue;
|
||||
}
|
||||
|
||||
const changes = detectChanges(existing, merged);
|
||||
if (changes.length > 0) {
|
||||
updated++;
|
||||
if (dryRun) {
|
||||
console.log(`[DRY RUN] Would update: ${relativePath}`);
|
||||
} else {
|
||||
await mkdir(dirPath, { recursive: true });
|
||||
await Bun.write(filePath, toml);
|
||||
console.log(`Updated: ${relativePath}`);
|
||||
}
|
||||
for (const c of changes) console.log(` ${c.field}: ${c.oldValue} → ${c.newValue}`);
|
||||
console.log("");
|
||||
} else {
|
||||
unchanged++;
|
||||
}
|
||||
}
|
||||
|
||||
// Orphan detection: files in the TOML directory but not in the API
|
||||
const orphaned: string[] = [];
|
||||
for (const file of existingFiles) {
|
||||
if (!apiModelFiles.has(file)) {
|
||||
orphaned.push(file);
|
||||
console.log(`Warning: orphaned file (not in API): ${file}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("");
|
||||
if (dryRun) {
|
||||
console.log(
|
||||
`Summary: ${created} would be created, ${updated} would be updated, ${unchanged} unchanged, ${orphaned.length} orphaned`,
|
||||
);
|
||||
} else {
|
||||
console.log(`Summary: ${created} created, ${updated} updated, ${unchanged} unchanged, ${orphaned.length} orphaned`);
|
||||
}
|
||||
}
|
||||
|
||||
await main();
|
||||
@@ -162,18 +162,7 @@ interface ExistingModel {
|
||||
output?: number;
|
||||
cache_read?: number;
|
||||
cache_write?: number;
|
||||
context_min?: number;
|
||||
};
|
||||
tiers?: Array<{
|
||||
tier: {
|
||||
type?: "context";
|
||||
size: number;
|
||||
};
|
||||
input?: number;
|
||||
output?: number;
|
||||
cache_read?: number;
|
||||
cache_write?: number;
|
||||
}>;
|
||||
};
|
||||
limit?: {
|
||||
context?: number;
|
||||
@@ -206,30 +195,6 @@ async function loadExistingModel(filePath: string): Promise<ExistingModel | null
|
||||
}
|
||||
}
|
||||
|
||||
function getExistingLongContextMin(existing: ExistingModel | null) {
|
||||
return (
|
||||
existing?.cost?.tiers?.find(
|
||||
(tier) =>
|
||||
(tier.tier.type === undefined || tier.tier.type === "context") &&
|
||||
tier.tier.size >= 200_000,
|
||||
)?.tier.size ?? 200_000
|
||||
);
|
||||
}
|
||||
|
||||
function getExistingLongContextCost(existing: ExistingModel | null) {
|
||||
return (
|
||||
existing?.cost?.tiers?.find(
|
||||
(tier) =>
|
||||
(tier.tier.type === undefined || tier.tier.type === "context") &&
|
||||
tier.tier.size >= 200_000,
|
||||
) ?? existing?.cost?.context_over_200k
|
||||
);
|
||||
}
|
||||
|
||||
function getLongContextMin(cost: { context_min?: number }) {
|
||||
return cost.context_min ?? 200_000;
|
||||
}
|
||||
|
||||
interface MergedModel {
|
||||
name: string;
|
||||
family?: string;
|
||||
@@ -254,7 +219,6 @@ interface MergedModel {
|
||||
output: number;
|
||||
cache_read?: number;
|
||||
cache_write?: number;
|
||||
context_min?: number;
|
||||
};
|
||||
};
|
||||
limit: {
|
||||
@@ -328,7 +292,6 @@ function mergeModel(
|
||||
merged.cost.context_over_200k = {
|
||||
input: spec.pricing.extended.input.usd,
|
||||
output: spec.pricing.extended.output.usd,
|
||||
context_min: spec.pricing.extended.context_token_threshold,
|
||||
...(spec.pricing.extended.cache_input && { cache_read: spec.pricing.extended.cache_input.usd }),
|
||||
...(spec.pricing.extended.cache_write && { cache_write: spec.pricing.extended.cache_write.usd }),
|
||||
};
|
||||
@@ -403,8 +366,7 @@ function formatToml(model: MergedModel): string {
|
||||
|
||||
if (model.cost.context_over_200k) {
|
||||
lines.push("");
|
||||
lines.push(`[[cost.tiers]]`);
|
||||
lines.push(`tier = { size = ${formatNumber(getLongContextMin(model.cost.context_over_200k))} }`);
|
||||
lines.push(`[cost.context_over_200k]`);
|
||||
lines.push(`input = ${model.cost.context_over_200k.input}`);
|
||||
lines.push(`output = ${model.cost.context_over_200k.output}`);
|
||||
if (model.cost.context_over_200k.cache_read !== undefined) {
|
||||
@@ -476,11 +438,10 @@ function detectChanges(
|
||||
compare("cost.output", existing.cost?.output, merged.cost?.output);
|
||||
compare("cost.cache_read", existing.cost?.cache_read, merged.cost?.cache_read);
|
||||
compare("cost.cache_write", existing.cost?.cache_write, merged.cost?.cache_write);
|
||||
const existingLongContextCost = getExistingLongContextCost(existing);
|
||||
compare("cost.context_over_200k.input", existingLongContextCost?.input, merged.cost?.context_over_200k?.input);
|
||||
compare("cost.context_over_200k.output", existingLongContextCost?.output, merged.cost?.context_over_200k?.output);
|
||||
compare("cost.context_over_200k.cache_read", existingLongContextCost?.cache_read, merged.cost?.context_over_200k?.cache_read);
|
||||
compare("cost.context_over_200k.cache_write", existingLongContextCost?.cache_write, merged.cost?.context_over_200k?.cache_write);
|
||||
compare("cost.context_over_200k.input", existing.cost?.context_over_200k?.input, merged.cost?.context_over_200k?.input);
|
||||
compare("cost.context_over_200k.output", existing.cost?.context_over_200k?.output, merged.cost?.context_over_200k?.output);
|
||||
compare("cost.context_over_200k.cache_read", existing.cost?.context_over_200k?.cache_read, merged.cost?.context_over_200k?.cache_read);
|
||||
compare("cost.context_over_200k.cache_write", existing.cost?.context_over_200k?.cache_write, merged.cost?.context_over_200k?.cache_write);
|
||||
compare("limit.context", existing.limit?.context, merged.limit.context);
|
||||
compare("limit.output", existing.limit?.output, merged.limit.output);
|
||||
compare("modalities.input", existing.modalities?.input, merged.modalities.input);
|
||||
|
||||
@@ -1,389 +0,0 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
import path from "node:path";
|
||||
import { mkdir, readdir, rm } from "node:fs/promises";
|
||||
import { z } from "zod";
|
||||
|
||||
import { AuthoredModel, AuthoredModelShape } from "../src/schema.js";
|
||||
import { openrouter } from "./sync/openrouter.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;
|
||||
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;
|
||||
files: Array<{ status: "created" | "updated" | "deleted"; path: string }>;
|
||||
}
|
||||
|
||||
export const providers = {
|
||||
openrouter,
|
||||
};
|
||||
|
||||
export const groups = {
|
||||
aggregators: ["openrouter"],
|
||||
} 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 }>();
|
||||
|
||||
for (const sourceModel of sourceModels) {
|
||||
const translated = provider.translateModel(sourceModel, {
|
||||
existing(id) {
|
||||
return existing.get(`${id}.toml`)?.toml;
|
||||
},
|
||||
});
|
||||
if (translated === undefined) continue;
|
||||
|
||||
const relativePath = `${translated.id}.toml`;
|
||||
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);
|
||||
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,
|
||||
): 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,
|
||||
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>");
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -1,142 +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";
|
||||
|
||||
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()),
|
||||
});
|
||||
|
||||
const OpenRouterResponse = z.object({
|
||||
data: z.array(OpenRouterModel),
|
||||
}).passthrough();
|
||||
|
||||
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: buildModel(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;
|
||||
}
|
||||
|
||||
function modalities(values: string[], fallback: string[]) {
|
||||
const allowed = new Set(["text", "audio", "image", "video", "pdf"]);
|
||||
const result = values
|
||||
.map((value) => value.toLowerCase())
|
||||
.map((value) => value === "file" ? "pdf" : value)
|
||||
.filter((value) => allowed.has(value));
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
function buildModel(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 },
|
||||
};
|
||||
}
|
||||
@@ -54,17 +54,12 @@ export const ModelFamilyValues = [
|
||||
// DeepSeek
|
||||
"deepseek",
|
||||
"deepseek-thinking",
|
||||
"deepseek-flash",
|
||||
"deepseek-flash-free",
|
||||
"deepseek-flash-think",
|
||||
|
||||
// Microsoft Phi
|
||||
"phi",
|
||||
|
||||
// Moonshot Kimi
|
||||
"kimi",
|
||||
"kimi-k2.5",
|
||||
"kimi-k2.6",
|
||||
"kimi-free",
|
||||
"kimi-thinking",
|
||||
|
||||
@@ -120,8 +115,8 @@ export const ModelFamilyValues = [
|
||||
// Hunyuan
|
||||
"hunyuan",
|
||||
|
||||
// Hy
|
||||
"Hy",
|
||||
// HY
|
||||
"HY",
|
||||
|
||||
// Yi
|
||||
"yi",
|
||||
@@ -210,10 +205,6 @@ export const ModelFamilyValues = [
|
||||
"mimo",
|
||||
"mimo-pro",
|
||||
"mimo-omni",
|
||||
"mimo-v2-pro",
|
||||
"mimo-v2-omni",
|
||||
"mimo-v2.5-pro",
|
||||
"mimo-v2.5",
|
||||
"mimo-pro-free",
|
||||
"mimo-omni-free",
|
||||
"mimo-flash-free",
|
||||
@@ -289,15 +280,9 @@ export const ModelFamilyValues = [
|
||||
// RNJ
|
||||
"rnj",
|
||||
|
||||
// Tecent Hy
|
||||
"hy3",
|
||||
"hy3-free",
|
||||
|
||||
// Ling & Ring (InclusionAI)
|
||||
"ling",
|
||||
"ling-flash-free",
|
||||
"ring",
|
||||
"ring-1t-free",
|
||||
|
||||
// Kat Coder
|
||||
"kat-coder",
|
||||
|
||||
@@ -2,9 +2,9 @@ import path from "path";
|
||||
import { mergeDeep } from "remeda";
|
||||
import { z } from "zod";
|
||||
|
||||
import { Provider, Model, AuthoredModel, AuthoredModelShape } from "./schema.js";
|
||||
import { Provider, Model } from "./schema.js";
|
||||
|
||||
const ExtendsModel = AuthoredModelShape
|
||||
const ExtendsModel = Model.sourceType()
|
||||
.partial()
|
||||
.extend({
|
||||
extends: z
|
||||
@@ -71,12 +71,12 @@ export async function generate(directory: string) {
|
||||
});
|
||||
continue;
|
||||
}
|
||||
const model = AuthoredModel.safeParse(toml);
|
||||
const model = Model.safeParse(toml);
|
||||
if (!model.success) {
|
||||
model.error.cause = { modelPath, toml };
|
||||
throw model.error;
|
||||
}
|
||||
provider.data.models[modelID] = normalizeModelCost(model.data);
|
||||
provider.data.models[modelID] = model.data;
|
||||
}
|
||||
result[providerID] = provider.data;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ export async function generate(directory: string) {
|
||||
}
|
||||
}
|
||||
|
||||
const model = Model.safeParse(normalizeCost(merged));
|
||||
const model = Model.safeParse(merged);
|
||||
if (!model.success) {
|
||||
model.error.cause = { modelPath: pendingModel.modelPath, toml: merged };
|
||||
throw model.error;
|
||||
@@ -155,51 +155,3 @@ export async function generate(directory: string) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function normalizeModelCost(model: z.infer<typeof AuthoredModel>): Model {
|
||||
return normalizeCost(model) as Model;
|
||||
}
|
||||
|
||||
function normalizeCost(model: Record<string, unknown>) {
|
||||
const cost = model.cost;
|
||||
if (cost === undefined || cost === null || typeof cost !== "object" || Array.isArray(cost)) {
|
||||
return model;
|
||||
}
|
||||
|
||||
const tiers = (cost as { tiers?: unknown }).tiers;
|
||||
if (!Array.isArray(tiers)) {
|
||||
return model;
|
||||
}
|
||||
|
||||
if (tiers.length !== 1) {
|
||||
return model;
|
||||
}
|
||||
|
||||
const contextOver200k = tiers.find((tier) => {
|
||||
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 type = (tierConfig as { type?: unknown }).type;
|
||||
const size = (tierConfig as { size?: unknown }).size;
|
||||
// context_over_200k is a legacy compatibility field. It intentionally
|
||||
// includes higher thresholds; cost.tiers carries the exact threshold.
|
||||
return (
|
||||
(type === undefined || type === "context") &&
|
||||
typeof size === "number" &&
|
||||
size >= 200_000
|
||||
);
|
||||
});
|
||||
|
||||
if (contextOver200k === undefined) {
|
||||
return model;
|
||||
}
|
||||
|
||||
const { tier: _tier, ...legacyCost } = contextOver200k as Record<string, unknown>;
|
||||
return {
|
||||
...model,
|
||||
cost: {
|
||||
...(cost as Record<string, unknown>),
|
||||
context_over_200k: legacyCost,
|
||||
},
|
||||
};
|
||||
}
|
||||
+102
-160
@@ -21,164 +21,110 @@ 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 CostTier = Cost.extend({
|
||||
tier: z
|
||||
.object({
|
||||
type: z.literal("context").default("context"),
|
||||
size: z.number().int().min(0, "Context tier size cannot be negative"),
|
||||
})
|
||||
.strict(),
|
||||
}).strict();
|
||||
|
||||
const AuthoredCost = Cost.extend({
|
||||
context_over_200k: z.never().optional(),
|
||||
tiers: z.array(CostTier).optional(),
|
||||
});
|
||||
|
||||
const OutputCost = Cost.extend({
|
||||
context_over_200k: Cost.optional(),
|
||||
tiers: z.array(CostTier).optional(),
|
||||
});
|
||||
|
||||
const ModelBase = z.object({
|
||||
id: z.string(),
|
||||
name: z.string().min(1, "Model name cannot be empty"),
|
||||
family: ModelFamily.optional(),
|
||||
attachment: z.boolean(),
|
||||
reasoning: z.boolean(),
|
||||
tool_call: z.boolean(),
|
||||
interleaved: z
|
||||
.union([
|
||||
z.literal(true),
|
||||
z
|
||||
.object({
|
||||
field: z.enum(["reasoning_content", "reasoning_details"]),
|
||||
})
|
||||
.strict(),
|
||||
])
|
||||
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, "Input price cannot be negative").optional(),
|
||||
cache_read: z
|
||||
.number()
|
||||
.min(0, "Cache read price cannot be negative")
|
||||
.optional(),
|
||||
structured_output: z.boolean().optional(),
|
||||
temperature: z.boolean().optional(),
|
||||
knowledge: z
|
||||
.string()
|
||||
.regex(/^\d{4}-\d{2}(-\d{2})?$/, {
|
||||
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(),
|
||||
});
|
||||
export const Model = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
name: z.string().min(1, "Model name cannot be empty"),
|
||||
family: ModelFamily.optional(),
|
||||
attachment: z.boolean(),
|
||||
reasoning: z.boolean(),
|
||||
tool_call: z.boolean(),
|
||||
interleaved: z
|
||||
.union([
|
||||
z.literal(true),
|
||||
z
|
||||
.object({
|
||||
field: z.enum(["reasoning_content", "reasoning_details"]),
|
||||
})
|
||||
.strict(),
|
||||
])
|
||||
.optional(),
|
||||
structured_output: z.boolean().optional(),
|
||||
temperature: z.boolean().optional(),
|
||||
knowledge: z
|
||||
.string()
|
||||
.regex(/^\d{4}-\d{2}(-\d{2})?$/, {
|
||||
message: "Must be in YYYY-MM or YYYY-MM-DD format",
|
||||
})
|
||||
.optional(),
|
||||
release_date: z.string().regex(/^\d{4}-\d{2}(-\d{2})?$/, {
|
||||
message: "Must be in YYYY-MM or YYYY-MM-DD format",
|
||||
})
|
||||
.optional(),
|
||||
release_date: z.string().regex(/^\d{4}-\d{2}(-\d{2})?$/, {
|
||||
message: "Must be in YYYY-MM or YYYY-MM-DD format",
|
||||
}),
|
||||
last_updated: z.string().regex(/^\d{4}-\d{2}(-\d{2})?$/, {
|
||||
message: "Must be in YYYY-MM or YYYY-MM-DD format",
|
||||
}),
|
||||
modalities: z.object({
|
||||
input: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
|
||||
output: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
|
||||
}),
|
||||
open_weights: z.boolean(),
|
||||
limit: z.object({
|
||||
context: z.number().min(0, "Context window must be positive"),
|
||||
input: z.number().min(0, "Input tokens must be positive").optional(),
|
||||
output: z.number().min(0, "Output tokens must be positive"),
|
||||
}),
|
||||
status: z.enum(["alpha", "beta", "deprecated"]).optional(),
|
||||
experimental: z
|
||||
.object({
|
||||
modes: z
|
||||
.record(
|
||||
z.object({
|
||||
cost: Cost.optional(),
|
||||
provider: z
|
||||
.object({
|
||||
body: z.record(JsonValue).optional(),
|
||||
headers: z.record(z.string()).optional(),
|
||||
})
|
||||
.optional(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
})
|
||||
.optional(),
|
||||
provider: z
|
||||
.object({
|
||||
npm: z.string().optional(),
|
||||
api: z.string().optional(),
|
||||
shape: z.enum(["responses", "completions"]).optional(),
|
||||
body: z.record(JsonValue).optional(),
|
||||
headers: z.record(z.string()).optional(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
function refineModel<T extends z.ZodTypeAny>(schema: T) {
|
||||
return schema
|
||||
.refine(
|
||||
(data) => {
|
||||
return !(data.reasoning === false && data.cost?.reasoning !== undefined);
|
||||
},
|
||||
{
|
||||
message: "Cannot set cost.reasoning when reasoning is false",
|
||||
path: ["cost", "reasoning"],
|
||||
},
|
||||
)
|
||||
.refine(
|
||||
(data) => {
|
||||
const tiers = data.cost?.tiers;
|
||||
if (tiers === undefined) return true;
|
||||
|
||||
const sizes = tiers.map((tier: { tier: { size: number } }) => tier.tier.size);
|
||||
return new Set(sizes).size === sizes.length;
|
||||
},
|
||||
{
|
||||
message: "Cost context tiers must not have duplicate sizes",
|
||||
path: ["cost", "tiers"],
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export const ModelShape = z
|
||||
.object({
|
||||
...ModelBase.shape,
|
||||
cost: OutputCost.optional(),
|
||||
}),
|
||||
last_updated: z.string().regex(/^\d{4}-\d{2}(-\d{2})?$/, {
|
||||
message: "Must be in YYYY-MM or YYYY-MM-DD format",
|
||||
}),
|
||||
modalities: z.object({
|
||||
input: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
|
||||
output: z.array(z.enum(["text", "audio", "image", "video", "pdf"])),
|
||||
}),
|
||||
open_weights: z.boolean(),
|
||||
cost: Cost.extend({
|
||||
context_over_200k: Cost.optional(),
|
||||
}).optional(),
|
||||
limit: z.object({
|
||||
context: z.number().min(0, "Context window must be positive"),
|
||||
input: z.number().min(0, "Input tokens must be positive").optional(),
|
||||
output: z.number().min(0, "Output tokens must be positive"),
|
||||
}),
|
||||
status: z.enum(["alpha", "beta", "deprecated"]).optional(),
|
||||
experimental: z
|
||||
.object({
|
||||
modes: z
|
||||
.record(
|
||||
z.object({
|
||||
cost: Cost.optional(),
|
||||
provider: z
|
||||
.object({
|
||||
body: z.record(JsonValue).optional(),
|
||||
headers: z.record(z.string()).optional(),
|
||||
})
|
||||
.optional(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
})
|
||||
.optional(),
|
||||
provider: z
|
||||
.object({
|
||||
npm: z.string().optional(),
|
||||
api: z.string().optional(),
|
||||
shape: z.enum(["responses", "completions"]).optional(),
|
||||
body: z.record(JsonValue).optional(),
|
||||
headers: z.record(z.string()).optional(),
|
||||
})
|
||||
.optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const AuthoredModelShape = z
|
||||
.object({
|
||||
...ModelBase.shape,
|
||||
cost: AuthoredCost.optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
export const Model = refineModel(ModelShape);
|
||||
|
||||
export const AuthoredModel = refineModel(AuthoredModelShape);
|
||||
.strict()
|
||||
.refine(
|
||||
(data) => {
|
||||
return !(data.reasoning === false && data.cost?.reasoning !== undefined);
|
||||
},
|
||||
{
|
||||
message: "Cannot set cost.reasoning when reasoning is false",
|
||||
path: ["cost", "reasoning"],
|
||||
},
|
||||
);
|
||||
|
||||
export type Model = z.infer<typeof Model>;
|
||||
|
||||
@@ -204,7 +150,6 @@ export const Provider = z
|
||||
const isOpenAIcompatible = data.npm === "@ai-sdk/openai-compatible";
|
||||
const isOpenrouter = data.npm === "@openrouter/ai-sdk-provider";
|
||||
const isAnthropic = data.npm === "@ai-sdk/anthropic";
|
||||
const isKiro = data.npm === "kiro-acp-ai-provider";
|
||||
const hasApi = data.api !== undefined;
|
||||
|
||||
return (
|
||||
@@ -216,20 +161,17 @@ export const Provider = z
|
||||
isAnthropic ||
|
||||
// openai: api optional (always allowed)
|
||||
isOpenAI ||
|
||||
// kiro: api optional (always allowed)
|
||||
isKiro ||
|
||||
// all others: must NOT have api
|
||||
(!isOpenAI &&
|
||||
!isOpenAIcompatible &&
|
||||
!isOpenrouter &&
|
||||
!isAnthropic &&
|
||||
!isKiro &&
|
||||
!hasApi)
|
||||
);
|
||||
},
|
||||
{
|
||||
message:
|
||||
"'api' is required for openai-compatible and openrouter, optional for anthropic, openai, and kiro, forbidden otherwise",
|
||||
"'api' is required for openai-compatible and openrouter, optional for anthropic and openai, forbidden otherwise",
|
||||
path: ["api"],
|
||||
},
|
||||
);
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
"build": "./script/build.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tanstack/virtual-core": "^3.14.0",
|
||||
"hono": "^4.8.0",
|
||||
"models.dev": "workspace:*"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
import { Rendered, Providers } from "../src/render";
|
||||
import { normalizeLogoSvg } from "../src/logo.js";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import { $ } from "bun";
|
||||
@@ -23,7 +24,10 @@ await fs.mkdir("./dist/logos", { recursive: true });
|
||||
const defaultLogoPath = "../../providers/logo.svg";
|
||||
const defaultLogo = Bun.file(defaultLogoPath);
|
||||
if (await defaultLogo.exists()) {
|
||||
await Bun.write("./dist/logos/default.svg", defaultLogo);
|
||||
await Bun.write(
|
||||
"./dist/logos/default.svg",
|
||||
normalizeLogoSvg(await defaultLogo.text())
|
||||
);
|
||||
}
|
||||
|
||||
// Then copy provider-specific logos
|
||||
@@ -36,7 +40,10 @@ for (const entry of entries) {
|
||||
const logoFile = Bun.file(logoPath);
|
||||
|
||||
if (await logoFile.exists()) {
|
||||
await Bun.write(`./dist/logos/${provider}.svg`, logoFile);
|
||||
await Bun.write(
|
||||
`./dist/logos/${provider}.svg`,
|
||||
normalizeLogoSvg(await logoFile.text())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+16
-32
@@ -41,8 +41,6 @@
|
||||
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
font-family: 'Rubik', sans-serif;
|
||||
line-height: 1.6;
|
||||
color: var(--color-text);
|
||||
@@ -207,17 +205,12 @@ header {
|
||||
}
|
||||
}
|
||||
|
||||
.table-viewport {
|
||||
height: calc(100svh - var(--header-height));
|
||||
margin-top: var(--header-height);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
font-size: 0.875rem;
|
||||
width: 100%;
|
||||
margin-top: var(--header-height);
|
||||
}
|
||||
|
||||
thead,
|
||||
@@ -225,7 +218,7 @@ tbody {}
|
||||
|
||||
table thead th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
top: var(--header-height);
|
||||
border-top: 1px solid var(--color-border);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
font-size: 0.75rem;
|
||||
@@ -271,7 +264,6 @@ td {
|
||||
text-align: left;
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
white-space: nowrap;
|
||||
height: 48px;
|
||||
}
|
||||
|
||||
tbody {
|
||||
@@ -327,37 +319,18 @@ tbody {
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
.provider-cell img,
|
||||
.provider-cell svg {
|
||||
.provider-logo {
|
||||
flex: 0 0 auto;
|
||||
display: block;
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.virtual-spacer td {
|
||||
height: inherit;
|
||||
padding: 0;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.empty-row td {
|
||||
padding: 2rem 0.75rem;
|
||||
color: var(--color-text-tertiary);
|
||||
}
|
||||
|
||||
.empty-row div {
|
||||
position: sticky;
|
||||
left: 0;
|
||||
width: calc(100vw - 1.5rem);
|
||||
text-align: center;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.model-id-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
@@ -440,6 +413,17 @@ tbody {
|
||||
.modality-icon:hover::after {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
tr.loading-row td,
|
||||
tr.error-row td {
|
||||
padding: 1rem 0.75rem;
|
||||
text-align: center;
|
||||
font-family: inherit;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 400;
|
||||
text-transform: none;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
dialog::backdrop {
|
||||
|
||||
+384
-283
@@ -1,54 +1,249 @@
|
||||
import {
|
||||
Virtualizer,
|
||||
elementScroll,
|
||||
observeElementOffset,
|
||||
observeElementRect,
|
||||
} from "@tanstack/virtual-core";
|
||||
import {
|
||||
type TableRow,
|
||||
renderRow,
|
||||
escapeHtml,
|
||||
booleanText,
|
||||
knowledgeText,
|
||||
weightsText,
|
||||
} from "./shared.js";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__TABLE_DATA__: TableRow[];
|
||||
}
|
||||
interface ApiCost {
|
||||
input?: number;
|
||||
output?: number;
|
||||
reasoning?: number;
|
||||
cache_read?: number;
|
||||
cache_write?: number;
|
||||
input_audio?: number;
|
||||
output_audio?: number;
|
||||
}
|
||||
|
||||
interface VirtualizedRow extends TableRow {
|
||||
key: string;
|
||||
searchText: string;
|
||||
sortValues: Array<string | number | undefined>;
|
||||
interface ApiLimit {
|
||||
context: number;
|
||||
input?: number;
|
||||
output: number;
|
||||
}
|
||||
|
||||
type SortDirection = "asc" | "desc";
|
||||
interface ApiModel {
|
||||
name: string;
|
||||
family?: string;
|
||||
status?: string;
|
||||
tool_call: boolean;
|
||||
reasoning: boolean;
|
||||
modalities: {
|
||||
input: string[];
|
||||
output: string[];
|
||||
};
|
||||
cost?: ApiCost;
|
||||
limit: ApiLimit;
|
||||
structured_output?: boolean;
|
||||
temperature: boolean;
|
||||
open_weights: boolean;
|
||||
knowledge?: string;
|
||||
release_date: string;
|
||||
last_updated: string;
|
||||
}
|
||||
|
||||
const ESTIMATED_ROW_HEIGHT = 48;
|
||||
const VIRTUAL_OVERSCAN = 5;
|
||||
interface ApiProvider {
|
||||
name: string;
|
||||
models: Record<string, ApiModel>;
|
||||
}
|
||||
|
||||
type ApiResponse = Record<string, ApiProvider>;
|
||||
|
||||
const COLUMN_COUNT = 25;
|
||||
const modal = document.getElementById("modal") as HTMLDialogElement;
|
||||
const modalClose = document.getElementById("close")!;
|
||||
const help = document.getElementById("help")!;
|
||||
const search = document.getElementById("search")! as HTMLInputElement;
|
||||
const viewport = document.getElementById("table-viewport") as HTMLElement;
|
||||
const tbody = document.getElementById(
|
||||
"models-table-body"
|
||||
) as HTMLTableSectionElement;
|
||||
const headers = Array.from(document.querySelectorAll("th.sortable"));
|
||||
const columnCount = document.querySelectorAll("thead th").length;
|
||||
const tableBody = document.getElementById("table-body")! as HTMLTableSectionElement;
|
||||
|
||||
let isLoaded = false;
|
||||
let allRows: VirtualizedRow[] = [];
|
||||
let visibleRows: VirtualizedRow[] = [];
|
||||
let currentSort: { column: number; direction: SortDirection } = {
|
||||
column: -1,
|
||||
direction: "asc",
|
||||
const copyIcon = `
|
||||
<svg
|
||||
class="copy-icon"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="14"
|
||||
height="14"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
>
|
||||
<rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect>
|
||||
<path d="m4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path>
|
||||
</svg>
|
||||
`;
|
||||
|
||||
const checkIcon = `
|
||||
<svg
|
||||
class="check-icon"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="14"
|
||||
height="14"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
style="display: none;"
|
||||
>
|
||||
<polyline points="20,6 9,17 4,12"></polyline>
|
||||
</svg>
|
||||
`;
|
||||
|
||||
const modalityIcons: Record<string, { label: string; svg: string }> = {
|
||||
text: {
|
||||
label: "Text",
|
||||
svg: `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<polyline points="4,7 4,4 20,4 20,7"></polyline>
|
||||
<line x1="9" y1="20" x2="15" y2="20"></line>
|
||||
<line x1="12" y1="4" x2="12" y2="20"></line>
|
||||
</svg>
|
||||
`,
|
||||
},
|
||||
image: {
|
||||
label: "Image",
|
||||
svg: `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<rect width="18" height="18" x="3" y="3" rx="2" ry="2"></rect>
|
||||
<circle cx="9" cy="9" r="2"></circle>
|
||||
<path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"></path>
|
||||
</svg>
|
||||
`,
|
||||
},
|
||||
audio: {
|
||||
label: "Audio",
|
||||
svg: `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"></polygon>
|
||||
<path d="m19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"></path>
|
||||
</svg>
|
||||
`,
|
||||
},
|
||||
video: {
|
||||
label: "Video",
|
||||
svg: `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="m22 8-6 4 6 4V8Z"></path>
|
||||
<rect width="14" height="12" x="2" y="6" rx="2" ry="2"></rect>
|
||||
</svg>
|
||||
`,
|
||||
},
|
||||
pdf: {
|
||||
label: "PDF",
|
||||
svg: `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
||||
<polyline points="14,2 14,8 20,8"></polyline>
|
||||
<line x1="16" y1="13" x2="8" y2="13"></line>
|
||||
<line x1="16" y1="17" x2="8" y2="17"></line>
|
||||
<polyline points="10,9 9,9 8,9"></polyline>
|
||||
</svg>
|
||||
`,
|
||||
},
|
||||
};
|
||||
|
||||
function escapeHtml(value: string) {
|
||||
return value
|
||||
.replaceAll("&", "&")
|
||||
.replaceAll("<", "<")
|
||||
.replaceAll(">", ">")
|
||||
.replaceAll('"', """)
|
||||
.replaceAll("'", "'");
|
||||
}
|
||||
|
||||
function renderCost(cost?: number) {
|
||||
return cost === undefined ? "-" : `$${cost.toFixed(2)}`;
|
||||
}
|
||||
|
||||
function renderModalityIcon(modality: string) {
|
||||
const icon = modalityIcons[modality];
|
||||
if (!icon) return "";
|
||||
|
||||
return `<span class="modality-icon" data-tooltip="${icon.label}">${icon.svg}</span>`;
|
||||
}
|
||||
|
||||
function renderModalities(modalities: string[]) {
|
||||
return `<div class="modalities">${modalities.map(renderModalityIcon).join("")}</div>`;
|
||||
}
|
||||
|
||||
function renderProviderLogo(providerId: string) {
|
||||
return `<img class="provider-logo" src="/logos/${encodeURIComponent(providerId)}.svg" alt="" width="16" height="16" loading="lazy" decoding="async" />`;
|
||||
}
|
||||
|
||||
function renderRow(
|
||||
providerId: string,
|
||||
providerName: string,
|
||||
modelId: string,
|
||||
model: ApiModel
|
||||
) {
|
||||
const safeProviderId = escapeHtml(providerId);
|
||||
const safeProviderName = escapeHtml(providerName);
|
||||
const safeModelId = escapeHtml(modelId);
|
||||
const safeModelName = escapeHtml(model.name);
|
||||
const safeFamily = escapeHtml(model.family ?? "-");
|
||||
const safeKnowledge = escapeHtml(model.knowledge?.substring(0, 7) ?? "-");
|
||||
const safeReleaseDate = escapeHtml(model.release_date);
|
||||
const safeLastUpdated = escapeHtml(model.last_updated);
|
||||
|
||||
return `
|
||||
<tr data-model-row="true">
|
||||
<td>
|
||||
<div class="provider-cell">
|
||||
${renderProviderLogo(providerId)}
|
||||
<span>${safeProviderName}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>${safeModelName}</td>
|
||||
<td>${safeFamily}</td>
|
||||
<td>${safeProviderId}</td>
|
||||
<td>
|
||||
<div class="model-id-cell">
|
||||
<span class="model-id-text">${safeModelId}</span>
|
||||
<button class="copy-button" type="button" data-model-id="${safeModelId}" aria-label="Copy model ID">
|
||||
${copyIcon}
|
||||
${checkIcon}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
<td>${model.tool_call ? "Yes" : "No"}</td>
|
||||
<td>${model.reasoning ? "Yes" : "No"}</td>
|
||||
<td>${renderModalities(model.modalities.input)}</td>
|
||||
<td>${renderModalities(model.modalities.output)}</td>
|
||||
<td>${renderCost(model.cost?.input)}</td>
|
||||
<td>${renderCost(model.cost?.output)}</td>
|
||||
<td>${renderCost(model.cost?.reasoning)}</td>
|
||||
<td>${renderCost(model.cost?.cache_read)}</td>
|
||||
<td>${renderCost(model.cost?.cache_write)}</td>
|
||||
<td>${renderCost(model.cost?.input_audio)}</td>
|
||||
<td>${renderCost(model.cost?.output_audio)}</td>
|
||||
<td>${model.limit.context.toLocaleString()}</td>
|
||||
<td>${model.limit.input?.toLocaleString() ?? "-"}</td>
|
||||
<td>${model.limit.output.toLocaleString()}</td>
|
||||
<td>${model.structured_output === undefined ? "-" : model.structured_output ? "Yes" : "No"}</td>
|
||||
<td>${model.temperature ? "Yes" : "No"}</td>
|
||||
<td>${model.open_weights ? "Open" : "Closed"}</td>
|
||||
<td>${safeKnowledge}</td>
|
||||
<td>${safeReleaseDate}</td>
|
||||
<td>${safeLastUpdated}</td>
|
||||
</tr>
|
||||
`;
|
||||
}
|
||||
|
||||
function renderTableRows(providers: ApiResponse) {
|
||||
return Object.entries(providers)
|
||||
.sort(([, providerA], [, providerB]) =>
|
||||
providerA.name.localeCompare(providerB.name)
|
||||
)
|
||||
.flatMap(([providerId, provider]) =>
|
||||
Object.entries(provider.models)
|
||||
.filter(([, model]) => model.status !== "alpha")
|
||||
.sort(([, modelA], [, modelB]) => modelA.name.localeCompare(modelB.name))
|
||||
.map(([modelId, model]) =>
|
||||
renderRow(providerId, provider.name, modelId, model)
|
||||
)
|
||||
)
|
||||
.join("");
|
||||
}
|
||||
|
||||
function setStatusRow(message: string, className = "loading-row") {
|
||||
tableBody.innerHTML = `<tr class="${className}"><td colspan="${COLUMN_COUNT}">${escapeHtml(message)}</td></tr>`;
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
// URL State Management
|
||||
/////////////////////////
|
||||
@@ -56,7 +251,10 @@ function getQueryParams() {
|
||||
return new URLSearchParams(window.location.search);
|
||||
}
|
||||
|
||||
function updateQueryParams(updates: Record<string, string | null>) {
|
||||
function updateQueryParams(
|
||||
updates: Record<string, string | null>,
|
||||
historyMode: "push" | "replace" = "push"
|
||||
) {
|
||||
const params = getQueryParams();
|
||||
for (const [key, value] of Object.entries(updates)) {
|
||||
if (value) {
|
||||
@@ -65,9 +263,18 @@ function updateQueryParams(updates: Record<string, string | null>) {
|
||||
params.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
const newPath = params.toString()
|
||||
? `${window.location.pathname}?${params.toString()}`
|
||||
: window.location.pathname;
|
||||
|
||||
if (newPath === `${window.location.pathname}${window.location.search}`) return;
|
||||
|
||||
if (historyMode === "replace") {
|
||||
window.history.replaceState({}, "", newPath);
|
||||
return;
|
||||
}
|
||||
|
||||
window.history.pushState({}, "", newPath);
|
||||
}
|
||||
|
||||
@@ -77,7 +284,10 @@ function getColumnNameForURL(headerEl: Element): string {
|
||||
}
|
||||
|
||||
function getColumnIndexByUrlName(name: string): number {
|
||||
return headers.findIndex((header) => getColumnNameForURL(header) === name);
|
||||
const headers = document.querySelectorAll("th.sortable");
|
||||
return Array.from(headers).findIndex(
|
||||
(header) => getColumnNameForURL(header) === name
|
||||
);
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
@@ -106,230 +316,83 @@ modal.addEventListener("click", (e) => {
|
||||
});
|
||||
|
||||
////////////////////
|
||||
// Row Data
|
||||
// Handle Sorting
|
||||
////////////////////
|
||||
function lockColumnWidths() {
|
||||
const ths = document.querySelectorAll("#models-table thead th");
|
||||
const widths = Array.from(ths).map((th) => th.getBoundingClientRect().width);
|
||||
let currentSort = { column: -1, direction: "asc" as "asc" | "desc" };
|
||||
|
||||
const measurementRow = tbody.querySelector('tr[aria-hidden="true"]');
|
||||
if (measurementRow) measurementRow.remove();
|
||||
|
||||
const table = document.getElementById("models-table")!;
|
||||
table.style.tableLayout = "fixed";
|
||||
|
||||
const colgroup = document.createElement("colgroup");
|
||||
for (const width of widths) {
|
||||
const col = document.createElement("col");
|
||||
col.style.width = `${width}px`;
|
||||
colgroup.appendChild(col);
|
||||
}
|
||||
table.insertBefore(colgroup, table.firstChild);
|
||||
function updateSortIndicators(column: number, direction: "asc" | "desc") {
|
||||
const headers = document.querySelectorAll("th.sortable");
|
||||
headers.forEach((header, i) => {
|
||||
const indicator = header.querySelector(".sort-indicator")!;
|
||||
indicator.textContent = i === column ? (direction === "asc" ? "↑" : "↓") : "";
|
||||
});
|
||||
}
|
||||
|
||||
function prepareRow(row: TableRow): VirtualizedRow {
|
||||
const sortValues: VirtualizedRow["sortValues"] = [
|
||||
row.providerName,
|
||||
row.modelName,
|
||||
row.family,
|
||||
row.providerId,
|
||||
row.modelId,
|
||||
booleanText(row.toolCall),
|
||||
booleanText(row.reasoning),
|
||||
row.input.length,
|
||||
row.output.length,
|
||||
row.inputCost,
|
||||
row.outputCost,
|
||||
row.reasoningCost,
|
||||
row.cacheReadCost,
|
||||
row.cacheWriteCost,
|
||||
row.audioInputCost,
|
||||
row.audioOutputCost,
|
||||
row.contextLimit,
|
||||
row.inputLimit,
|
||||
row.outputLimit,
|
||||
row.structuredOutput === undefined
|
||||
? undefined
|
||||
: booleanText(row.structuredOutput),
|
||||
booleanText(row.temperature),
|
||||
weightsText(row.openWeights),
|
||||
row.knowledge ? knowledgeText(row.knowledge) : undefined,
|
||||
row.releaseDate,
|
||||
row.lastUpdated,
|
||||
];
|
||||
|
||||
const searchableValues = [
|
||||
row.providerName,
|
||||
row.modelName,
|
||||
row.family ?? "",
|
||||
row.providerId,
|
||||
row.modelId,
|
||||
row.releaseDate,
|
||||
row.lastUpdated,
|
||||
];
|
||||
|
||||
return {
|
||||
...row,
|
||||
key: `${row.providerId}/${row.modelId}`,
|
||||
searchText: searchableValues.join(" ").toLowerCase(),
|
||||
sortValues,
|
||||
};
|
||||
function clearSortIndicators() {
|
||||
updateSortIndicators(-1, "asc");
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// Virtual Table
|
||||
////////////////////
|
||||
function getVirtualizerOptions(count: number) {
|
||||
return {
|
||||
count,
|
||||
getScrollElement: () => viewport,
|
||||
estimateSize: () => ESTIMATED_ROW_HEIGHT,
|
||||
getItemKey: (index: number) => visibleRows[index]?.key ?? index,
|
||||
initialRect: {
|
||||
width: viewport.clientWidth || window.innerWidth,
|
||||
height: viewport.clientHeight || window.innerHeight,
|
||||
},
|
||||
overscan: VIRTUAL_OVERSCAN,
|
||||
observeElementRect,
|
||||
observeElementOffset,
|
||||
scrollToFn: elementScroll,
|
||||
onChange: () => renderVirtualRows(),
|
||||
};
|
||||
}
|
||||
function sortTable(
|
||||
column: number,
|
||||
direction: "asc" | "desc",
|
||||
syncUrl = true
|
||||
) {
|
||||
const header = document.querySelectorAll("th.sortable")[column];
|
||||
const columnType = header?.getAttribute("data-type");
|
||||
if (!columnType) return;
|
||||
|
||||
const virtualizer = new Virtualizer<HTMLElement, HTMLTableRowElement>(
|
||||
getVirtualizerOptions(0)
|
||||
);
|
||||
const cleanupVirtualizer = virtualizer._didMount();
|
||||
virtualizer._willUpdate();
|
||||
window.addEventListener("pagehide", () => cleanupVirtualizer());
|
||||
|
||||
function renderStatusRow(message: string) {
|
||||
tbody.innerHTML = `<tr class="empty-row"><td colspan="${columnCount}"><div>${escapeHtml(
|
||||
message
|
||||
)}</div></td></tr>`;
|
||||
}
|
||||
|
||||
function setVirtualizerCount(count: number, resetScroll: boolean) {
|
||||
virtualizer.setOptions(getVirtualizerOptions(count));
|
||||
virtualizer._willUpdate();
|
||||
if (resetScroll) virtualizer.scrollToOffset(0);
|
||||
renderVirtualRows();
|
||||
}
|
||||
|
||||
function renderVirtualRows() {
|
||||
if (!isLoaded) return;
|
||||
if (visibleRows.length === 0) {
|
||||
renderStatusRow("No models found");
|
||||
return;
|
||||
currentSort = { column, direction };
|
||||
if (syncUrl) {
|
||||
updateQueryParams(
|
||||
{
|
||||
sort: getColumnNameForURL(header),
|
||||
order: direction,
|
||||
},
|
||||
"push"
|
||||
);
|
||||
}
|
||||
|
||||
const virtualRows = virtualizer.getVirtualItems();
|
||||
if (virtualRows.length === 0) return;
|
||||
const rows = Array.from(
|
||||
tableBody.querySelectorAll('tr[data-model-row="true"]')
|
||||
) as HTMLTableRowElement[];
|
||||
|
||||
const firstRow = virtualRows[0]!;
|
||||
const lastRow = virtualRows[virtualRows.length - 1]!;
|
||||
const paddingTop = firstRow.start;
|
||||
const paddingBottom = Math.max(virtualizer.getTotalSize() - lastRow.end, 0);
|
||||
const html: string[] = [];
|
||||
|
||||
if (paddingTop > 0) html.push(renderSpacerRow(paddingTop));
|
||||
for (const virtualRow of virtualRows) {
|
||||
const row = visibleRows[virtualRow.index];
|
||||
if (row) html.push(renderRow(row, virtualRow.index));
|
||||
}
|
||||
if (paddingBottom > 0) html.push(renderSpacerRow(paddingBottom));
|
||||
|
||||
tbody.innerHTML = html.join("");
|
||||
tbody.querySelectorAll<HTMLTableRowElement>("tr[data-index]").forEach((row) =>
|
||||
virtualizer.measureElement(row)
|
||||
);
|
||||
}
|
||||
|
||||
function renderSpacerRow(height: number) {
|
||||
return `<tr class="virtual-spacer" style="height: ${height}px"><td colspan="${columnCount}"></td></tr>`;
|
||||
}
|
||||
|
||||
function applyRows(resetScroll = true) {
|
||||
if (!isLoaded) return;
|
||||
visibleRows = getRowsForDisplay();
|
||||
setVirtualizerCount(visibleRows.length, resetScroll);
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// Sorting
|
||||
////////////////////
|
||||
function getRowsForDisplay() {
|
||||
const terms = search.value
|
||||
.toLowerCase()
|
||||
.split(",")
|
||||
.map((term) => term.trim())
|
||||
.filter(Boolean);
|
||||
const filteredRows =
|
||||
terms.length === 0
|
||||
? allRows
|
||||
: allRows.filter((row) =>
|
||||
terms.some((term) => row.searchText.includes(term))
|
||||
);
|
||||
|
||||
if (currentSort.column === -1) return filteredRows;
|
||||
|
||||
const columnType = headers[currentSort.column]?.getAttribute("data-type");
|
||||
if (!columnType) return filteredRows;
|
||||
|
||||
return [...filteredRows].sort((a, b) => {
|
||||
const aValue = a.sortValues[currentSort.column];
|
||||
const bValue = b.sortValues[currentSort.column];
|
||||
rows.sort((a, b) => {
|
||||
const aValue = getCellValue(a.cells[column], columnType);
|
||||
const bValue = getCellValue(b.cells[column], columnType);
|
||||
|
||||
if (aValue === undefined && bValue === undefined) return 0;
|
||||
if (aValue === undefined) return 1;
|
||||
if (bValue === undefined) return -1;
|
||||
|
||||
let comparison = 0;
|
||||
if (columnType === "number" || columnType === "modalities") {
|
||||
comparison = (aValue as number) - (bValue as number);
|
||||
} else {
|
||||
comparison = String(aValue).localeCompare(String(bValue));
|
||||
}
|
||||
const comparison =
|
||||
columnType === "number" || columnType === "modalities"
|
||||
? (aValue as number) - (bValue as number)
|
||||
: (aValue as string).localeCompare(bValue as string);
|
||||
|
||||
return currentSort.direction === "asc" ? comparison : -comparison;
|
||||
return direction === "asc" ? comparison : -comparison;
|
||||
});
|
||||
|
||||
rows.forEach((row) => tableBody.appendChild(row));
|
||||
updateSortIndicators(column, direction);
|
||||
}
|
||||
|
||||
function sortTable(
|
||||
column: number,
|
||||
direction: SortDirection,
|
||||
updateURL = true
|
||||
) {
|
||||
const header = headers[column];
|
||||
if (!header?.getAttribute("data-type")) return;
|
||||
|
||||
currentSort = { column, direction };
|
||||
if (updateURL) {
|
||||
updateQueryParams({
|
||||
sort: getColumnNameForURL(header),
|
||||
order: direction,
|
||||
});
|
||||
function getCellValue(
|
||||
cell: HTMLTableCellElement,
|
||||
type: string
|
||||
): string | number | undefined {
|
||||
if (type === "modalities") {
|
||||
return cell.querySelectorAll(".modality-icon").length;
|
||||
}
|
||||
|
||||
updateSortIndicators();
|
||||
applyRows();
|
||||
const text = cell.textContent?.trim() || "";
|
||||
if (text === "-") return;
|
||||
if (type === "number") return parseFloat(text.replace(/[$,]/g, "")) || 0;
|
||||
return text;
|
||||
}
|
||||
|
||||
function updateSortIndicators() {
|
||||
headers.forEach((header, i) => {
|
||||
const indicator = header.querySelector(".sort-indicator")!;
|
||||
indicator.textContent =
|
||||
i === currentSort.column
|
||||
? currentSort.direction === "asc"
|
||||
? "↑"
|
||||
: "↓"
|
||||
: "";
|
||||
});
|
||||
}
|
||||
|
||||
headers.forEach((header, column) => {
|
||||
document.querySelectorAll("th.sortable").forEach((header) => {
|
||||
header.addEventListener("click", () => {
|
||||
const column = Array.from(header.parentElement!.children).indexOf(header);
|
||||
const direction =
|
||||
currentSort.column === column && currentSort.direction === "asc"
|
||||
? "desc"
|
||||
@@ -339,19 +402,43 @@ headers.forEach((header, column) => {
|
||||
});
|
||||
|
||||
///////////////////
|
||||
// Search
|
||||
// Handle Search
|
||||
///////////////////
|
||||
function filterTable(value: string, syncUrl = true) {
|
||||
const lowerCaseValues = value
|
||||
.toLowerCase()
|
||||
.split(",")
|
||||
.map((part) => part.trim())
|
||||
.filter(Boolean);
|
||||
const rows = tableBody.querySelectorAll(
|
||||
'tr[data-model-row="true"]'
|
||||
) as NodeListOf<HTMLTableRowElement>;
|
||||
|
||||
rows.forEach((row) => {
|
||||
const cellTexts = Array.from(row.cells).map((cell) =>
|
||||
cell.textContent!.toLowerCase()
|
||||
);
|
||||
const isVisible =
|
||||
lowerCaseValues.length === 0 ||
|
||||
lowerCaseValues.some((lowerCaseValue) =>
|
||||
cellTexts.some((text) => text.includes(lowerCaseValue))
|
||||
);
|
||||
row.style.display = isVisible ? "" : "none";
|
||||
});
|
||||
|
||||
if (syncUrl) {
|
||||
updateQueryParams({ search: value || null }, "replace");
|
||||
}
|
||||
}
|
||||
|
||||
search.addEventListener("input", () => {
|
||||
updateQueryParams({ search: search.value || null });
|
||||
applyRows();
|
||||
filterTable(search.value);
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", (e) => {
|
||||
const key = e.key.toLowerCase();
|
||||
if ((e.metaKey || e.ctrlKey) && (key === "k" || key === "f")) {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === "k") {
|
||||
e.preventDefault();
|
||||
search.focus();
|
||||
search.select();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -365,19 +452,22 @@ search.addEventListener("keydown", (e) => {
|
||||
///////////////////////////////////
|
||||
// Handle Copy model ID function
|
||||
///////////////////////////////////
|
||||
async function copyModelId(button: HTMLButtonElement, modelId: string) {
|
||||
tableBody.addEventListener("click", async (event) => {
|
||||
const target = event.target as HTMLElement;
|
||||
const button = target.closest(".copy-button") as HTMLButtonElement | null;
|
||||
const modelId = button?.dataset.modelId;
|
||||
if (!button || !modelId) return;
|
||||
|
||||
try {
|
||||
if (navigator.clipboard) {
|
||||
await navigator.clipboard.writeText(modelId);
|
||||
|
||||
// Switch to check icon
|
||||
const copyIcon = button.querySelector(".copy-icon") as HTMLElement;
|
||||
const checkIcon = button.querySelector(".check-icon") as HTMLElement;
|
||||
|
||||
copyIcon.style.display = "none";
|
||||
checkIcon.style.display = "block";
|
||||
|
||||
// Switch back after 1 second
|
||||
setTimeout(() => {
|
||||
copyIcon.style.display = "block";
|
||||
checkIcon.style.display = "none";
|
||||
@@ -386,56 +476,67 @@ async function copyModelId(button: HTMLButtonElement, modelId: string) {
|
||||
} catch (err) {
|
||||
console.error("Failed to copy text: ", err);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("click", (event) => {
|
||||
if (!(event.target instanceof Element)) return;
|
||||
const button = event.target.closest<HTMLButtonElement>(
|
||||
".copy-button[data-model-id]"
|
||||
);
|
||||
if (!button) return;
|
||||
|
||||
const modelId = button.dataset.modelId;
|
||||
if (modelId) void copyModelId(button, modelId);
|
||||
});
|
||||
|
||||
///////////////////////////////////
|
||||
// Initialize State from URL
|
||||
///////////////////////////////////
|
||||
let tableLoaded = false;
|
||||
|
||||
function initializeFromURL() {
|
||||
if (!tableLoaded) return;
|
||||
|
||||
const params = getQueryParams();
|
||||
const searchQuery = params.get("search") ?? "";
|
||||
search.value = searchQuery;
|
||||
filterTable(searchQuery, false);
|
||||
|
||||
search.value = params.get("search") ?? "";
|
||||
|
||||
currentSort = { column: -1, direction: "asc" };
|
||||
const columnName = params.get("sort");
|
||||
if (columnName) {
|
||||
const columnIndex = getColumnIndexByUrlName(columnName);
|
||||
if (columnIndex !== -1) {
|
||||
currentSort = {
|
||||
column: columnIndex,
|
||||
direction: params.get("order") === "desc" ? "desc" : "asc",
|
||||
};
|
||||
}
|
||||
if (!columnName) {
|
||||
currentSort = { column: -1, direction: "asc" };
|
||||
clearSortIndicators();
|
||||
return;
|
||||
}
|
||||
|
||||
updateSortIndicators();
|
||||
applyRows(false);
|
||||
const columnIndex = getColumnIndexByUrlName(columnName);
|
||||
if (columnIndex === -1) return;
|
||||
|
||||
const direction = (params.get("order") as "asc" | "desc") || "asc";
|
||||
sortTable(columnIndex, direction, false);
|
||||
}
|
||||
|
||||
function loadRows() {
|
||||
async function loadTable() {
|
||||
try {
|
||||
allRows = window.__TABLE_DATA__.map(prepareRow);
|
||||
lockColumnWidths();
|
||||
isLoaded = true;
|
||||
const response = await fetch("/api.json");
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch models: ${response.status}`);
|
||||
}
|
||||
|
||||
const providers = (await response.json()) as ApiResponse;
|
||||
const rows = renderTableRows(providers);
|
||||
tableBody.innerHTML = rows || "";
|
||||
|
||||
if (!rows) {
|
||||
setStatusRow("No models found.");
|
||||
return;
|
||||
}
|
||||
|
||||
tableLoaded = true;
|
||||
initializeFromURL();
|
||||
window.addEventListener("popstate", initializeFromURL);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
isLoaded = true;
|
||||
visibleRows = [];
|
||||
renderStatusRow("Failed to load model data");
|
||||
console.error("Failed to load model data:", error);
|
||||
setStatusRow("Failed to load models.", "loading-row error-row");
|
||||
}
|
||||
}
|
||||
|
||||
loadRows();
|
||||
window.addEventListener("popstate", initializeFromURL);
|
||||
function initializeApp() {
|
||||
search.value = getQueryParams().get("search") ?? "";
|
||||
void loadTable();
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", initializeApp);
|
||||
} else {
|
||||
initializeApp();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
const LOGO_THEME_MARKER = "models-dev-logo-theme";
|
||||
const LOGO_THEME_STYLE = `<style id="${LOGO_THEME_MARKER}">:root{color:#666}@media (prefers-color-scheme: dark){:root{color:#AAA}}</style>`;
|
||||
|
||||
export function normalizeLogoSvg(svgText: string) {
|
||||
if (svgText.includes(LOGO_THEME_MARKER)) {
|
||||
return svgText;
|
||||
}
|
||||
|
||||
return svgText.replace(/<svg\b[^>]*>/i, (svgTag) => {
|
||||
const themedTag = svgTag.includes("fill=")
|
||||
? svgTag
|
||||
: svgTag.replace("<svg", '<svg fill="currentColor"');
|
||||
|
||||
return `${themedTag}${LOGO_THEME_STYLE}`;
|
||||
});
|
||||
}
|
||||
+10
-110
@@ -1,109 +1,15 @@
|
||||
/** @jsx jsx */
|
||||
/** @jsxImportSource hono/jsx */
|
||||
|
||||
import { generate } from "models.dev";
|
||||
import { Fragment } from "hono/jsx";
|
||||
import { renderToString } from "hono/jsx/dom/server";
|
||||
import { existsSync } from "fs";
|
||||
import { generate } from "models.dev";
|
||||
import path from "path";
|
||||
import { type TableRow, renderRow, getLargestRow } from "./shared.js";
|
||||
|
||||
export const Providers = await generate(
|
||||
path.join(import.meta.dir, "..", "..", "..", "providers")
|
||||
);
|
||||
|
||||
// Function to load SVG content
|
||||
const loadProviderSvg = async (providerId: string): Promise<string | null> => {
|
||||
const providerLogoPath = path.join(
|
||||
import.meta.dir,
|
||||
"..",
|
||||
"..",
|
||||
"..",
|
||||
"providers",
|
||||
providerId,
|
||||
"logo.svg"
|
||||
);
|
||||
|
||||
const defaultLogoPath = path.join(
|
||||
import.meta.dir,
|
||||
"..",
|
||||
"..",
|
||||
"..",
|
||||
"providers",
|
||||
"logo.svg"
|
||||
);
|
||||
|
||||
try {
|
||||
// Try provider-specific logo first
|
||||
if (existsSync(providerLogoPath)) {
|
||||
const file = Bun.file(providerLogoPath);
|
||||
return await file.text();
|
||||
}
|
||||
// Fall back to default logo
|
||||
if (existsSync(defaultLogoPath)) {
|
||||
const file = Bun.file(defaultLogoPath);
|
||||
return await file.text();
|
||||
}
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.warn(`Failed to load logo for provider ${providerId}:`, error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
// Create a cache of loaded SVGs at build time
|
||||
const providerLogos = new Map<string, string>();
|
||||
|
||||
// Pre-load all provider logos
|
||||
for (const [providerId] of Object.entries(Providers)) {
|
||||
const svgContent = await loadProviderSvg(providerId);
|
||||
if (svgContent) {
|
||||
providerLogos.set(providerId, svgContent);
|
||||
}
|
||||
}
|
||||
|
||||
export const INITIAL_ROW_COUNT = 50;
|
||||
|
||||
export const TableRows: TableRow[] = Object.entries(Providers)
|
||||
.sort(([, providerA], [, providerB]) =>
|
||||
providerA.name.localeCompare(providerB.name)
|
||||
)
|
||||
.flatMap(([providerId, provider]) =>
|
||||
Object.entries(provider.models)
|
||||
.filter(([, model]) => model.status !== "alpha")
|
||||
.sort(([, modelA], [, modelB]) => modelA.name.localeCompare(modelB.name))
|
||||
.map(([modelId, model]) => ({
|
||||
providerId,
|
||||
providerName: provider.name,
|
||||
providerLogoSvg: providerLogos.get(providerId) || "",
|
||||
modelId,
|
||||
modelName: model.name,
|
||||
family: model.family,
|
||||
toolCall: model.tool_call,
|
||||
reasoning: model.reasoning,
|
||||
input: model.modalities.input,
|
||||
output: model.modalities.output,
|
||||
inputCost: model.cost?.input,
|
||||
outputCost: model.cost?.output,
|
||||
reasoningCost: model.cost?.reasoning,
|
||||
cacheReadCost: model.cost?.cache_read,
|
||||
cacheWriteCost: model.cost?.cache_write,
|
||||
audioInputCost: model.cost?.input_audio,
|
||||
audioOutputCost: model.cost?.output_audio,
|
||||
contextLimit: model.limit.context,
|
||||
inputLimit: model.limit.input,
|
||||
outputLimit: model.limit.output,
|
||||
structuredOutput: model.structured_output,
|
||||
temperature: model.temperature ?? false,
|
||||
openWeights: model.open_weights,
|
||||
knowledge: model.knowledge,
|
||||
releaseDate: model.release_date,
|
||||
lastUpdated: model.last_updated,
|
||||
}))
|
||||
);
|
||||
|
||||
const largestRow = getLargestRow(TableRows);
|
||||
|
||||
export const Rendered = renderToString(
|
||||
<Fragment>
|
||||
<header>
|
||||
@@ -138,8 +44,7 @@ export const Rendered = renderToString(
|
||||
<button id="help">How to use</button>
|
||||
</div>
|
||||
</header>
|
||||
<div id="table-viewport" class="table-viewport">
|
||||
<table id="models-table">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="sortable" data-type="text">
|
||||
@@ -268,12 +173,12 @@ export const Rendered = renderToString(
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="models-table-body" dangerouslySetInnerHTML={{
|
||||
__html: TableRows.slice(0, INITIAL_ROW_COUNT).map((row, i) => renderRow(row, i)).join('')
|
||||
+ renderRow(largestRow, -1).replace('<tr', '<tr style="visibility:hidden" aria-hidden="true"')
|
||||
}} />
|
||||
</table>
|
||||
</div>
|
||||
<tbody id="table-body">
|
||||
<tr class="loading-row">
|
||||
<td colspan={25}>Loading models...</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<dialog id="modal">
|
||||
<div class="header">
|
||||
<h2>How to use</h2>
|
||||
@@ -383,15 +288,10 @@ export const Rendered = renderToString(
|
||||
>
|
||||
Edit on GitHub
|
||||
</a>
|
||||
<a href="https://opencode.ai" target="_blank" rel="noopener noreferrer">
|
||||
Created by OpenCode
|
||||
<a href="https://sst.dev" target="_blank" rel="noopener noreferrer">
|
||||
Created by SST
|
||||
</a>
|
||||
</div>
|
||||
</dialog>
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `window.__TABLE_DATA__ = ${JSON.stringify(TableRows)}`,
|
||||
}}
|
||||
></script>
|
||||
</Fragment>
|
||||
);
|
||||
@@ -1,11 +1,19 @@
|
||||
import Index from "../index.html";
|
||||
import { Rendered } from "./render";
|
||||
import { normalizeLogoSvg } from "./logo.js";
|
||||
import { Providers, Rendered } from "./render";
|
||||
import path from "path";
|
||||
|
||||
Bun.serve({
|
||||
port: 16_000,
|
||||
routes: {
|
||||
"/": Index,
|
||||
"/api.json": () => {
|
||||
return Response.json(Providers, {
|
||||
headers: {
|
||||
"Cache-Control": "public, max-age=3600",
|
||||
},
|
||||
});
|
||||
},
|
||||
"/assets/*": (req) => {
|
||||
const file = Bun.file(
|
||||
path.join(import.meta.dir, new URL(req.url).pathname)
|
||||
@@ -38,7 +46,7 @@ Bun.serve({
|
||||
file = Bun.file(defaultLogoPath);
|
||||
}
|
||||
|
||||
return new Response(file, {
|
||||
return new Response(normalizeLogoSvg(await file.text()), {
|
||||
headers: {
|
||||
"Content-Type": "image/svg+xml",
|
||||
"Cache-Control": "public, max-age=3600",
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
export interface TableRow {
|
||||
providerId: string;
|
||||
providerName: string;
|
||||
providerLogoSvg: string;
|
||||
modelId: string;
|
||||
modelName: string;
|
||||
family?: string;
|
||||
toolCall: boolean;
|
||||
reasoning: boolean;
|
||||
input: string[];
|
||||
output: string[];
|
||||
inputCost?: number;
|
||||
outputCost?: number;
|
||||
reasoningCost?: number;
|
||||
cacheReadCost?: number;
|
||||
cacheWriteCost?: number;
|
||||
audioInputCost?: number;
|
||||
audioOutputCost?: number;
|
||||
contextLimit: number;
|
||||
inputLimit?: number;
|
||||
outputLimit: number;
|
||||
structuredOutput?: boolean;
|
||||
temperature: boolean;
|
||||
openWeights: boolean;
|
||||
knowledge?: string;
|
||||
releaseDate: string;
|
||||
lastUpdated: string;
|
||||
}
|
||||
|
||||
const MODALITY_ICONS: Record<string, string> = {
|
||||
text: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="4,7 4,4 20,4 20,7"></polyline><line x1="9" y1="20" x2="15" y2="20"></line><line x1="12" y1="4" x2="12" y2="20"></line></svg>`,
|
||||
image: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"></rect><circle cx="9" cy="9" r="2"></circle><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"></path></svg>`,
|
||||
audio: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"></polygon><path d="m19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"></path></svg>`,
|
||||
video: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m22 8-6 4 6 4V8Z"></path><rect width="14" height="12" x="2" y="6" rx="2" ry="2"></rect></svg>`,
|
||||
pdf: `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14,2 14,8 20,8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10,9 9,9 8,9"></polyline></svg>`,
|
||||
};
|
||||
|
||||
export function escapeHtml(value: string | number) {
|
||||
return String(value).replace(/[&<>'"]/g, (char) => {
|
||||
switch (char) {
|
||||
case "&":
|
||||
return "&";
|
||||
case "<":
|
||||
return "<";
|
||||
case ">":
|
||||
return ">";
|
||||
case "'":
|
||||
return "'";
|
||||
case '"':
|
||||
return """;
|
||||
default:
|
||||
return char;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function booleanText(value: boolean) {
|
||||
return value ? "Yes" : "No";
|
||||
}
|
||||
|
||||
export function optionalBooleanText(value?: boolean) {
|
||||
return value === undefined ? "-" : booleanText(value);
|
||||
}
|
||||
|
||||
export function formatCost(cost?: number) {
|
||||
return cost === undefined ? "-" : `$${cost.toFixed(2)}`;
|
||||
}
|
||||
|
||||
export function formatNumber(value?: number) {
|
||||
return value === undefined ? "-" : value.toLocaleString();
|
||||
}
|
||||
|
||||
export function knowledgeText(value?: string) {
|
||||
return value ? value.substring(0, 7) : "-";
|
||||
}
|
||||
|
||||
export function weightsText(value: boolean) {
|
||||
return value ? "Open" : "Closed";
|
||||
}
|
||||
|
||||
export function renderModalityIcon(modality: string) {
|
||||
const label =
|
||||
modality === "pdf"
|
||||
? "PDF"
|
||||
: modality[0]!.toUpperCase() + modality.slice(1);
|
||||
const icon = MODALITY_ICONS[modality];
|
||||
if (!icon) return "";
|
||||
return `<span class="modality-icon" data-tooltip="${label}">${icon}</span>`;
|
||||
}
|
||||
|
||||
export function renderModalities(modalities: string[]) {
|
||||
return `<div class="modalities">${modalities
|
||||
.map(renderModalityIcon)
|
||||
.join("")}</div>`;
|
||||
}
|
||||
|
||||
export function renderCopyButton(modelId: string) {
|
||||
const escapedModelId = escapeHtml(modelId);
|
||||
return `<button type="button" class="copy-button" data-model-id="${escapedModelId}" aria-label="Copy model ID"><svg class="copy-icon" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect><path d="m4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path></svg><svg class="check-icon" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display: none;"><polyline points="20,6 9,17 4,12"></polyline></svg></button>`;
|
||||
}
|
||||
|
||||
export function renderRow(row: TableRow, index: number) {
|
||||
return `<tr data-index="${index}">
|
||||
<td><div class="provider-cell">${row.providerLogoSvg}<span>${escapeHtml(
|
||||
row.providerName
|
||||
)}</span></div></td>
|
||||
<td>${escapeHtml(row.modelName)}</td>
|
||||
<td>${escapeHtml(row.family ?? "-")}</td>
|
||||
<td>${escapeHtml(row.providerId)}</td>
|
||||
<td><div class="model-id-cell"><span class="model-id-text">${escapeHtml(
|
||||
row.modelId
|
||||
)}</span>${renderCopyButton(row.modelId)}</div></td>
|
||||
<td>${booleanText(row.toolCall)}</td>
|
||||
<td>${booleanText(row.reasoning)}</td>
|
||||
<td>${renderModalities(row.input)}</td>
|
||||
<td>${renderModalities(row.output)}</td>
|
||||
<td>${formatCost(row.inputCost)}</td>
|
||||
<td>${formatCost(row.outputCost)}</td>
|
||||
<td>${formatCost(row.reasoningCost)}</td>
|
||||
<td>${formatCost(row.cacheReadCost)}</td>
|
||||
<td>${formatCost(row.cacheWriteCost)}</td>
|
||||
<td>${formatCost(row.audioInputCost)}</td>
|
||||
<td>${formatCost(row.audioOutputCost)}</td>
|
||||
<td>${formatNumber(row.contextLimit)}</td>
|
||||
<td>${formatNumber(row.inputLimit)}</td>
|
||||
<td>${formatNumber(row.outputLimit)}</td>
|
||||
<td>${optionalBooleanText(row.structuredOutput)}</td>
|
||||
<td>${booleanText(row.temperature)}</td>
|
||||
<td>${weightsText(row.openWeights)}</td>
|
||||
<td>${knowledgeText(row.knowledge)}</td>
|
||||
<td>${escapeHtml(row.releaseDate)}</td>
|
||||
<td>${escapeHtml(row.lastUpdated)}</td>
|
||||
</tr>`;
|
||||
}
|
||||
|
||||
export function getLargestRow(rows: TableRow[]): TableRow {
|
||||
const worst: TableRow = {
|
||||
providerId: "", providerName: "", providerLogoSvg: "", modelId: "", modelName: "",
|
||||
toolCall: true, reasoning: true,
|
||||
input: [], output: [],
|
||||
contextLimit: 0, outputLimit: 0,
|
||||
structuredOutput: true, temperature: true, openWeights: false,
|
||||
releaseDate: "", lastUpdated: "",
|
||||
};
|
||||
|
||||
for (const row of rows) {
|
||||
if (row.providerName.length > worst.providerName.length) worst.providerName = row.providerName;
|
||||
if (row.modelName.length > worst.modelName.length) worst.modelName = row.modelName;
|
||||
if ((row.family ?? "").length > (worst.family ?? "").length) worst.family = row.family;
|
||||
if (row.providerId.length > worst.providerId.length) worst.providerId = row.providerId;
|
||||
if (row.modelId.length > worst.modelId.length) worst.modelId = row.modelId;
|
||||
if ((row.knowledge ?? "").length > (worst.knowledge ?? "").length) worst.knowledge = row.knowledge;
|
||||
if (row.releaseDate.length > worst.releaseDate.length) worst.releaseDate = row.releaseDate;
|
||||
if (row.lastUpdated.length > worst.lastUpdated.length) worst.lastUpdated = row.lastUpdated;
|
||||
if (row.input.length > worst.input.length) worst.input = row.input;
|
||||
if (row.output.length > worst.output.length) worst.output = row.output;
|
||||
|
||||
const costWider = (a: number | undefined, b: number | undefined) =>
|
||||
b !== undefined && (a === undefined || formatCost(b).length > formatCost(a).length);
|
||||
if (costWider(worst.inputCost, row.inputCost)) worst.inputCost = row.inputCost;
|
||||
if (costWider(worst.outputCost, row.outputCost)) worst.outputCost = row.outputCost;
|
||||
if (costWider(worst.reasoningCost, row.reasoningCost)) worst.reasoningCost = row.reasoningCost;
|
||||
if (costWider(worst.cacheReadCost, row.cacheReadCost)) worst.cacheReadCost = row.cacheReadCost;
|
||||
if (costWider(worst.cacheWriteCost, row.cacheWriteCost)) worst.cacheWriteCost = row.cacheWriteCost;
|
||||
if (costWider(worst.audioInputCost, row.audioInputCost)) worst.audioInputCost = row.audioInputCost;
|
||||
if (costWider(worst.audioOutputCost, row.audioOutputCost)) worst.audioOutputCost = row.audioOutputCost;
|
||||
|
||||
const numWider = (a: number | undefined, b: number | undefined) =>
|
||||
b !== undefined && (a === undefined || formatNumber(b).length > formatNumber(a).length);
|
||||
if (numWider(worst.contextLimit as number | undefined, row.contextLimit)) worst.contextLimit = row.contextLimit;
|
||||
if (numWider(worst.inputLimit, row.inputLimit)) worst.inputLimit = row.inputLimit;
|
||||
if (numWider(worst.outputLimit as number | undefined, row.outputLimit)) worst.outputLimit = row.outputLimit;
|
||||
}
|
||||
|
||||
return worst;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
name = "claude-3-5-haiku-20241022"
|
||||
family = "claude-haiku"
|
||||
release_date = "2024-10-22"
|
||||
last_updated = "2024-10-22"
|
||||
attachment = true
|
||||
@@ -7,7 +6,7 @@ reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2024-07-31"
|
||||
knowledge = "2024-07"
|
||||
|
||||
[cost]
|
||||
input = 0.800
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
name = "claude-3-5-haiku-latest"
|
||||
family = "claude-haiku"
|
||||
release_date = "2024-10-22"
|
||||
last_updated = "2024-10-22"
|
||||
attachment = true
|
||||
@@ -7,7 +6,7 @@ reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2024-07-31"
|
||||
knowledge = "2024-07"
|
||||
|
||||
[cost]
|
||||
input = 0.800
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
name = "claude-haiku-4-5-20251001"
|
||||
family = "claude-haiku"
|
||||
release_date = "2025-10-16"
|
||||
last_updated = "2025-10-16"
|
||||
attachment = true
|
||||
@@ -7,7 +6,7 @@ reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2025-02-28"
|
||||
knowledge = "2025-03"
|
||||
|
||||
[cost]
|
||||
input = 1.000
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
name = "claude-haiku-4-5"
|
||||
family = "claude-haiku"
|
||||
release_date = "2025-10-16"
|
||||
last_updated = "2025-10-16"
|
||||
attachment = true
|
||||
@@ -7,7 +6,7 @@ reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2025-02-28"
|
||||
knowledge = "2025-02"
|
||||
|
||||
[cost]
|
||||
input = 1.000
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
name = "claude-opus-4-1-20250805"
|
||||
family = "claude-opus"
|
||||
release_date = "2025-08-05"
|
||||
last_updated = "2025-08-05"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2025-03-31"
|
||||
knowledge = "2025-03"
|
||||
|
||||
[cost]
|
||||
input = 15.000
|
||||
@@ -18,5 +17,5 @@ context = 200_000
|
||||
output = 32_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "pdf"]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
@@ -1,13 +1,12 @@
|
||||
name = "claude-opus-4-20250514"
|
||||
family = "claude-opus"
|
||||
release_date = "2025-05-22"
|
||||
last_updated = "2025-05-22"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2025-03-31"
|
||||
knowledge = "2025-03"
|
||||
|
||||
[cost]
|
||||
input = 15.000
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
name = "claude-opus-4-5-20251101"
|
||||
family = "claude-opus"
|
||||
release_date = "2025-11-25"
|
||||
last_updated = "2025-11-25"
|
||||
attachment = true
|
||||
@@ -7,7 +6,7 @@ reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2025-03-31"
|
||||
knowledge = "2025-03"
|
||||
|
||||
[cost]
|
||||
input = 5.000
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
name = "claude-opus-4-5"
|
||||
family = "claude-opus"
|
||||
release_date = "2025-11-25"
|
||||
last_updated = "2025-11-25"
|
||||
attachment = true
|
||||
@@ -7,7 +6,7 @@ reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2025-03-31"
|
||||
knowledge = "2025-03"
|
||||
|
||||
[cost]
|
||||
input = 5.000
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
name = "claude-opus-4-6"
|
||||
family = "claude-opus"
|
||||
release_date = "2026-02-06"
|
||||
last_updated = "2026-03-13"
|
||||
attachment = true
|
||||
@@ -7,7 +6,7 @@ reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2025-05-31"
|
||||
knowledge = "2025-05"
|
||||
|
||||
[cost]
|
||||
input = 5.000
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
name = "claude-opus-4-7"
|
||||
family = "claude-opus"
|
||||
release_date = "2026-04-17"
|
||||
last_updated = "2026-04-17"
|
||||
attachment = true
|
||||
@@ -7,7 +6,7 @@ reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2026-01-31"
|
||||
knowledge = "2025-05"
|
||||
|
||||
[cost]
|
||||
input = 5.000
|
||||
@@ -15,15 +14,14 @@ output = 25.000
|
||||
cache_read = 0.500
|
||||
cache_write = 6.250
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 200_000 }
|
||||
[cost.context_over_200k]
|
||||
input = 10.000
|
||||
output = 37.500
|
||||
cache_read = 1.000
|
||||
cache_write = 12.500
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
context = 200_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
name = "claude-sonnet-4-20250514"
|
||||
family = "claude-sonnet"
|
||||
release_date = "2025-05-22"
|
||||
last_updated = "2025-05-22"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2025-03-31"
|
||||
knowledge = "2025-03"
|
||||
|
||||
[cost]
|
||||
input = 3.000
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
name = "claude-sonnet-4-5-20250929"
|
||||
family = "claude-sonnet"
|
||||
release_date = "2025-09-30"
|
||||
last_updated = "2025-09-30"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2025-07-31"
|
||||
knowledge = "2025-03"
|
||||
|
||||
[cost]
|
||||
input = 3.000
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
name = "claude-sonnet-4-5"
|
||||
family = "claude-sonnet"
|
||||
release_date = "2025-09-30"
|
||||
last_updated = "2025-09-30"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2025-07-31"
|
||||
knowledge = "2025-07"
|
||||
|
||||
[cost]
|
||||
input = 3.000
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
name = "claude-sonnet-4-6"
|
||||
family = "claude-sonnet"
|
||||
release_date = "2026-02-18"
|
||||
last_updated = "2026-03-13"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
knowledge = "2025-08-31"
|
||||
knowledge = "2025-08"
|
||||
|
||||
[cost]
|
||||
input = 3.000
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
name = "glm-4.5-air"
|
||||
family = "glm-air"
|
||||
release_date = "2025-07-29"
|
||||
last_updated = "2025-07-29"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = true
|
||||
open_weights = false
|
||||
knowledge = "2025-04"
|
||||
|
||||
[cost]
|
||||
@@ -14,7 +13,7 @@ input = 0.1143
|
||||
output = 0.286
|
||||
|
||||
[limit]
|
||||
context = 131_072
|
||||
context = 128_000
|
||||
output = 98_304
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
name = "glm-4.5-airx"
|
||||
family = "glm"
|
||||
release_date = "2025-07-29"
|
||||
last_updated = "2025-07-29"
|
||||
attachment = false
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
name = "glm-4.5-x"
|
||||
family = "glm"
|
||||
release_date = "2025-07-29"
|
||||
last_updated = "2025-07-29"
|
||||
attachment = false
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
name = "GLM-4.5"
|
||||
family = "glm"
|
||||
release_date = "2025-07-29"
|
||||
last_updated = "2025-07-29"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = true
|
||||
knowledge = "2025-04"
|
||||
open_weights = false
|
||||
knowledge = "2024-10"
|
||||
|
||||
[cost]
|
||||
input = 0.286
|
||||
output = 1.142
|
||||
|
||||
[limit]
|
||||
context = 131_072
|
||||
context = 128_000
|
||||
output = 98_304
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
name = "GLM-4.5V"
|
||||
family = "glm"
|
||||
release_date = "2025-08-12"
|
||||
last_updated = "2025-08-12"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = true
|
||||
knowledge = "2025-04"
|
||||
open_weights = false
|
||||
knowledge = "2024-10"
|
||||
|
||||
[cost]
|
||||
input = 0.290
|
||||
@@ -18,5 +17,5 @@ context = 64_000
|
||||
output = 16_384
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "video"]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
@@ -1,20 +1,19 @@
|
||||
name = "glm-4.6"
|
||||
family = "glm"
|
||||
release_date = "2025-09-30"
|
||||
last_updated = "2025-09-30"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = true
|
||||
knowledge = "2025-04"
|
||||
open_weights = false
|
||||
knowledge = "2025-03"
|
||||
|
||||
[cost]
|
||||
input = 0.286
|
||||
output = 1.142
|
||||
|
||||
[limit]
|
||||
context = 204_800
|
||||
context = 200_000
|
||||
output = 131_072
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
name = "GLM-4.6V"
|
||||
family = "glm"
|
||||
release_date = "2025-12-08"
|
||||
last_updated = "2025-12-08"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = true
|
||||
knowledge = "2025-04"
|
||||
open_weights = false
|
||||
knowledge = "2025-03"
|
||||
|
||||
[cost]
|
||||
input = 0.145
|
||||
@@ -18,5 +17,5 @@ context = 128_000
|
||||
output = 32_768
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "video"]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
@@ -1,12 +1,11 @@
|
||||
name = "glm-4.7-flashx"
|
||||
family = "glm-flash"
|
||||
release_date = "2026-01-20"
|
||||
last_updated = "2026-01-20"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = true
|
||||
open_weights = false
|
||||
knowledge = "2025-04"
|
||||
|
||||
[cost]
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
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
|
||||
open_weights = true
|
||||
knowledge = "2025-04"
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
open_weights = false
|
||||
knowledge = "2025-06"
|
||||
|
||||
[cost]
|
||||
input = 0.286
|
||||
output = 1.142
|
||||
|
||||
[limit]
|
||||
context = 204_800
|
||||
context = 200_000
|
||||
output = 131_072
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
name = "glm-5-turbo"
|
||||
family = "glm"
|
||||
release_date = "2026-03-16"
|
||||
last_updated = "2026-03-16"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0.720
|
||||
output = 3.200
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
name = "glm-5.1"
|
||||
family = "glm"
|
||||
release_date = "2026-04-10"
|
||||
last_updated = "2026-04-10"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0.860
|
||||
output = 3.500
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
name = "glm-5"
|
||||
family = "glm"
|
||||
release_date = "2026-02-12"
|
||||
last_updated = "2026-02-12"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
open_weights = true
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 0.600
|
||||
output = 2.600
|
||||
|
||||
[limit]
|
||||
context = 204_800
|
||||
context = 200_000
|
||||
output = 131_072
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
name = "GLM-5V-Turbo"
|
||||
family = "glm"
|
||||
name = "glm-5v-turbo"
|
||||
release_date = "2026-04-02"
|
||||
last_updated = "2026-04-02"
|
||||
attachment = true
|
||||
@@ -8,9 +7,6 @@ temperature = true
|
||||
tool_call = true
|
||||
open_weights = false
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0.720
|
||||
output = 3.200
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
name = "glm-for-coding"
|
||||
family = "glm"
|
||||
release_date = "2025-09-30"
|
||||
last_updated = "2025-09-30"
|
||||
attachment = false
|
||||
|
||||
@@ -6,7 +6,6 @@ attachment = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2024-04"
|
||||
|
||||
@@ -15,9 +14,9 @@ input = 0.400
|
||||
output = 1.600
|
||||
|
||||
[limit]
|
||||
context = 1_047_576
|
||||
context = 1_000_000
|
||||
output = 32_768
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "pdf"]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
@@ -6,7 +6,6 @@ attachment = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2024-04"
|
||||
|
||||
@@ -15,7 +14,7 @@ input = 0.100
|
||||
output = 0.400
|
||||
|
||||
[limit]
|
||||
context = 1_047_576
|
||||
context = 1_000_000
|
||||
output = 32_768
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -6,7 +6,6 @@ attachment = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2024-04"
|
||||
|
||||
@@ -15,9 +14,9 @@ input = 2.000
|
||||
output = 8.000
|
||||
|
||||
[limit]
|
||||
context = 1_047_576
|
||||
context = 1_000_000
|
||||
output = 32_768
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "pdf"]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
@@ -6,7 +6,6 @@ attachment = true
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2023-09"
|
||||
|
||||
@@ -19,5 +18,5 @@ context = 128_000
|
||||
output = 16_384
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "pdf"]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
@@ -1,14 +1,12 @@
|
||||
name = "gpt-5-mini"
|
||||
family = "gpt-mini"
|
||||
release_date = "2025-08-08"
|
||||
last_updated = "2025-08-08"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2024-05-30"
|
||||
knowledge = "2024-10"
|
||||
|
||||
[cost]
|
||||
input = 0.250
|
||||
@@ -16,7 +14,6 @@ output = 2.000
|
||||
|
||||
[limit]
|
||||
context = 400_000
|
||||
input = 272_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
name = "gpt-5-pro"
|
||||
family = "gpt-pro"
|
||||
release_date = "2025-10-08"
|
||||
last_updated = "2025-10-08"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2024-09-30"
|
||||
knowledge = "2024-10"
|
||||
|
||||
[cost]
|
||||
input = 15.000
|
||||
@@ -16,7 +14,6 @@ output = 120.000
|
||||
|
||||
[limit]
|
||||
context = 400_000
|
||||
input = 272_000
|
||||
output = 272_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
name = "gpt-5.1-chat-latest"
|
||||
family = "gpt-codex"
|
||||
release_date = "2025-11-14"
|
||||
last_updated = "2025-11-14"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2024-09-30"
|
||||
knowledge = "2024-10"
|
||||
|
||||
[cost]
|
||||
input = 1.250
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
name = "gpt-5.1"
|
||||
family = "gpt"
|
||||
release_date = "2025-11-14"
|
||||
last_updated = "2025-11-14"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2024-09-30"
|
||||
knowledge = "2024-10"
|
||||
|
||||
[cost]
|
||||
input = 1.250
|
||||
@@ -16,7 +14,6 @@ output = 10.000
|
||||
|
||||
[limit]
|
||||
context = 400_000
|
||||
input = 272_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
name = "gpt-5.2-chat-latest"
|
||||
family = "gpt-codex"
|
||||
release_date = "2025-12-12"
|
||||
last_updated = "2025-12-12"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2025-08-31"
|
||||
knowledge = "2024-10"
|
||||
|
||||
[cost]
|
||||
input = 1.750
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
name = "gpt-5.2"
|
||||
family = "gpt"
|
||||
release_date = "2025-12-12"
|
||||
last_updated = "2025-12-12"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2025-08-31"
|
||||
knowledge = "2024-10"
|
||||
|
||||
[cost]
|
||||
input = 1.750
|
||||
@@ -16,7 +14,6 @@ output = 14.000
|
||||
|
||||
[limit]
|
||||
context = 400_000
|
||||
input = 272_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
name = "gpt-5.4-mini-2026-03-17"
|
||||
family = "gpt-mini"
|
||||
release_date = "2026-03-19"
|
||||
last_updated = "2026-03-19"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2025-08-31"
|
||||
knowledge = "2025-08"
|
||||
|
||||
[cost]
|
||||
input = 0.750
|
||||
@@ -16,7 +14,6 @@ output = 4.500
|
||||
|
||||
[limit]
|
||||
context = 400_000
|
||||
input = 272_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
name = "gpt-5.4-mini"
|
||||
family = "gpt-mini"
|
||||
release_date = "2026-03-19"
|
||||
last_updated = "2026-03-19"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2025-08-31"
|
||||
knowledge = "2025-08"
|
||||
|
||||
[cost]
|
||||
input = 0.750
|
||||
@@ -16,7 +14,6 @@ output = 4.500
|
||||
|
||||
[limit]
|
||||
context = 400_000
|
||||
input = 272_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
name = "gpt-5.4-nano-2026-03-17"
|
||||
family = "gpt-nano"
|
||||
release_date = "2026-03-19"
|
||||
last_updated = "2026-03-19"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2025-08-31"
|
||||
knowledge = "2025-08"
|
||||
|
||||
[cost]
|
||||
input = 0.200
|
||||
@@ -16,7 +14,6 @@ output = 1.250
|
||||
|
||||
[limit]
|
||||
context = 400_000
|
||||
input = 272_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
name = "gpt-5.4-nano"
|
||||
family = "gpt-nano"
|
||||
release_date = "2026-03-19"
|
||||
last_updated = "2026-03-19"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2025-08-31"
|
||||
knowledge = "2025-08"
|
||||
|
||||
[cost]
|
||||
input = 0.200
|
||||
@@ -16,7 +14,6 @@ output = 1.250
|
||||
|
||||
[limit]
|
||||
context = 400_000
|
||||
input = 272_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
name = "gpt-5.4-pro"
|
||||
family = "gpt-pro"
|
||||
release_date = "2026-03-05"
|
||||
last_updated = "2026-03-05"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
tool_call = true
|
||||
structured_output = false
|
||||
open_weights = false
|
||||
knowledge = "2025-08-31"
|
||||
|
||||
[cost]
|
||||
input = 30.000
|
||||
output = 180.000
|
||||
cache_read = 0
|
||||
cache_write = 0
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 272_000 }
|
||||
input = 60.000
|
||||
output = 270.000
|
||||
|
||||
[limit]
|
||||
context = 1_050_000
|
||||
input = 922_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
@@ -1,31 +0,0 @@
|
||||
name = "gpt-5.4"
|
||||
family = "gpt"
|
||||
release_date = "2026-03-05"
|
||||
last_updated = "2026-03-05"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2025-08-31"
|
||||
|
||||
[cost]
|
||||
input = 2.500
|
||||
output = 15.000
|
||||
cache_read = 0.250
|
||||
cache_write = 0
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 272_000 }
|
||||
input = 5.000
|
||||
output = 22.500
|
||||
|
||||
[limit]
|
||||
context = 1_050_000
|
||||
input = 922_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "pdf"]
|
||||
output = ["text"]
|
||||
@@ -1,14 +1,12 @@
|
||||
name = "gpt-5"
|
||||
family = "gpt"
|
||||
release_date = "2025-08-08"
|
||||
last_updated = "2025-08-08"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
knowledge = "2024-09-30"
|
||||
knowledge = "2024-10"
|
||||
|
||||
[cost]
|
||||
input = 1.250
|
||||
@@ -16,7 +14,6 @@ output = 10.000
|
||||
|
||||
[limit]
|
||||
context = 400_000
|
||||
input = 272_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<svg viewBox="0 0 220 32" xmlns="http://www.w3.org/2000/svg">
|
||||
<text x="0" y="24" fill="currentColor">
|
||||
<tspan font-size="24">Abliteration</tspan>
|
||||
<tspan dx="8" dy="2" font-size="12" fill-opacity="0.6">.ai</tspan>
|
||||
</text>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 239 B |
@@ -1,22 +0,0 @@
|
||||
name = "Abliterated Model"
|
||||
release_date = "2026-01-06"
|
||||
last_updated = "2026-01-06"
|
||||
attachment = true
|
||||
reasoning = false
|
||||
tool_call = true
|
||||
structured_output = false
|
||||
temperature = true
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 3.00
|
||||
output = 3.00
|
||||
|
||||
[limit]
|
||||
context = 150_000
|
||||
input = 150_000
|
||||
output = 8_192
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
@@ -1,5 +0,0 @@
|
||||
name = "abliteration.ai"
|
||||
env = ["ABLIT_KEY"]
|
||||
npm = "@ai-sdk/openai-compatible"
|
||||
api = "https://api.abliteration.ai/v1"
|
||||
doc = "https://docs.abliteration.ai/models"
|
||||
@@ -0,0 +1,22 @@
|
||||
name = "Kimi K2 0905"
|
||||
family = "kimi"
|
||||
release_date = "2025-09-05"
|
||||
last_updated = "2025-09-05"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
temperature = true
|
||||
tool_call = true
|
||||
knowledge = "2024-10"
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.55
|
||||
output = 2.19
|
||||
|
||||
[limit]
|
||||
context = 262_144
|
||||
output = 262_144
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,27 +0,0 @@
|
||||
name = "DeepSeek V4 Flash (Alibaba Cloud)"
|
||||
family = "deepseek-flash"
|
||||
release_date = "2026-04-24"
|
||||
last_updated = "2026-04-24"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
knowledge = "2025-05"
|
||||
open_weights = true
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0.14
|
||||
output = 0.28
|
||||
cache_read = 0.028
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 384_000
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,27 +0,0 @@
|
||||
name = "DeepSeek V4 Pro (Alibaba Cloud)"
|
||||
family = "deepseek-thinking"
|
||||
release_date = "2026-04-24"
|
||||
last_updated = "2026-04-24"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
knowledge = "2025-05"
|
||||
open_weights = true
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 1.69
|
||||
output = 3.38
|
||||
cache_read = 0.13
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 384_000
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
+7
-7
@@ -1,18 +1,18 @@
|
||||
name = "Anthropic Claude Haiku Latest"
|
||||
name = "Claude Haiku 4.5"
|
||||
family = "claude-haiku"
|
||||
release_date = "2026-04-27"
|
||||
last_updated = "2026-04-27"
|
||||
release_date = "2025-09-29"
|
||||
last_updated = "2025-09-29"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
knowledge = "2025-07-31"
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 1
|
||||
output = 5
|
||||
cache_read = 0.1
|
||||
input = 1.10
|
||||
output = 5.50
|
||||
cache_read = 0.11
|
||||
cache_write = 1.25
|
||||
|
||||
[limit]
|
||||
+8
-9
@@ -1,24 +1,23 @@
|
||||
name = "AU Anthropic Claude Opus 4.6"
|
||||
name = "Claude Opus 4.1"
|
||||
family = "claude-opus"
|
||||
release_date = "2026-02-05"
|
||||
last_updated = "2026-02-05"
|
||||
release_date = "2025-08-05"
|
||||
last_updated = "2025-08-05"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
knowledge = "2025-05"
|
||||
knowledge = "2025-03-31"
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 16.50
|
||||
output = 82.50
|
||||
cache_read = 1.65
|
||||
cache_write = 20.625
|
||||
cache_read = 1.50
|
||||
cache_write = 18.75
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 128_000
|
||||
context = 200_000
|
||||
output = 32_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "pdf"]
|
||||
@@ -0,0 +1,23 @@
|
||||
name = "Claude Opus 4.5"
|
||||
release_date = "2025-11-25"
|
||||
last_updated = "2025-11-25"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
knowledge = "2025-03"
|
||||
open_weights = false
|
||||
|
||||
[cost]
|
||||
input = 5.00
|
||||
output = 25.00
|
||||
cache_read = 0.50
|
||||
cache_write = 6.25
|
||||
|
||||
[limit]
|
||||
context = 200_000
|
||||
output = 32_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image"]
|
||||
output = ["text"]
|
||||
@@ -1,33 +1,28 @@
|
||||
name = "Claude Opus 4.6 Thinking"
|
||||
name = "Claude Opus 4.6 Think"
|
||||
family = "claude-opus"
|
||||
release_date = "2026-02-05"
|
||||
last_updated = "2026-03-13"
|
||||
last_updated = "2026-02-05"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
knowledge = "2025-05-31"
|
||||
open_weights = false
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 5
|
||||
output = 25
|
||||
cache_read = 0.5
|
||||
cache_write = 6.25
|
||||
input = 5.00
|
||||
output = 25.00
|
||||
cache_read = 0.30
|
||||
cache_write = 3.75
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 200_000 }
|
||||
input = 10
|
||||
output = 37.5
|
||||
cache_read = 1.0
|
||||
cache_write = 12.5
|
||||
[cost.context_over_200k]
|
||||
input = 6.00
|
||||
output = 22.00
|
||||
cache_read = 0.60
|
||||
cache_write = 7.50
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
context = 200_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,32 +1,28 @@
|
||||
name = "Claude Opus 4.6"
|
||||
family = "claude-opus"
|
||||
release_date = "2026-02-05"
|
||||
last_updated = "2026-03-13"
|
||||
last_updated = "2026-02-05"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
knowledge = "2025-05-31"
|
||||
open_weights = false
|
||||
|
||||
interleaved = true
|
||||
|
||||
[cost]
|
||||
input = 5
|
||||
output = 25
|
||||
cache_read = 0.5
|
||||
cache_write = 6.25
|
||||
input = 5.00
|
||||
output = 25.00
|
||||
cache_read = 0.30
|
||||
cache_write = 3.75
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 200_000 }
|
||||
input = 10
|
||||
output = 37.5
|
||||
cache_read = 1.0
|
||||
cache_write = 12.5
|
||||
[cost.context_over_200k]
|
||||
input = 6.00
|
||||
output = 22.00
|
||||
cache_read = 0.60
|
||||
cache_write = 7.50
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
context = 200_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
name = "Claude Opus 4.7 Thinking"
|
||||
family = "claude-opus"
|
||||
release_date = "2026-04-16"
|
||||
last_updated = "2026-04-16"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = false
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
knowledge = "2026-01-31"
|
||||
open_weights = false
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 5
|
||||
output = 25
|
||||
cache_read = 0.5
|
||||
cache_write = 6.25
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 200_000 }
|
||||
input = 10
|
||||
output = 37.5
|
||||
cache_read = 1.0
|
||||
cache_write = 12.5
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "pdf"]
|
||||
output = ["text"]
|
||||
@@ -1,34 +0,0 @@
|
||||
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
|
||||
structured_output = true
|
||||
knowledge = "2026-01-31"
|
||||
open_weights = false
|
||||
|
||||
interleaved = true
|
||||
|
||||
[cost]
|
||||
input = 5
|
||||
output = 25
|
||||
cache_read = 0.5
|
||||
cache_write = 6.25
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 200_000 }
|
||||
input = 10
|
||||
output = 37.5
|
||||
cache_read = 1.0
|
||||
cache_write = 12.5
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "pdf"]
|
||||
output = ["text"]
|
||||
+7
-8
@@ -1,18 +1,17 @@
|
||||
name = "Claude 3.7 Sonnet"
|
||||
name = "Claude Sonnet 4.5"
|
||||
family = "claude-sonnet"
|
||||
release_date = "2025-02-24"
|
||||
last_updated = "2025-02-24"
|
||||
release_date = "2025-09-29"
|
||||
last_updated = "2025-09-29"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
knowledge = "2024-11"
|
||||
knowledge = "2025-07-31"
|
||||
open_weights = false
|
||||
status = "deprecated"
|
||||
|
||||
[cost]
|
||||
input = 3.00
|
||||
output = 15.00
|
||||
input = 3.30
|
||||
output = 16.50
|
||||
cache_read = 0.30
|
||||
cache_write = 3.75
|
||||
|
||||
@@ -21,5 +20,5 @@ context = 200_000
|
||||
output = 64_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image"]
|
||||
input = ["text", "image", "pdf"]
|
||||
output = ["text"]
|
||||
@@ -1,33 +1,28 @@
|
||||
name = "Claude Sonnet 4.6 Thinking"
|
||||
name = "Claude Sonnet 4.6 Think"
|
||||
family = "claude-sonnet"
|
||||
release_date = "2026-02-17"
|
||||
last_updated = "2026-03-13"
|
||||
last_updated = "2026-02-17"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
knowledge = "2025-08-31"
|
||||
open_weights = false
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 3.00
|
||||
output = 15.00
|
||||
cache_read = 0.30
|
||||
cache_write = 3.75
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 200_000 }
|
||||
[cost.context_over_200k]
|
||||
input = 6.00
|
||||
output = 22.50
|
||||
cache_read = 0.60
|
||||
cache_write = 7.50
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
context = 200_000
|
||||
output = 64_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -1,32 +1,28 @@
|
||||
name = "Claude Sonnet 4.6"
|
||||
family = "claude-sonnet"
|
||||
release_date = "2026-02-17"
|
||||
last_updated = "2026-03-13"
|
||||
last_updated = "2026-02-17"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
knowledge = "2025-08-31"
|
||||
open_weights = false
|
||||
|
||||
interleaved = true
|
||||
|
||||
[cost]
|
||||
input = 3.00
|
||||
output = 15.00
|
||||
cache_read = 0.30
|
||||
cache_write = 3.75
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 200_000 }
|
||||
[cost.context_over_200k]
|
||||
input = 6.00
|
||||
output = 22.50
|
||||
cache_read = 0.60
|
||||
cache_write = 7.50
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
context = 200_000
|
||||
output = 64_000
|
||||
|
||||
[modalities]
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
name = "Coding GLM 4.7 Free"
|
||||
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
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_details"
|
||||
|
||||
[cost]
|
||||
input = 0
|
||||
output = 0
|
||||
cache_read = 0
|
||||
cache_write = 0
|
||||
|
||||
[limit]
|
||||
context = 204800
|
||||
output = 131072
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
name = "Coding-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
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_details"
|
||||
|
||||
[cost]
|
||||
input = 0.06
|
||||
output = 0.22
|
||||
cache_read = 0.01
|
||||
|
||||
[limit]
|
||||
context = 204800
|
||||
output = 131072
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
|
||||
+8
-8
@@ -1,23 +1,23 @@
|
||||
name = "Laguna M.1 (free)"
|
||||
release_date = "2026-04-28"
|
||||
last_updated = "2026-04-28"
|
||||
name = "Coding-GLM-5-Free"
|
||||
family = "glm"
|
||||
release_date = "2026-02-11"
|
||||
last_updated = "2026-02-11"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = false
|
||||
open_weights = false
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0
|
||||
output = 0
|
||||
input = 0.0
|
||||
output = 0.0
|
||||
|
||||
[limit]
|
||||
context = 131_072
|
||||
output = 8_192
|
||||
context = 204800
|
||||
output = 131072
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
@@ -1,4 +1,4 @@
|
||||
name = "Coding GLM 5.1"
|
||||
name = "Coding-GLM-5.1"
|
||||
family = "glm"
|
||||
release_date = "2026-04-11"
|
||||
last_updated = "2026-04-11"
|
||||
@@ -6,8 +6,7 @@ attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = true
|
||||
open_weights = false
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
@@ -15,11 +14,10 @@ field = "reasoning_content"
|
||||
[cost]
|
||||
input = 0.06
|
||||
output = 0.22
|
||||
cache_read = 0.013
|
||||
|
||||
[limit]
|
||||
context = 200_000
|
||||
output = 128_000
|
||||
context = 200000
|
||||
output = 128000
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
|
||||
+10
-7
@@ -1,22 +1,25 @@
|
||||
name = "Llama 3.3 Nemotron Super 49B v1.5"
|
||||
family = "nemotron"
|
||||
release_date = "2025-07-25"
|
||||
last_updated = "2025-07-25"
|
||||
name = "Coding MiniMax M2.1 Free"
|
||||
family = "minimax"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
knowledge = "2023-12"
|
||||
tool_call = true
|
||||
temperature = true
|
||||
release_date = "2025-12-23"
|
||||
last_updated = "2025-12-23"
|
||||
open_weights = true
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_details"
|
||||
|
||||
[cost]
|
||||
input = 0.0
|
||||
output = 0.0
|
||||
|
||||
[limit]
|
||||
context = 131_072
|
||||
context = 204_800
|
||||
output = 131_072
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
name = "Coding MiniMax M2.7 Highspeed"
|
||||
family = "minimax"
|
||||
release_date = "2026-03-18"
|
||||
last_updated = "2026-03-18"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = true
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0.2
|
||||
output = 0.2
|
||||
|
||||
[limit]
|
||||
context = 204_800
|
||||
output = 128_100
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,17 +0,0 @@
|
||||
name = "Coding Xiaomi MiMo-V2.5-Pro"
|
||||
family = "mimo-v2.5-pro"
|
||||
last_updated = "2026-05-13"
|
||||
|
||||
[extends]
|
||||
from = "xiaomi/mimo-v2.5-pro"
|
||||
|
||||
[cost]
|
||||
input = 0.20
|
||||
output = 0.60
|
||||
cache_read = 0.04
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 256_000 }
|
||||
input = 0.40
|
||||
output = 1.20
|
||||
cache_read = 0.08
|
||||
@@ -1,17 +0,0 @@
|
||||
name = "Coding Xiaomi MiMo-V2.5"
|
||||
family = "mimo-v2.5"
|
||||
last_updated = "2026-05-13"
|
||||
|
||||
[extends]
|
||||
from = "xiaomi/mimo-v2.5"
|
||||
|
||||
[cost]
|
||||
input = 0.08
|
||||
output = 0.40
|
||||
cache_read = 0.016
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 256_000 }
|
||||
input = 0.16
|
||||
output = 0.80
|
||||
cache_read = 0.032
|
||||
@@ -1,27 +0,0 @@
|
||||
name = "DeepSeek V4 Flash (DeepSeek)"
|
||||
family = "deepseek-flash"
|
||||
release_date = "2026-04-24"
|
||||
last_updated = "2026-04-24"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
knowledge = "2025-05"
|
||||
open_weights = true
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0.154
|
||||
output = 0.308
|
||||
cache_read = 0.0308
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 384_000
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -1,27 +0,0 @@
|
||||
name = "DeepSeek V4 Pro (DeepSeek)"
|
||||
family = "deepseek-thinking"
|
||||
release_date = "2026-04-24"
|
||||
last_updated = "2026-04-24"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
knowledge = "2025-05"
|
||||
open_weights = true
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0.478
|
||||
output = 0.956
|
||||
cache_read = 0.004302
|
||||
|
||||
[limit]
|
||||
context = 1_000_000
|
||||
output = 384_000
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
@@ -0,0 +1,21 @@
|
||||
name = "DeepSeek-V3.2-Fast"
|
||||
family = "deepseek"
|
||||
release_date = "2025-12-01"
|
||||
last_updated = "2025-12-01"
|
||||
attachment = false
|
||||
reasoning = false
|
||||
knowledge = "2024-07"
|
||||
tool_call = false
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 1.10
|
||||
output = 3.29
|
||||
|
||||
[limit]
|
||||
context = 128_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
output = ["text"]
|
||||
+7
-7
@@ -1,21 +1,21 @@
|
||||
name = "Trinity Mini"
|
||||
family = "trinity-mini"
|
||||
name = "DeepSeek-V3.2-Think"
|
||||
family = "deepseek"
|
||||
release_date = "2025-12-01"
|
||||
last_updated = "2025-12-01"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
temperature = true
|
||||
knowledge = "2024-07"
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.045
|
||||
output = 0.15
|
||||
input = 0.30
|
||||
output = 0.45
|
||||
|
||||
[limit]
|
||||
context = 131_072
|
||||
output = 131_072
|
||||
context = 131_000
|
||||
output = 64_000
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
+7
-7
@@ -1,21 +1,21 @@
|
||||
name = "DeepSeek V3.2"
|
||||
name = "DeepSeek-V3.2"
|
||||
family = "deepseek"
|
||||
release_date = "2025-12-01"
|
||||
last_updated = "2025-12-01"
|
||||
knowledge = "2024-07"
|
||||
attachment = false
|
||||
reasoning = true
|
||||
tool_call = true
|
||||
temperature = true
|
||||
knowledge = "2024-07"
|
||||
tool_call = true
|
||||
open_weights = true
|
||||
|
||||
[cost]
|
||||
input = 0.266
|
||||
output = 0.444
|
||||
input = 0.30
|
||||
output = 0.45
|
||||
|
||||
[limit]
|
||||
context = 163_840
|
||||
output = 163_840
|
||||
context = 131_000
|
||||
output = 64_000
|
||||
|
||||
[modalities]
|
||||
input = ["text"]
|
||||
@@ -1,38 +0,0 @@
|
||||
name = "Doubao Seed 2.0 Code Preview"
|
||||
family = "seed"
|
||||
release_date = "2026-02-14"
|
||||
last_updated = "2026-02-14"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0.48
|
||||
output = 2.41
|
||||
cache_read = 0.09644
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 32_000 }
|
||||
input = 0.72
|
||||
output = 3.62
|
||||
cache_read = 0.144656
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 128_000 }
|
||||
input = 1.45
|
||||
output = 7.23
|
||||
cache_read = 0.28932
|
||||
|
||||
[limit]
|
||||
context = 256_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "video"]
|
||||
output = ["text"]
|
||||
@@ -1,41 +0,0 @@
|
||||
name = "Doubao Seed 2.0 Lite 260428"
|
||||
family = "seed"
|
||||
release_date = "2026-04-28"
|
||||
last_updated = "2026-04-28"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0.08
|
||||
output = 0.51
|
||||
cache_read = 0.01692
|
||||
input_audio = 1.269
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 32_000 }
|
||||
input = 0.13
|
||||
output = 0.76
|
||||
cache_read = 0.02536
|
||||
input_audio = 1.902
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 128_000 }
|
||||
input = 0.25
|
||||
output = 1.52
|
||||
cache_read = 0.05072
|
||||
input_audio = 3.804
|
||||
|
||||
[limit]
|
||||
context = 256_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "video"]
|
||||
output = ["text"]
|
||||
@@ -1,41 +0,0 @@
|
||||
name = "Doubao Seed 2.0 Mini 260428"
|
||||
family = "seed"
|
||||
release_date = "2026-04-28"
|
||||
last_updated = "2026-04-28"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0.03
|
||||
output = 0.28
|
||||
cache_read = 0.00564
|
||||
input_audio = 0.423
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 32_000 }
|
||||
input = 0.06
|
||||
output = 0.56
|
||||
cache_read = 0.01128
|
||||
input_audio = 0.846
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 128_000 }
|
||||
input = 0.11
|
||||
output = 1.13
|
||||
cache_read = 0.02256
|
||||
input_audio = 1.692
|
||||
|
||||
[limit]
|
||||
context = 256_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "video"]
|
||||
output = ["text"]
|
||||
@@ -1,38 +0,0 @@
|
||||
name = "Doubao Seed 2.0 Pro"
|
||||
family = "seed"
|
||||
release_date = "2026-02-14"
|
||||
last_updated = "2026-02-14"
|
||||
attachment = true
|
||||
reasoning = true
|
||||
temperature = true
|
||||
tool_call = true
|
||||
structured_output = true
|
||||
open_weights = false
|
||||
|
||||
[interleaved]
|
||||
field = "reasoning_content"
|
||||
|
||||
[cost]
|
||||
input = 0.48
|
||||
output = 2.41
|
||||
cache_read = 0.09644
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 32_000 }
|
||||
input = 0.72
|
||||
output = 3.62
|
||||
cache_read = 0.144656
|
||||
|
||||
[[cost.tiers]]
|
||||
tier = { size = 128_000 }
|
||||
input = 1.45
|
||||
output = 7.23
|
||||
cache_read = 0.28932
|
||||
|
||||
[limit]
|
||||
context = 256_000
|
||||
output = 128_000
|
||||
|
||||
[modalities]
|
||||
input = ["text", "image", "video"]
|
||||
output = ["text"]
|
||||
Loaded 100 of 1473 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user