@pydantic/genai-prices 0.0.6 → 0.0.7

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/README.md CHANGED
@@ -174,7 +174,7 @@ src/
174
174
  ### Common Issues
175
175
 
176
176
  - **No price found (returns null)**:
177
- - Make sure you specify the correct `providerId` (e.g., `openai`)
177
+ - Make sure you specify the correct `providerId` (e.g., `openai`, `google`, `anthropic`)
178
178
  - Try using `provider:model` format in CLI
179
179
  - Use `--auto-update` flag to fetch latest data
180
180
  - Check that the model name is correct and supported by the provider
@@ -0,0 +1 @@
1
+ export {};
package/dist/data.js CHANGED
@@ -1292,6 +1292,16 @@ export const data = [
1292
1292
  model_match: {
1293
1293
  contains: 'gemini',
1294
1294
  },
1295
+ provider_match: {
1296
+ or: [
1297
+ {
1298
+ contains: 'google',
1299
+ },
1300
+ {
1301
+ equals: 'gemini',
1302
+ },
1303
+ ],
1304
+ },
1295
1305
  models: [
1296
1306
  {
1297
1307
  id: 'claude-3-5-haiku',
@@ -1973,6 +1983,9 @@ export const data = [
1973
1983
  model_match: {
1974
1984
  regex: '(?:mi|code|dev|magi|mini)stral',
1975
1985
  },
1986
+ provider_match: {
1987
+ starts_with: 'mistral',
1988
+ },
1976
1989
  models: [
1977
1990
  {
1978
1991
  id: 'codestral',
@@ -1298,6 +1298,16 @@
1298
1298
  model_match: {
1299
1299
  contains: "gemini"
1300
1300
  },
1301
+ provider_match: {
1302
+ or: [
1303
+ {
1304
+ contains: "google"
1305
+ },
1306
+ {
1307
+ equals: "gemini"
1308
+ }
1309
+ ]
1310
+ },
1301
1311
  models: [
1302
1312
  {
1303
1313
  id: "claude-3-5-haiku",
@@ -1979,6 +1989,9 @@
1979
1989
  model_match: {
1980
1990
  regex: "(?:mi|code|dev|magi|mini)stral"
1981
1991
  },
1992
+ provider_match: {
1993
+ starts_with: "mistral"
1994
+ },
1982
1995
  models: [
1983
1996
  {
1984
1997
  id: "codestral",
@@ -10573,9 +10586,15 @@
10573
10586
  }
10574
10587
  return false;
10575
10588
  }
10589
+ function findProviderById(providers, providerId) {
10590
+ const normalizedProviderId = providerId.toLowerCase().trim();
10591
+ const exactMatch = providers.find((p) => p.id === normalizedProviderId);
10592
+ if (exactMatch) return exactMatch;
10593
+ return providers.find((p) => p.provider_match && matchLogic(p.provider_match, normalizedProviderId));
10594
+ }
10576
10595
  function matchProvider(providers, modelRef, providerId, providerApiUrl) {
10577
10596
  if (providerId) {
10578
- return providers.find((p) => p.id === providerId);
10597
+ return findProviderById(providers, providerId);
10579
10598
  }
10580
10599
  if (providerApiUrl) {
10581
10600
  return providers.find((p) => new RegExp(p.api_pattern).test(providerApiUrl));
package/dist/matcher.js CHANGED
@@ -22,14 +22,20 @@ function matchLogic(logic, text) {
22
22
  }
23
23
  return false;
24
24
  }
25
+ function findProviderById(providers, providerId) {
26
+ const normalizedProviderId = providerId.toLowerCase().trim();
27
+ const exactMatch = providers.find((p) => p.id === normalizedProviderId);
28
+ if (exactMatch)
29
+ return exactMatch;
30
+ return providers.find((p) => p.provider_match && matchLogic(p.provider_match, normalizedProviderId));
31
+ }
25
32
  export function matchProvider(providers, modelRef, providerId, providerApiUrl) {
26
33
  if (providerId) {
27
- return providers.find((p) => p.id === providerId);
34
+ return findProviderById(providers, providerId);
28
35
  }
29
36
  if (providerApiUrl) {
30
37
  return providers.find((p) => new RegExp(p.api_pattern).test(providerApiUrl));
31
38
  }
32
- // Try model_match logic
33
39
  return providers.find((p) => p.model_match && matchLogic(p.model_match, modelRef));
34
40
  }
35
41
  export function matchModel(models, modelRef) {
package/dist/types.d.ts CHANGED
@@ -71,6 +71,7 @@ export interface Provider {
71
71
  description?: string;
72
72
  price_comments?: string;
73
73
  model_match?: MatchLogic;
74
+ provider_match?: MatchLogic;
74
75
  models: ModelInfo[];
75
76
  }
76
77
  export interface PriceCalculation {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pydantic/genai-prices",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Calculate prices for calling LLM inference APIs (JS/TS version of genai-prices)",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",