@pydantic/genai-prices 0.0.42 → 0.0.44

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/dist/index.js CHANGED
@@ -47,6 +47,28 @@ const x = [
47
47
  required: !0
48
48
  }
49
49
  ]
50
+ },
51
+ {
52
+ api_flavor: "chat",
53
+ root: "usage",
54
+ model_path: "model",
55
+ mappings: [
56
+ {
57
+ path: "prompt_tokens",
58
+ dest: "input_tokens",
59
+ required: !0
60
+ },
61
+ {
62
+ path: "cached_tokens",
63
+ dest: "cache_read_tokens",
64
+ required: !1
65
+ },
66
+ {
67
+ path: "completion_tokens",
68
+ dest: "output_tokens",
69
+ required: !0
70
+ }
71
+ ]
50
72
  }
51
73
  ],
52
74
  models: [
@@ -596,24 +618,50 @@ const x = [
596
618
  }
597
619
  },
598
620
  {
599
- id: "anthropic.claude-3-haiku-20240307-v1:0",
600
- name: "Claude 3 Haiku",
621
+ id: "deepseek.r1-v1:0",
622
+ name: "DeepSeek-R1",
601
623
  match: {
602
- contains: "claude-3-haiku-20240307"
624
+ contains: "r1"
603
625
  },
604
626
  prices: {
605
- input_mtok: 0.25
627
+ input_mtok: 1.35,
628
+ output_mtok: 5.4
606
629
  }
607
630
  },
608
631
  {
609
- id: "deepseek.r1-v1:0",
610
- name: "DeepSeek-R1",
632
+ id: "global.anthropic.claude-haiku-4-5-20251001-v1:0",
611
633
  match: {
612
- contains: "r1"
634
+ starts_with: "global.anthropic.claude-haiku-4-5-20251001-v1"
613
635
  },
614
636
  prices: {
615
- input_mtok: 1.35,
616
- output_mtok: 5.4
637
+ input_mtok: 1,
638
+ cache_write_mtok: 1.25,
639
+ cache_read_mtok: 0.1,
640
+ output_mtok: 5
641
+ }
642
+ },
643
+ {
644
+ id: "global.anthropic.claude-sonnet-4-20250514-v1:0",
645
+ match: {
646
+ starts_with: "global.anthropic.claude-sonnet-4-20250514-v1"
647
+ },
648
+ prices: {
649
+ input_mtok: 3,
650
+ cache_write_mtok: 3.75,
651
+ cache_read_mtok: 0.3,
652
+ output_mtok: 15
653
+ }
654
+ },
655
+ {
656
+ id: "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
657
+ match: {
658
+ starts_with: "global.anthropic.claude-sonnet-4-5-20250929-v1"
659
+ },
660
+ prices: {
661
+ input_mtok: 3,
662
+ cache_write_mtok: 3.75,
663
+ cache_read_mtok: 0.3,
664
+ output_mtok: 15
617
665
  }
618
666
  },
