Files
openclaw/scripts/publish-model-catalog.d.mts
Peter Steinberger 5347285d6b improve(models): source pricing from hosted catalog (#114060)
* feat(model-catalog): serve hosted fallback pricing

* refactor(config): retire client pricing bootstrap settings

* refactor(gateway): delete client pricing refresh runtime

* docs(models): explain hosted catalog pricing

* fix(model-catalog): preserve pricing privacy and aliases

* fix(model-catalog): fingerprint pricing eligibility

* fix(model-catalog): harden pricing endpoint checks

* fix(model-catalog): materialize source-safe pricing aliases

* fix(model-catalog): keep unknown pricing fallbacks safe

* fix(model-catalog): reject zero-only hosted prices

* fix(model-catalog): fail closed without pricing policy metadata

* refactor(utils): extract usage pricing normalization

* fix(model-catalog): rebuild policy-owned pricing namespaces

* test(model-catalog): type publisher cost fixtures

* chore(config): regenerate schema baselines

* fix(utils): keep raw pricing tiers private
2026-07-26 03:48:25 -04:00

81 lines
2.3 KiB
TypeScript

export const MODEL_CATALOG_MIN_MODELS: 200;
export const OPENROUTER_MODELS_URL: "https://openrouter.ai/api/v1/models";
export const LITELLM_PRICING_URL: "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json";
export type ModelCatalogManifestInput = {
pluginId: string;
manifestPath: string;
manifest: {
modelCatalog?: {
providers?: Record<string, unknown>;
};
modelPricing?: {
providers?: Record<string, unknown>;
};
};
};
export type PublishModelCatalogArgs = {
dryRun: boolean;
pricing: boolean;
out?: string;
};
export type ModelCatalogBundleSummary = {
providers: number;
models: number;
costModels: number;
pricingEntries: number;
};
export type PublishedModelPricing = {
input: number;
output: number;
cacheRead?: number;
cacheWrite?: number;
tieredPricing?: Array<{
input: number;
output: number;
cacheRead: number;
cacheWrite: number;
range: [number] | [number, number];
}>;
};
export type PublishedModelCatalogBundle = {
schemaVersion: 1;
generatedAt: number;
minVersion?: string;
sourceCommit: string;
providers: Record<
string,
{
models: Array<{ id: string; cost?: Record<string, unknown>; [key: string]: unknown }>;
[key: string]: unknown;
}
>;
pricing?: Record<string, PublishedModelPricing>;
};
export function parsePublishModelCatalogArgs(args: string[]): PublishModelCatalogArgs;
export function readModelCatalogManifests(options?: {
rootDir?: string;
}): ModelCatalogManifestInput[];
export function assembleModelCatalogBundle(options: {
manifests: ModelCatalogManifestInput[];
generatedAt: number;
sourceCommit: string;
minVersion?: string;
validateBundle?: (bundle: unknown) => PublishedModelCatalogBundle;
}): Promise<PublishedModelCatalogBundle>;
export function summarizeModelCatalogBundle(
bundle: PublishedModelCatalogBundle,
): ModelCatalogBundleSummary;
export function enrichModelCatalogPricing(options: {
bundle: PublishedModelCatalogBundle;
manifests: ModelCatalogManifestInput[];
fetchImpl?: typeof fetch;
validateBundle?: (bundle: unknown) => PublishedModelCatalogBundle;
}): Promise<{ modelsEnriched: number; pricingEntries: number }>;
export function serializeModelCatalogBundle(bundle: PublishedModelCatalogBundle): string;