@pydantic/genai-prices 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +59 -147
- package/dist/cli.js +11684 -150
- package/dist/index.cjs +10 -0
- package/dist/index.d.cts +146 -0
- package/dist/index.d.ts +146 -5
- package/dist/index.js +11032 -4
- package/package.json +55 -28
- package/dist/__tests__/calcPrice.test.d.ts +0 -1
- package/dist/__tests__/comprehensive.test.d.ts +0 -1
- package/dist/__tests__/matcher.test.d.ts +0 -1
- package/dist/async/calcPriceAsync.d.ts +0 -8
- package/dist/async/calcPriceAsync.js +0 -24
- package/dist/cli.d.ts +0 -1
- package/dist/data.d.ts +0 -2
- package/dist/data.js +0 -10605
- package/dist/dataLoader.d.ts +0 -18
- package/dist/dataLoader.js +0 -146
- package/dist/index.umd.cjs +0 -10914
- package/dist/matcher.d.ts +0 -3
- package/dist/matcher.js +0 -43
- package/dist/priceCalc.d.ts +0 -3
- package/dist/priceCalc.js +0 -90
- package/dist/sync/calcPriceSync.d.ts +0 -8
- package/dist/sync/calcPriceSync.js +0 -24
- package/dist/types.d.ts +0 -95
- package/dist/types.js +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,146 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export declare function calcPrice(usage: Usage, modelId: string, options?: PriceOptions): PriceCalculationResult;
|
|
2
|
+
|
|
3
|
+
export declare interface ConditionalPrice {
|
|
4
|
+
constraint?: StartDateConstraint | TimeOfDateConstraint;
|
|
5
|
+
prices: ModelPrice;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export declare function extractUsage(provider: Provider, responseData: unknown, apiFlavor?: string): [string, Usage];
|
|
9
|
+
|
|
10
|
+
export declare type MatchLogic = {
|
|
11
|
+
and: MatchLogic[];
|
|
12
|
+
} | {
|
|
13
|
+
contains: string;
|
|
14
|
+
} | {
|
|
15
|
+
ends_with: string;
|
|
16
|
+
} | {
|
|
17
|
+
equals: string;
|
|
18
|
+
} | {
|
|
19
|
+
or: MatchLogic[];
|
|
20
|
+
} | {
|
|
21
|
+
regex: string;
|
|
22
|
+
} | {
|
|
23
|
+
starts_with: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export declare interface ModelInfo {
|
|
27
|
+
context_window?: number;
|
|
28
|
+
description?: string;
|
|
29
|
+
id: string;
|
|
30
|
+
match: MatchLogic;
|
|
31
|
+
name?: string;
|
|
32
|
+
price_comments?: string;
|
|
33
|
+
prices: ConditionalPrice[] | ModelPrice;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export declare interface ModelPrice {
|
|
37
|
+
cache_audio_read_mtok?: number | TieredPrices;
|
|
38
|
+
cache_read_mtok?: number | TieredPrices;
|
|
39
|
+
cache_write_mtok?: number | TieredPrices;
|
|
40
|
+
input_audio_mtok?: number | TieredPrices;
|
|
41
|
+
input_mtok?: number | TieredPrices;
|
|
42
|
+
output_audio_mtok?: number | TieredPrices;
|
|
43
|
+
output_mtok?: number | TieredPrices;
|
|
44
|
+
requests_kcount?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare interface ModelPriceCalculationResult {
|
|
48
|
+
input_price: number;
|
|
49
|
+
output_price: number;
|
|
50
|
+
total_price: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export declare interface PriceCalculation {
|
|
54
|
+
auto_update_timestamp?: string;
|
|
55
|
+
input_price: number;
|
|
56
|
+
model: ModelInfo;
|
|
57
|
+
model_price: ModelPrice;
|
|
58
|
+
output_price: number;
|
|
59
|
+
provider: Provider;
|
|
60
|
+
total_price: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export declare type PriceCalculationResult = null | PriceCalculation;
|
|
64
|
+
|
|
65
|
+
export declare interface PriceDataStorage {
|
|
66
|
+
get: () => Promise<null | string>;
|
|
67
|
+
get_last_modified?: () => Promise<null | number>;
|
|
68
|
+
set: (data: string) => Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export declare interface PriceOptions {
|
|
72
|
+
providerApiUrl?: string;
|
|
73
|
+
providerId?: string;
|
|
74
|
+
timestamp?: Date;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export declare interface Provider {
|
|
78
|
+
api_pattern: string;
|
|
79
|
+
description?: string;
|
|
80
|
+
extractors?: UsageExtractor[];
|
|
81
|
+
id: string;
|
|
82
|
+
model_match?: MatchLogic;
|
|
83
|
+
models: ModelInfo[];
|
|
84
|
+
name: string;
|
|
85
|
+
price_comments?: string;
|
|
86
|
+
pricing_urls?: string[];
|
|
87
|
+
provider_match?: MatchLogic;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export declare const REMOTE_DATA_JSON_URL = "https://raw.githubusercontent.com/pydantic/genai-prices/main/prices/data.json";
|
|
91
|
+
|
|
92
|
+
export declare interface StartDateConstraint {
|
|
93
|
+
start_date: string;
|
|
94
|
+
type: 'start_date';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export declare interface StorageFactoryParams {
|
|
98
|
+
onCalc: (cb: () => void) => void;
|
|
99
|
+
remoteDataUrl: string;
|
|
100
|
+
setProviderData: (data: Promise<Provider[]> | Provider[]) => void;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export declare interface Tier {
|
|
104
|
+
price: number;
|
|
105
|
+
start: number;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export declare interface TieredPrices {
|
|
109
|
+
base: number;
|
|
110
|
+
tiers: Tier[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export declare interface TimeOfDateConstraint {
|
|
114
|
+
end_time: string;
|
|
115
|
+
start_time: string;
|
|
116
|
+
type: 'time_of_date';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export declare function updatePrices(factory: (options: StorageFactoryParams) => any): void;
|
|
120
|
+
|
|
121
|
+
export declare interface Usage {
|
|
122
|
+
cache_audio_read_tokens?: number;
|
|
123
|
+
cache_read_tokens?: number;
|
|
124
|
+
cache_write_tokens?: number;
|
|
125
|
+
input_audio_tokens?: number;
|
|
126
|
+
input_tokens?: number;
|
|
127
|
+
output_audio_tokens?: number;
|
|
128
|
+
output_tokens?: number;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export declare interface UsageExtractor {
|
|
132
|
+
api_flavor: string;
|
|
133
|
+
mappings: UsageExtractorMapping[];
|
|
134
|
+
model_path: string | string[];
|
|
135
|
+
root: string | string[];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export declare interface UsageExtractorMapping {
|
|
139
|
+
dest: 'cache_audio_read_tokens' | 'cache_read_tokens' | 'cache_write_tokens' | 'input_audio_tokens' | 'input_tokens' | 'output_audio_tokens' | 'output_tokens';
|
|
140
|
+
path: string | string[];
|
|
141
|
+
required: boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export declare function waitForUpdate(): Promise<Provider[]>;
|
|
145
|
+
|
|
146
|
+
export { }
|