619
667
  {
@@ -835,6 +883,374 @@ const x = [
835
883
  input_mtok: 0.15,
836
884
  output_mtok: 0.6
837
885
  }
886
+ },
887
+ {
888
+ id: "regional.anthropic.claude-3-5-haiku-20241022-v1:0",
889
+ match: {
890
+ or: [
891
+ {
892
+ starts_with: "us.anthropic.claude-3-5-haiku-20241022-v1"
893
+ },
894
+ {
895
+ starts_with: "au.anthropic.claude-3-5-haiku-20241022-v1"
896
+ },
897
+ {
898
+ starts_with: "apac.anthropic.claude-3-5-haiku-20241022-v1"
899
+ },
900
+ {
901
+ starts_with: "eu.anthropic.claude-3-5-haiku-20241022-v1"
902
+ },
903
+ {
904
+ starts_with: "us-gov.anthropic.claude-3-5-haiku-20241022-v1"
905
+ },
906
+ {
907
+ starts_with: "jp.anthropic.claude-3-5-haiku-20241022-v1"
908
+ }
909
+ ]
910
+ },
911
+ prices: {
912
+ input_mtok: 0.8,
913
+ cache_write_mtok: 1,
914
+ cache_read_mtok: 0.08,
915
+ output_mtok: 4
916
+ }
917
+ },
918
+ {
919
+ id: "regional.anthropic.claude-3-5-sonnet-20240620-v1:0",
920
+ match: {
921
+ or: [
922
+ {
923
+ starts_with: "us.anthropic.claude-3-5-sonnet-20240620-v1"
924
+ },
925
+ {
926
+ starts_with: "au.anthropic.claude-3-5-sonnet-20240620-v1"
927
+ },
928
+ {
929
+ starts_with: "apac.anthropic.claude-3-5-sonnet-20240620-v1"
930
+ },
931
+ {
932
+ starts_with: "eu.anthropic.claude-3-5-sonnet-20240620-v1"
933
+ },
934
+ {
935
+ starts_with: "us-gov.anthropic.claude-3-5-sonnet-20240620-v1"
936
+ },
937
+ {
938
+ starts_with: "jp.anthropic.claude-3-5-sonnet-20240620-v1"
939
+ }
940
+ ]
941
+ },
942
+ prices: {
943
+ input_mtok: 3,
944
+ cache_write_mtok: 3.75,
945
+ cache_read_mtok: 0.3,
946
+ output_mtok: 15
947
+ }
948
+ },
949
+ {
950
+ id: "regional.anthropic.claude-3-5-sonnet-20241022-v2:0",
951
+ match: {
952
+ or: [
953
+ {
954
+ starts_with: "us.anthropic.claude-3-5-sonnet-20241022-v2"
955
+ },
956
+ {
957
+ starts_with: "au.anthropic.claude-3-5-sonnet-20241022-v2"
958
+ },
959
+ {
960
+ starts_with: "apac.anthropic.claude-3-5-sonnet-20241022-v2"
961
+ },
962
+ {
963
+ starts_with: "eu.anthropic.claude-3-5-sonnet-20241022-v2"
964
+ },
965
+ {
966
+ starts_with: "us-gov.anthropic.claude-3-5-sonnet-20241022-v2"
967
+ },
968
+ {
969
+ starts_with: "jp.anthropic.claude-3-5-sonnet-20241022-v2"
970
+ }
971
+ ]
972
+ },
973
+ prices: {
974
+ input_mtok: 3,
975
+ cache_write_mtok: 3.75,
976
+ cache_read_mtok: 0.3,
977
+ output_mtok: 15
978
+ }
979
+ },
980
+ {
981
+ id: "regional.anthropic.claude-3-7-sonnet-20250219-v1:0",
982
+ match: {
983
+ or: [
984
+ {
985
+ starts_with: "us.anthropic.claude-3-7-sonnet-20250219-v1"
986
+ },
987
+ {
988
+ starts_with: "au.anthropic.claude-3-7-sonnet-20250219-v1"
989
+ },
990
+ {
991
+ starts_with: "apac.anthropic.claude-3-7-sonnet-20250219-v1"
992
+ },
993
+ {
994
+ starts_with: "eu.anthropic.claude-3-7-sonnet-20250219-v1"
995
+ },
996
+ {
997
+ starts_with: "us-gov.anthropic.claude-3-7-sonnet-20250219-v1"
998
+ },
999
+ {
1000
+ starts_with: "jp.anthropic.claude-3-7-sonnet-20250219-v1"
1001
+ }
1002
+ ]
1003
+ },
1004
+ prices: {
1005
+ input_mtok: 3,
1006
+ cache_write_mtok: 3.75,
1007
+ cache_read_mtok: 0.3,
1008
+ output_mtok: 15
1009
+ }
1010
+ },
1011
+ {
1012
+ id: "regional.anthropic.claude-3-haiku-20240307-v1:0",
1013
+ match: {
1014
+ or: [
1015
+ {
1016
+ starts_with: "us.anthropic.claude-3-haiku-20240307-v1"
1017
+ },
1018
+ {
1019
+ starts_with: "au.anthropic.claude-3-haiku-20240307-v1"
1020
+ },
1021
+ {
1022
+ starts_with: "apac.anthropic.claude-3-haiku-20240307-v1"
1023
+ },
1024
+ {
1025
+ starts_with: "eu.anthropic.claude-3-haiku-20240307-v1"
1026
+ },
1027
+ {
1028
+ starts_with: "us-gov.anthropic.claude-3-haiku-20240307-v1"
1029
+ },
1030
+ {
1031
+ starts_with: "jp.anthropic.claude-3-haiku-20240307-v1"
1032
+ }
1033
+ ]
1034
+ },
1035
+ prices: {
1036
+ input_mtok: 0.25,
1037
+ output_mtok: 1.25
1038
+ }
1039
+ },
1040
+ {
1041
+ id: "regional.anthropic.claude-3-opus-20240229-v1:0",
1042
+ match: {
1043
+ or: [
1044
+ {
1045
+ starts_with: "us.anthropic.claude-3-opus-20240229-v1"
1046
+ },
1047
+ {
1048
+ starts_with: "au.anthropic.claude-3-opus-20240229-v1"
1049
+ },
1050
+ {
1051
+ starts_with: "apac.anthropic.claude-3-opus-20240229-v1"
1052
+ },
1053
+ {
1054
+ starts_with: "eu.anthropic.claude-3-opus-20240229-v1"
1055
+ },
1056
+ {
1057
+ starts_with: "us-gov.anthropic.claude-3-opus-20240229-v1"
1058
+ },
1059
+ {
1060
+ starts_with: "jp.anthropic.claude-3-opus-20240229-v1"
1061
+ }
1062
+ ]
1063
+ },
1064
+ prices: {
1065
+ input_mtok: 15,
1066
+ output_mtok: 75
1067
+ }
1068
+ },
1069
+ {
1070
+ id: "regional.anthropic.claude-3-sonnet-20240229-v1:0",
1071
+ match: {
1072
+ or: [
1073
+ {
1074
+ starts_with: "us.anthropic.claude-3-sonnet-20240229-v1"
1075
+ },
1076
+ {
1077
+ starts_with: "au.anthropic.claude-3-sonnet-20240229-v1"
1078
+ },
1079
+ {
1080
+ starts_with: "apac.anthropic.claude-3-sonnet-20240229-v1"
1081
+ },
1082
+ {
1083
+ starts_with: "eu.anthropic.claude-3-sonnet-20240229-v1"
1084
+ },
1085
+ {
1086
+ starts_with: "us-gov.anthropic.claude-3-sonnet-20240229-v1"
1087
+ },
1088
+ {
1089
+ starts_with: "jp.anthropic.claude-3-sonnet-20240229-v1"
1090
+ }
1091
+ ]
1092
+ },
1093
+ prices: {
1094
+ input_mtok: 3,
1095
+ cache_write_mtok: 3.75,
1096
+ cache_read_mtok: 0.3,
1097
+ output_mtok: 15
1098
+ }
1099
+ },
1100
+ {
1101
+ id: "regional.anthropic.claude-haiku-4-5-20251001-v1:0",
1102
+ match: {
1103
+ or: [
1104
+ {
1105
+ starts_with: "us.anthropic.claude-haiku-4-5-20251001-v1"
1106
+ },
1107
+ {
1108
+ starts_with: "au.anthropic.claude-haiku-4-5-20251001-v1"
1109
+ },
1110
+ {
1111
+ starts_with: "apac.anthropic.claude-haiku-4-5-20251001-v1"
1112
+ },
1113
+ {
1114
+ starts_with: "eu.anthropic.claude-haiku-4-5-20251001-v1"
1115
+ },
1116
+ {
1117
+ starts_with: "us-gov.anthropic.claude-haiku-4-5-20251001-v1"
1118
+ },
1119
+ {
1120
+ starts_with: "jp.anthropic.claude-haiku-4-5-20251001-v1"
1121
+ }
1122
+ ]
1123
+ },
1124
+ prices: {
1125
+ input_mtok: 1.1,
1126
+ cache_write_mtok: 1.375,
1127
+ cache_read_mtok: 0.11,
1128
+ output_mtok: 5.5
1129
+ }
1130
+ },
1131
+ {
1132
+ id: "regional.anthropic.claude-opus-4-1-20250805-v1:0",
1133
+ match: {
1134
+ or: [
1135
+ {
1136
+ starts_with: "us.anthropic.claude-opus-4-1-20250805-v1"
1137
+ },
1138
+ {
1139
+ starts_with: "au.anthropic.claude-opus-4-1-20250805-v1"
1140
+ },
1141
+ {
1142
+ starts_with: "apac.anthropic.claude-opus-4-1-20250805-v1"
1143
+ },
1144
+ {
1145
+ starts_with: "eu.anthropic.claude-opus-4-1-20250805-v1"
1146
+ },
1147
+ {
1148
+ starts_with: "us-gov.anthropic.claude-opus-4-1-20250805-v1"
1149
+ },
1150
+ {
1151
+ starts_with: "jp.anthropic.claude-opus-4-1-20250805-v1"
1152
+ }
1153
+ ]
1154
+ },
1155
+ prices: {
1156
+ input_mtok: 15,
1157
+ cache_write_mtok: 18.75,
1158
+ cache_read_mtok: 1.5,
1159
+ output_mtok: 75
1160
+ }
1161
+ },
1162
+ {
1163
+ id: "regional.anthropic.claude-opus-4-20250514-v1:0",
1164
+ match: {
1165
+ or: [
1166
+ {
1167
+ starts_with: "us.anthropic.claude-opus-4-20250514-v1"
1168
+ },
1169
+ {
1170
+ starts_with: "au.anthropic.claude-opus-4-20250514-v1"
1171
+ },
1172
+ {
1173
+ starts_with: "apac.anthropic.claude-opus-4-20250514-v1"
1174
+ },
1175
+ {
1176
+ starts_with: "eu.anthropic.claude-opus-4-20250514-v1"
1177
+ },
1178
+ {
1179
+ starts_with: "us-gov.anthropic.claude-opus-4-20250514-v1"
1180
+ },
1181
+ {
1182
+ starts_with: "jp.anthropic.claude-opus-4-20250514-v1"
1183
+ }
1184
+ ]
1185
+ },
1186
+ prices: {
1187
+ input_mtok: 15,
1188
+ cache_write_mtok: 18.75,
1189
+ cache_read_mtok: 1.5,
1190
+ output_mtok: 75
1191
+ }
1192
+ },
1193
+ {
1194
+ id: "regional.anthropic.claude-sonnet-4-20250514-v1:0",
1195
+ match: {
1196
+ or: [
1197
+ {
1198
+ starts_with: "us.anthropic.claude-sonnet-4-20250514-v1"
1199
+ },
1200
+ {
1201
+ starts_with: "au.anthropic.claude-sonnet-4-20250514-v1"
1202
+ },
1203
+ {
1204
+ starts_with: "apac.anthropic.claude-sonnet-4-20250514-v1"
1205
+ },
1206
+ {
1207
+ starts_with: "eu.anthropic.claude-sonnet-4-20250514-v1"
1208
+ },
1209
+ {
1210
+ starts_with: "us-gov.anthropic.claude-sonnet-4-20250514-v1"
1211
+ },
1212
+ {
1213
+ starts_with: "jp.anthropic.claude-sonnet-4-20250514-v1"
1214
+ }
1215
+ ]
1216
+ },
1217
+ prices: {
1218
+ input_mtok: 3,
1219
+ cache_write_mtok: 3.75,
1220
+ cache_read_mtok: 0.3,
1221
+ output_mtok: 15
1222
+ }
1223
+ },
1224
+ {
1225
+ id: "regional.anthropic.claude-sonnet-4-5-20250929-v1:0",
1226
+ match: {
1227
+ or: [
1228
+ {
1229
+ starts_with: "us.anthropic.claude-sonnet-4-5-20250929-v1"
1230
+ },
1231
+ {
1232
+ starts_with: "au.anthropic.claude-sonnet-4-5-20250929-v1"
1233
+ },
1234
+ {
1235
+ starts_with: "apac.anthropic.claude-sonnet-4-5-20250929-v1"
1236
+ },
1237
+ {
1238
+ starts_with: "eu.anthropic.claude-sonnet-4-5-20250929-v1"
1239
+ },
1240
+ {
1241
+ starts_with: "us-gov.anthropic.claude-sonnet-4-5-20250929-v1"
1242
+ },
1243
+ {
1244
+ starts_with: "jp.anthropic.claude-sonnet-4-5-20250929-v1"
1245
+ }
1246
+ ]
1247
+ },
1248
+ prices: {
1249
+ input_mtok: 3.3,
1250
+ cache_write_mtok: 4.125,
1251
+ cache_read_mtok: 0.33,
1252
+ output_mtok: 16.5
1253
+ }
838
1254
  }
839
1255
  ]
840
1256
  },
@@ -844,6 +1260,111 @@ const x = [
844
1260
  pricing_urls: ["https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/#pricing"],
845
1261
  api_pattern: "(https?://)?([^.]*\\.)?(?:openai\\.azure\\.com|azure-api\\.net|cognitiveservices\\.azure\\.com)",
846
1262
  price_comments: 'These are prices for "*-Global" models, prices for "Regional" models are often slightly higher. Retired models are listed at https://learn.microsoft.com/th-th/azure/ai-foundry/openai/concepts/legacy-models',
1263
+ extractors: [
1264
+ {
1265
+ api_flavor: "chat",
1266
+ root: "usage",
1267
+ model_path: "model",
1268
+ mappings: [
1269
+ {
1270
+ path: "prompt_tokens",
1271
+ dest: "input_tokens",
1272
+ required: !0
1273
+ },
1274
+ {
1275
+ path: ["prompt_tokens_details", "cached_tokens"],
1276
+ dest: "cache_read_tokens",
1277
+ required: !1
1278
+ },
1279
+ {
1280
+ path: ["prompt_tokens_details", "audio_tokens"],
1281
+ dest: "input_audio_tokens",
1282
+ required: !1
1283
+ },
1284
+ {
1285
+ path: ["completion_tokens_details", "audio_tokens"],
1286
+ dest: "output_audio_tokens",
1287
+ required: !1
1288
+ },
1289
+ {
1290
+ path: "completion_tokens",
1291
+ dest: "output_tokens",
1292
+ required: !0
1293
+ }
1294
+ ]
1295
+ },
1296
+ {
1297
+ api_flavor: "responses",
1298
+ root: "usage",
1299
+ model_path: "model",
1300
+ mappings: [
1301
+ {
1302
+ path: "input_tokens",
1303
+ dest: "input_tokens",
1304
+ required: !0
1305
+ },
1306
+ {
1307
+ path: ["input_tokens_details", "cached_tokens"],
1308
+ dest: "cache_read_tokens",
1309
+ required: !1
1310
+ },
1311
+ {
1312
+ path: "output_tokens",
1313
+ dest: "output_tokens",
1314
+ required: !0
1315
+ }
1316
+ ]
1317
+ },
1318
+ {
1319
+ api_flavor: "embeddings",
1320
+ root: "usage",
1321
+ model_path: "model",
1322
+ mappings: [
1323
+ {
1324
+ path: "prompt_tokens",
1325
+ dest: "input_tokens",
1326
+ required: !0
1327
+ }
1328
+ ]
1329
+ },
1330
+ {
1331
+ api_flavor: "anthropic",
1332
+ root: "usage",
1333
+ model_path: "model",
1334
+ mappings: [
1335
+ {
1336
+ path: "input_tokens",
1337
+ dest: "input_tokens",
1338
+ required: !0
1339
+ },
1340
+ {
1341
+ path: "cache_creation_input_tokens",
1342
+ dest: "input_tokens",
1343
+ required: !1
1344
+ },
1345
+ {
1346
+ path: "cache_read_input_tokens",
1347
+ dest: "input_tokens",
1348
+ required: !1
1349
+ },
1350
+ {
1351
+ path: "cache_creation_input_tokens",
1352
+ dest: "cache_write_tokens",
1353
+ required: !1
1354
+ },
1355
+ {
1356
+ path: "cache_read_input_tokens",
1357
+ dest: "cache_read_tokens",
1358
+ required: !1
1359
+ },
1360
+ {
1361
+ path: "output_tokens",
1362
+ dest: "output_tokens",
1363
+ required: !0
1364
+ }
1365
+ ]
1366
+ }
1367
+ ],
847
1368
  models: [
848
1369
  {
849
1370
  id: "ada",
@@ -12238,34 +12759,34 @@ Compared to other leading proprietary and open-weights models Command A delivers
12238
12759
  function M(t, e) {
12239
12760
  if (e <= 0) return 0;
12240
12761
  let a = 0;
12241
- const i = [...t.tiers].sort((r, s) => r.start - s.start), o = i[0]?.start ?? e, m = Math.min(e, o);
12242
- a += m * t.base / 1e6;
12243
- for (let r = 0; r < i.length; r++) {
12244
- const s = i[r], n = i[r + 1]?.start ?? 1 / 0, u = Math.max(0, Math.min(e, n) - s.start);
12762
+ const i = [...t.tiers].sort((m, s) => m.start - s.start), o = i[0]?.start ?? e, r = Math.min(e, o);
12763
+ a += r * t.base / 1e6;
12764
+ for (let m = 0; m < i.length; m++) {
12765
+ const s = i[m], n = i[m + 1]?.start ?? 1 / 0, u = Math.max(0, Math.min(e, n) - s.start);
12245
12766
  u > 0 && (a += u * s.price / 1e6);
12246
12767
  }
12247
12768
  return a;
12248
12769
  }
12249
- function l(t, e, a) {
12770
+ function c(t, e, a) {
12250
12771
  return t === void 0 || e === void 0 ? 0 : typeof t == "number" ? t * e / 1e6 : M(t, e);
12251
12772
  }
12252
12773
  function I(t, e) {
12253
12774
  let a = 0, i = 0;
12254
- const o = t.cache_read_tokens ?? 0, m = t.cache_write_tokens ?? 0, r = t.cache_audio_read_tokens ?? 0, s = t.output_audio_tokens ?? 0;
12775
+ const o = t.cache_read_tokens ?? 0, r = t.cache_write_tokens ?? 0, m = t.cache_audio_read_tokens ?? 0, s = t.output_audio_tokens ?? 0;
12255
12776
  let n = t.input_audio_tokens ?? 0;
12256
- if (n -= r, n < 0)
12777
+ if (n -= m, n < 0)
12257
12778
  throw new Error("cache_audio_read_tokens cannot be greater than input_audio_tokens");
12258
12779
  let u = t.input_tokens ?? 0;
12259
- if (u -= o, u -= m, u -= n, u < 0)
12780
+ if (u -= o, u -= r, u -= n, u < 0)
12260
12781
  throw new Error("Uncached text input tokens cannot be negative");
12261
12782
  let p = o;
12262
- if (p -= r, p < 0)
12783
+ if (p -= m, p < 0)
12263
12784
  throw new Error("cache_audio_read_tokens cannot be greater than cache_read_tokens");
12264
- a += l(e.input_mtok, u), a += l(e.cache_read_mtok, p), a += l(e.cache_write_mtok, m), a += l(e.input_audio_mtok, n), a += l(e.cache_audio_read_mtok, r);
12265
- let k = t.output_tokens ?? 0;
12266
- if (k -= s, k < 0)
12785
+ a += c(e.input_mtok, u), a += c(e.cache_read_mtok, p), a += c(e.cache_write_mtok, r), a += c(e.input_audio_mtok, n), a += c(e.cache_audio_read_mtok, m);
12786
+ let _ = t.output_tokens ?? 0;
12787
+ if (_ -= s, _ < 0)
12267
12788
  throw new Error("output_audio_tokens cannot be greater than output_tokens");
12268
- i += l(e.output_mtok, k), i += l(e.output_audio_mtok, t.output_audio_tokens);
12789
+ i += c(e.output_mtok, _), i += c(e.output_audio_mtok, t.output_audio_tokens);
12269
12790
  let w = a + i;
12270
12791
  return e.requests_kcount !== void 0 && (w += e.requests_kcount / 1e3), {
12271
12792
  input_price: a,
@@ -12284,11 +12805,11 @@ function L(t, e) {
12284
12805
  if (e >= new Date(o.start_date))
12285
12806
  return i.prices;
12286
12807
  } else {
12287
- const m = e.toISOString().slice(11, 19), r = o.start_time, s = o.end_time;
12288
- if (s < r) {
12289
- if (m >= r || m < s)
12808
+ const r = e.toISOString().slice(11, 19), m = o.start_time, s = o.end_time;
12809
+ if (s < m) {
12810
+ if (r >= m || r < s)
12290
12811
  return i.prices;
12291
- } else if (m >= r && m < s)
12812
+ } else if (r >= m && r < s)
12292
12813
  return i.prices;
12293
12814
  }
12294
12815
  }
@@ -12336,12 +12857,12 @@ function O(t, e, a) {
12336
12857
  f?.();
12337
12858
  const i = e.toLowerCase().trim(), o = a?.provider ?? B(g, { modelId: i, providerApiUrl: a?.providerApiUrl, providerId: a?.providerId });
12338
12859
  if (!o) return null;
12339
- const m = T(o.models, i);
12340
- if (!m) return null;
12341
- const r = a?.timestamp ?? /* @__PURE__ */ new Date(), s = L(m, r), n = I(t, s);
12860
+ const r = T(o.models, i);
12861
+ if (!r) return null;
12862
+ const m = a?.timestamp ?? /* @__PURE__ */ new Date(), s = L(r, m), n = I(t, s);
12342
12863
  return {
12343
12864
  auto_update_timestamp: void 0,
12344
- model: m,
12865
+ model: r,
12345
12866
  model_price: s,
12346
12867
  provider: o,
12347
12868
  ...n
@@ -12358,11 +12879,11 @@ function E(t, e, a) {
12358
12879
  const n = t.extractors.map((u) => u.api_flavor).join(", ");
12359
12880
  throw new Error(`Unknown apiFlavor '${a}', allowed values: ${n}`);
12360
12881
  }
12361
- if (!_.guard(e))
12362
- throw new Error(`Expected response data to be a mapping object, got ${c(e)}`);
12363
- const o = q(i.model_path, e, R, !1, []), m = y(i.root), r = q(m, e, _, !0, []), s = {};
12882
+ if (!k.guard(e))
12883
+ throw new Error(`Expected response data to be a mapping object, got ${l(e)}`);
12884
+ const o = q(i.model_path, e, R, !1, []), r = y(i.root), m = q(r, e, k, !0, []), s = {};
12364
12885
  for (const n of i.mappings) {
12365
- const u = q(n.path, r, z, n.required, m);
12886
+ const u = q(n.path, m, z, n.required, r);
12366
12887
  if (u !== null) {
12367
12888
  const p = s[n.dest] ?? 0;
12368
12889
  s[n.dest] = p + u;
@@ -12373,55 +12894,55 @@ function E(t, e, a) {
12373
12894
  return { model: o, usage: s };
12374
12895
  }
12375
12896
  function q(t, e, a, i, o) {
12376
- const [m, ...r] = y(t).reverse();
12377
- if (typeof m != "string")
12378
- throw new Error(`Expected last step of path to be a string, got ${c(m)}`);
12379
- r.reverse();
12897
+ const [r, ...m] = y(t).reverse();
12898
+ if (typeof r != "string")
12899
+ throw new Error(`Expected last step of path to be a string, got ${l(r)}`);
12900
+ m.reverse();
12380
12901
  let s = e;
12381
12902
  const n = [];
12382
- for (const p of r) {
12903
+ for (const p of m) {
12383
12904
  if (n.push(p), typeof p == "object")
12384
12905
  if (Array.isArray(s))
12385
12906
  s = A(p, s);
12386
12907
  else {
12387
12908
  if (i)
12388
- throw new Error(`Expected \`${d(o, n)}\` value to be a mapping, got ${c(s)}`);
12909
+ throw new Error(`Expected \`${d(o, n)}\` value to be a mapping, got ${l(s)}`);
12389
12910
  return null;
12390
12911
  }
12391
- else if (_.guard(s))
12912
+ else if (k.guard(s))
12392
12913
  s = s[p];
12393
12914
  else {
12394
12915
  if (i)
12395
- throw new Error(`Expected \`${d(o, n)}\` value to be a mapping, got ${c(s)}`);
12916
+ throw new Error(`Expected \`${d(o, n)}\` value to be a mapping, got ${l(s)}`);
12396
12917
  return null;
12397
12918
  }
12398
12919
  if (typeof s > "u")
12399
12920
  if (i) {
12400
- const k = typeof p == "object" ? "Unable to find item" : "Missing value";
12401
- throw new Error(`${k} at \`${d(o, n)}\``);
12921
+ const _ = typeof p == "object" ? "Unable to find item" : "Missing value";
12922
+ throw new Error(`${_} at \`${d(o, n)}\``);
12402
12923
  } else
12403
12924
  return null;
12404
12925
  }
12405
- if (!_.guard(s)) {
12926
+ if (!k.guard(s)) {
12406
12927
  if (i)
12407
- throw new Error(`Expected \`${d(o, n)}\` value to be a mapping, got ${c(s)}`);
12928
+ throw new Error(`Expected \`${d(o, n)}\` value to be a mapping, got ${l(s)}`);
12408
12929
  return null;
12409
12930
  }
12410
- const u = s[m];
12931
+ const u = s[r];
12411
12932
  if (typeof u > "u") {
12412
12933
  if (i)
12413
- throw n.push(m), new Error(`Missing value at \`${d(o, n)}\``);
12934
+ throw n.push(r), new Error(`Missing value at \`${d(o, n)}\``);
12414
12935
  return null;
12415
12936
  }
12416
12937
  if (a.guard(u))
12417
12938
  return u;
12418
12939
  if (i)
12419
- throw n.push(m), new Error(`Expected \`${d(o, n)}\` value to be a ${a.name}, got ${c(u)}`);
12940
+ throw n.push(r), new Error(`Expected \`${d(o, n)}\` value to be a ${a.name}, got ${l(u)}`);
12420
12941
  return null;
12421
12942
  }
12422
12943
  function A(t, e) {
12423
12944
  for (const a of e)
12424
- if (_.guard(a)) {
12945
+ if (k.guard(a)) {
12425
12946
  const i = a[t.field];
12426
12947
  if (typeof i == "string" && h(t.match, i))
12427
12948
  return a;
@@ -12430,11 +12951,11 @@ function A(t, e) {
12430
12951
  function y(t) {
12431
12952
  return Array.isArray(t) ? [...t] : [t];
12432
12953
  }
12433
- function c(t) {
12954
+ function l(t) {
12434
12955
  return t === null ? "null" : Array.isArray(t) ? "array" : typeof t == "object" ? "mapping" : typeof t;
12435
12956
  }
12436
- const _ = {
12437
- guard: (t) => c(t) === "mapping",
12957
+ const k = {
12958
+ guard: (t) => l(t) === "mapping",
12438
12959
  name: "mapping"
12439
12960
  }, R = {
12440
12961
  guard: (t) => typeof t == "string",