@opengeni/config 0.10.1 → 0.10.6

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.d.ts CHANGED
@@ -190,6 +190,7 @@ declare const SettingsSchema: z.ZodObject<{
190
190
  openaiReasoningEffort: z.ZodDefault<z.ZodEnum<{
191
191
  high: "high";
192
192
  low: "low";
193
+ max: "max";
193
194
  medium: "medium";
194
195
  minimal: "minimal";
195
196
  none: "none";
@@ -528,6 +529,7 @@ export declare const ModelCapabilitiesV1Schema: z.ZodObject<{
528
529
  efforts: z.ZodArray<z.ZodEnum<{
529
530
  high: "high";
530
531
  low: "low";
532
+ max: "max";
531
533
  medium: "medium";
532
534
  minimal: "minimal";
533
535
  none: "none";
@@ -536,6 +538,7 @@ export declare const ModelCapabilitiesV1Schema: z.ZodObject<{
536
538
  defaultEffort: z.ZodNullable<z.ZodEnum<{
537
539
  high: "high";
538
540
  low: "low";
541
+ max: "max";
539
542
  medium: "medium";
540
543
  minimal: "minimal";
541
544
  none: "none";
@@ -590,6 +593,7 @@ export declare const ModelCapabilitiesV1Schema: z.ZodObject<{
590
593
  image: "image";
591
594
  text: "text";
592
595
  }>>;
596
+ inputFileMediaTypes: z.ZodDefault<z.ZodArray<z.ZodString>>;
593
597
  outputModalities: z.ZodArray<z.ZodEnum<{
594
598
  audio: "audio";
595
599
  image: "image";
@@ -743,6 +747,7 @@ declare const RegistryProviderSchema: z.ZodObject<{
743
747
  efforts: z.ZodArray<z.ZodEnum<{
744
748
  high: "high";
745
749
  low: "low";
750
+ max: "max";
746
751
  medium: "medium";
747
752
  minimal: "minimal";
748
753
  none: "none";
@@ -751,6 +756,7 @@ declare const RegistryProviderSchema: z.ZodObject<{
751
756
  defaultEffort: z.ZodNullable<z.ZodEnum<{
752
757
  high: "high";
753
758
  low: "low";
759
+ max: "max";
754
760
  medium: "medium";
755
761
  minimal: "minimal";
756
762
  none: "none";
@@ -805,6 +811,7 @@ declare const RegistryProviderSchema: z.ZodObject<{
805
811
  image: "image";
806
812
  text: "text";
807
813
  }>>;
814
+ inputFileMediaTypes: z.ZodDefault<z.ZodArray<z.ZodString>>;
808
815
  outputModalities: z.ZodArray<z.ZodEnum<{
809
816
  audio: "audio";
810
817
  image: "image";
@@ -940,7 +947,7 @@ export interface ConfiguredModel {
940
947
  capabilities: ModelCapabilitiesV1;
941
948
  requestPolicy?: {
942
949
  gateway: {
943
- only: [string];
950
+ only: [string, ...string[]];
944
951
  caching: "auto" | "none";
945
952
  };
946
953
  };
@@ -954,26 +961,59 @@ export interface ConfiguredModel {
954
961
  hostedWebSearch: boolean;
955
962
  }
956
963
  export declare const VERCEL_AI_GATEWAY_BASE_URL: "https://ai-gateway.vercel.sh/v1";
964
+ export declare const VERCEL_AI_GATEWAY_AI_SDK_BASE_URL: "https://ai-gateway.vercel.sh/v4/ai";
957
965
  export declare const OPENGENI_GATEWAY_PROVIDER_ID: "opengeni-gateway";
958
966
  export declare const WORKSPACE_GATEWAY_PROVIDER_ID: "workspace-gateway";
959
967
  export declare const WORKSPACE_GATEWAY_MODEL_ID_PREFIX: "workspace-gateway/";
960
968
  export declare const VERCEL_AI_GATEWAY_CONNECTION_DOMAIN: "ai-gateway.vercel.sh";
961
969
  export declare const VERCEL_AI_GATEWAY_CONNECTION_ROLE: "vercel_ai_gateway";
970
+ export declare const CODEX_REALTIME_MODEL_ID: "gpt-live-1-boulder-alpha";
971
+ export declare const OPENGENI_REALTIME_MODEL_ID_PREFIX: "opengeni-gateway/";
972
+ export declare const WORKSPACE_REALTIME_MODEL_ID_PREFIX: "workspace-gateway/";
973
+ /** Curated voice models exposed through AI Gateway's normalized realtime API. */
974
+ export declare const AI_GATEWAY_REALTIME_MODELS: {
975
+ readonly openaiRealtime21: {
976
+ readonly upstreamModelId: "openai/gpt-realtime-2.1";
977
+ readonly managedModelId: "opengeni-gateway/openai/gpt-realtime-2.1";
978
+ readonly workspaceModelId: "workspace-gateway/openai/gpt-realtime-2.1";
979
+ readonly label: "GPT Realtime 2.1";
980
+ readonly description: "Best overall voice intelligence";
981
+ };
982
+ readonly openaiRealtimeMini: {
983
+ readonly upstreamModelId: "openai/gpt-realtime-mini";
984
+ readonly managedModelId: "opengeni-gateway/openai/gpt-realtime-mini";
985
+ readonly workspaceModelId: "workspace-gateway/openai/gpt-realtime-mini";
986
+ readonly label: "GPT Realtime Mini";
987
+ readonly description: "Faster, lighter live voice";
988
+ };
989
+ readonly grokVoiceThinkFast20: {
990
+ readonly upstreamModelId: "xai/grok-voice-think-fast-2.0";
991
+ readonly managedModelId: "opengeni-gateway/xai/grok-voice-think-fast-2.0";
992
+ readonly workspaceModelId: "workspace-gateway/xai/grok-voice-think-fast-2.0";
993
+ readonly label: "Grok Voice Think Fast 2.0";
994
+ readonly description: "Fast, natural xAI voice";
995
+ };
996
+ };
997
+ export type AiGatewayRealtimeModel = (typeof AI_GATEWAY_REALTIME_MODELS)[keyof typeof AI_GATEWAY_REALTIME_MODELS];
998
+ export declare function resolveAiGatewayRealtimeModel(modelId: string): {
999
+ source: "managed" | "workspace";
1000
+ upstreamModelId: string;
1001
+ } | null;
962
1002
  export declare const OPENGENI_GATEWAY_MODELS: {
963
1003
  readonly deepseek: {
964
1004
  readonly productId: "deepseek-v4-flash-0731";
965
1005
  readonly workspaceProductId: "workspace-gateway/deepseek-v4-flash-0731";
966
1006
  readonly upstreamModelId: "deepseek/deepseek-v4-flash-0731";
967
1007
  readonly label: "DeepSeek V4 Flash 0731";
968
- readonly provider: "deepinfra";
1008
+ readonly providers: readonly ["baseten", "novita", "deepinfra"];
969
1009
  readonly implicitCaching: true;
970
1010
  };
971
1011
  readonly kimi: {
972
- readonly productId: "kimi-k3-fast";
973
- readonly workspaceProductId: "workspace-gateway/kimi-k3-fast";
974
- readonly upstreamModelId: "moonshotai/kimi-k3-fast";
975
- readonly label: "Kimi K3 Fast";
976
- readonly provider: "wafer";
1012
+ readonly productId: "kimi-k3";
1013
+ readonly workspaceProductId: "workspace-gateway/kimi-k3";
1014
+ readonly upstreamModelId: "moonshotai/kimi-k3";
1015
+ readonly label: "Kimi K3";
1016
+ readonly providers: readonly ["baseten", "fireworks"];
977
1017
  readonly implicitCaching: true;
978
1018
  };
979
1019
  };
@@ -1184,6 +1224,14 @@ export declare function configuredEntitlements(settings: Settings): Entitlements
1184
1224
  export declare function calculateModelUsageCostMicros(settings: Settings, model: string, usage: ModelUsageInput, options?: {
1185
1225
  latencyMode?: LatencyMode;
1186
1226
  }): number;
1227
+ /**
1228
+ * Convert AI Gateway's exact USD inference cost to OpenGeni credit micros and
1229
+ * apply the configured model margin. Decimal arithmetic is integer-only so a
1230
+ * sub-micro provider charge cannot be lost to floating-point rounding.
1231
+ */
1232
+ export declare function calculateGatewayReportedCostMicros(settings: Settings, model: string, inferenceCostUsd: string, options?: {
1233
+ inputTokens?: number;
1234
+ }): number;
1187
1235
  export declare function configuredAllowedReasoningEfforts(settings: Settings): Array<z.infer<typeof ReasoningEffort>>;
1188
1236
  /**
1189
1237
  * Decodes OPENGENI_ENVIRONMENTS_ENCRYPTION_KEY (base64, exactly 32 bytes) for
package/dist/index.js CHANGED
@@ -78,7 +78,7 @@ var DEFAULT_AGENT_INSTRUCTIONS = [
78
78
  "Follow the user's task and any enabled pack or skill instructions for the current role.",
79
79
  "Work inside the sandbox workspace and use filesystem and shell tools when useful.",
80
80
  "Repository resources are mounted under repos/<host>/<owner>/<repo> unless the session specifies another collision-free mount path.",
81
- "File resources are mounted under files/<file-id>/ unless the session specifies another mount path.",
81
+ "File resources are mounted under .opengeni/files/<file-id>/ unless the session specifies another mount path.",
82
82
  "Attached files are mounted read-only; copy them before modifying.",
83
83
  "Bundled skills are under .agents/ and can include infrastructure, marketing, or other role-specific guidance.",
84
84
  "Use Checkov, Terraform, Azure CLI, git provider CLIs, and repository tools when relevant; gh, glab, and az repos are pre-authenticated when the host brokers matching git credentials.",
@@ -367,7 +367,7 @@ var SettingsSchema = z.object({
367
367
  // match the UI danger flip (UsageBar danger at pct >= 90). OPENGENI_CODEX_ROTATION_NEAR_EXHAUSTION_PCT.
368
368
  codexRotationNearExhaustionPct: z.coerce.number().int().min(1).max(100).default(90),
369
369
  openaiReasoningEffort: ReasoningEffort.default("low"),
370
- openaiAllowedReasoningEfforts: z.string().default("low,medium,high,xhigh"),
370
+ openaiAllowedReasoningEfforts: z.string().default("low,medium,high,xhigh,max"),
371
371
  openaiResponsesTransport: z.enum(["http", "websocket"]).default("http"),
372
372
  // Provider-assigned item ids (rs_/msg_/fc_…) in Responses API input are
373
373
  // resolved against the provider's server-side response store. That store is
@@ -963,6 +963,8 @@ var ModelCapabilitiesV1Schema = z.object({
963
963
  codeExecution: CapabilityStateV1Schema
964
964
  }),
965
965
  inputModalities: z.array(ModelModalityV1).min(1),
966
+ /** Exact MIME types accepted as typed `input_file`; `text/*` is allowed. */
967
+ inputFileMediaTypes: z.array(z.string()).default([]),
966
968
  outputModalities: z.array(ModelModalityV1).min(1),
967
969
  transports: z.object({
968
970
  sse: CapabilityStateV1Schema,
@@ -1106,26 +1108,64 @@ var IntegrationOAuthClientConfigSchema = z.object({
1106
1108
  tokenEndpointAuthMethod: z.enum(["none", "client_secret_post", "client_secret_basic"]).default("none")
1107
1109
  });
1108
1110
  var VERCEL_AI_GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh/v1";
1111
+ var VERCEL_AI_GATEWAY_AI_SDK_BASE_URL = "https://ai-gateway.vercel.sh/v4/ai";
1109
1112
  var OPENGENI_GATEWAY_PROVIDER_ID = "opengeni-gateway";
1110
1113
  var WORKSPACE_GATEWAY_PROVIDER_ID = "workspace-gateway";
1111
1114
  var WORKSPACE_GATEWAY_MODEL_ID_PREFIX = "workspace-gateway/";
1112
1115
  var VERCEL_AI_GATEWAY_CONNECTION_DOMAIN = "ai-gateway.vercel.sh";
1113
1116
  var VERCEL_AI_GATEWAY_CONNECTION_ROLE = "vercel_ai_gateway";
1117
+ var CODEX_REALTIME_MODEL_ID = "gpt-live-1-boulder-alpha";
1118
+ var OPENGENI_REALTIME_MODEL_ID_PREFIX = "opengeni-gateway/";
1119
+ var WORKSPACE_REALTIME_MODEL_ID_PREFIX = "workspace-gateway/";
1120
+ var AI_GATEWAY_REALTIME_MODELS = {
1121
+ openaiRealtime21: {
1122
+ upstreamModelId: "openai/gpt-realtime-2.1",
1123
+ managedModelId: `${OPENGENI_REALTIME_MODEL_ID_PREFIX}openai/gpt-realtime-2.1`,
1124
+ workspaceModelId: `${WORKSPACE_REALTIME_MODEL_ID_PREFIX}openai/gpt-realtime-2.1`,
1125
+ label: "GPT Realtime 2.1",
1126
+ description: "Best overall voice intelligence"
1127
+ },
1128
+ openaiRealtimeMini: {
1129
+ upstreamModelId: "openai/gpt-realtime-mini",
1130
+ managedModelId: `${OPENGENI_REALTIME_MODEL_ID_PREFIX}openai/gpt-realtime-mini`,
1131
+ workspaceModelId: `${WORKSPACE_REALTIME_MODEL_ID_PREFIX}openai/gpt-realtime-mini`,
1132
+ label: "GPT Realtime Mini",
1133
+ description: "Faster, lighter live voice"
1134
+ },
1135
+ grokVoiceThinkFast20: {
1136
+ upstreamModelId: "xai/grok-voice-think-fast-2.0",
1137
+ managedModelId: `${OPENGENI_REALTIME_MODEL_ID_PREFIX}xai/grok-voice-think-fast-2.0`,
1138
+ workspaceModelId: `${WORKSPACE_REALTIME_MODEL_ID_PREFIX}xai/grok-voice-think-fast-2.0`,
1139
+ label: "Grok Voice Think Fast 2.0",
1140
+ description: "Fast, natural xAI voice"
1141
+ }
1142
+ };
1143
+ function resolveAiGatewayRealtimeModel(modelId) {
1144
+ for (const model of Object.values(AI_GATEWAY_REALTIME_MODELS)) {
1145
+ if (model.managedModelId === modelId) {
1146
+ return { source: "managed", upstreamModelId: model.upstreamModelId };
1147
+ }
1148
+ if (model.workspaceModelId === modelId) {
1149
+ return { source: "workspace", upstreamModelId: model.upstreamModelId };
1150
+ }
1151
+ }
1152
+ return null;
1153
+ }
1114
1154
  var OPENGENI_GATEWAY_MODELS = {
1115
1155
  deepseek: {
1116
1156
  productId: "deepseek-v4-flash-0731",
1117
1157
  workspaceProductId: `${WORKSPACE_GATEWAY_MODEL_ID_PREFIX}deepseek-v4-flash-0731`,
1118
1158
  upstreamModelId: "deepseek/deepseek-v4-flash-0731",
1119
1159
  label: "DeepSeek V4 Flash 0731",
1120
- provider: "deepinfra",
1160
+ providers: ["baseten", "novita", "deepinfra"],
1121
1161
  implicitCaching: true
1122
1162
  },
1123
1163
  kimi: {
1124
- productId: "kimi-k3-fast",
1125
- workspaceProductId: `${WORKSPACE_GATEWAY_MODEL_ID_PREFIX}kimi-k3-fast`,
1126
- upstreamModelId: "moonshotai/kimi-k3-fast",
1127
- label: "Kimi K3 Fast",
1128
- provider: "wafer",
1164
+ productId: "kimi-k3",
1165
+ workspaceProductId: `${WORKSPACE_GATEWAY_MODEL_ID_PREFIX}kimi-k3`,
1166
+ upstreamModelId: "moonshotai/kimi-k3",
1167
+ label: "Kimi K3",
1168
+ providers: ["baseten", "fireworks"],
1129
1169
  implicitCaching: true
1130
1170
  }
1131
1171
  };
@@ -1188,24 +1228,24 @@ var defaultModelPricing = {
1188
1228
  }
1189
1229
  ]
1190
1230
  },
1191
- // Vercel AI Gateway endpoint prices, provider-pinned in the runtime.
1192
- // Snapshot: 2026-08-02. Both pinned routes returned discounted implicit
1193
- // cache reads in live Gateway responses. Wafer/Kimi reported $0.45/M even
1194
- // though the provider-discovery flag currently says otherwise; bill from
1195
- // the response-backed rate, not that inconsistent boolean.
1231
+ // Conservative Vercel AI Gateway fallback prices. Normal managed Gateway
1232
+ // billing uses the exact response Gateway `cost` / `inferenceCost` and applies
1233
+ // the same margin. These token rates are used only if that
1234
+ // metadata is absent. DeepSeek therefore carries the highest approved route
1235
+ // (Novita); both approved Kimi routes have the same list price.
1196
1236
  [OPENGENI_GATEWAY_MODELS.deepseek.productId]: {
1197
1237
  default: {
1198
- inputMicrosPerMillionTokens: 9e4,
1199
- cachedInputMicrosPerMillionTokens: 18e3,
1200
- outputMicrosPerMillionTokens: 18e4,
1238
+ inputMicrosPerMillionTokens: 14e4,
1239
+ cachedInputMicrosPerMillionTokens: 28e3,
1240
+ outputMicrosPerMillionTokens: 28e4,
1201
1241
  marginBps: 2500
1202
1242
  }
1203
1243
  },
1204
1244
  [OPENGENI_GATEWAY_MODELS.kimi.productId]: {
1205
1245
  default: {
1206
- inputMicrosPerMillionTokens: 45e5,
1207
- cachedInputMicrosPerMillionTokens: 45e4,
1208
- outputMicrosPerMillionTokens: 225e5,
1246
+ inputMicrosPerMillionTokens: 3e6,
1247
+ cachedInputMicrosPerMillionTokens: 3e5,
1248
+ outputMicrosPerMillionTokens: 15e6,
1209
1249
  marginBps: 2500
1210
1250
  }
1211
1251
  },
@@ -1762,6 +1802,7 @@ function normalizeCapabilities(capabilities) {
1762
1802
  inputModalities: [...parsed.inputModalities].sort(
1763
1803
  (left, right) => (MODALITY_ORDER.get(left) ?? 0) - (MODALITY_ORDER.get(right) ?? 0)
1764
1804
  ),
1805
+ inputFileMediaTypes: [...new Set(parsed.inputFileMediaTypes)].sort(),
1765
1806
  outputModalities: [...parsed.outputModalities].sort(
1766
1807
  (left, right) => (MODALITY_ORDER.get(left) ?? 0) - (MODALITY_ORDER.get(right) ?? 0)
1767
1808
  ),
@@ -1790,7 +1831,14 @@ function legacyModelCapabilities(settings, input) {
1790
1831
  xSearch: { upstream: "unknown", runnable: false },
1791
1832
  codeExecution: { upstream: "unknown", runnable: false }
1792
1833
  },
1793
- inputModalities: ["text"],
1834
+ inputModalities: input.vision ? ["text", "image"] : ["text"],
1835
+ inputFileMediaTypes: [
1836
+ "application/json",
1837
+ "application/pdf",
1838
+ "application/x-yaml",
1839
+ "application/yaml",
1840
+ "text/*"
1841
+ ],
1794
1842
  outputModalities: ["text"],
1795
1843
  transports: {
1796
1844
  sse: { upstream: "unknown", runnable: true },
@@ -1809,7 +1857,7 @@ function gatewayRequestPolicyForUpstreamModel(upstreamModelId) {
1809
1857
  }
1810
1858
  return {
1811
1859
  gateway: {
1812
- only: [model.provider],
1860
+ only: [...model.providers],
1813
1861
  caching: model.implicitCaching ? "auto" : "none"
1814
1862
  }
1815
1863
  };
@@ -1823,31 +1871,36 @@ function gatewayModelCapabilities(settings, input) {
1823
1871
  ...legacy,
1824
1872
  functionCalling: { upstream: "supported", runnable: true },
1825
1873
  inputModalities: input.vision ? ["text", "image"] : ["text"],
1874
+ inputFileMediaTypes: input.inputFileMediaTypes ?? [],
1826
1875
  transports: {
1827
1876
  ...legacy.transports,
1828
1877
  sse: { upstream: "supported", runnable: true }
1829
1878
  },
1830
1879
  promptCaching: input.implicitCaching ? { upstream: "supported", runnable: true, mode: "implicit" } : { upstream: "unsupported", runnable: false, mode: "none" },
1831
- // "Fast" is part of Kimi's product name, not OpenGeni's separately billed
1832
- // latency mode. Both Gateway products expose only standard here.
1880
+ // Both Gateway products expose one reviewed route policy and no separately
1881
+ // billed latency mode.
1833
1882
  latencyModes: [{ id: "standard", upstream: "supported", runnable: true }]
1834
1883
  });
1835
1884
  }
1836
1885
  function gatewayRegistryProvider(settings, input) {
1837
1886
  const workspace = input.kind === "vercel-gateway-workspace";
1838
- const models = [OPENGENI_GATEWAY_MODELS.deepseek, OPENGENI_GATEWAY_MODELS.kimi].map((model) => ({
1839
- id: workspace ? model.workspaceProductId : model.productId,
1840
- upstreamModelId: model.upstreamModelId,
1841
- label: model.label,
1842
- capabilities: gatewayModelCapabilities(settings, {
1843
- implicitCaching: model.implicitCaching,
1844
- vision: model === OPENGENI_GATEWAY_MODELS.kimi
1845
- }),
1846
- contextWindowTokens: 1e6,
1847
- effectiveContextWindowTokens: 9e5,
1848
- autoCompactTokenLimit: 85e4,
1849
- toolOutputTruncationTokens: settings.modelToolOutputTruncationTokens
1850
- }));
1887
+ const models = [OPENGENI_GATEWAY_MODELS.deepseek, OPENGENI_GATEWAY_MODELS.kimi].map((model) => {
1888
+ const kimi = model === OPENGENI_GATEWAY_MODELS.kimi;
1889
+ return {
1890
+ id: workspace ? model.workspaceProductId : model.productId,
1891
+ upstreamModelId: model.upstreamModelId,
1892
+ label: model.label,
1893
+ capabilities: gatewayModelCapabilities(settings, {
1894
+ implicitCaching: model.implicitCaching,
1895
+ vision: kimi,
1896
+ inputFileMediaTypes: kimi ? ["application/pdf"] : []
1897
+ }),
1898
+ contextWindowTokens: 1e6,
1899
+ effectiveContextWindowTokens: 9e5,
1900
+ autoCompactTokenLimit: 85e4,
1901
+ toolOutputTruncationTokens: settings.modelToolOutputTruncationTokens
1902
+ };
1903
+ });
1851
1904
  return {
1852
1905
  kind: input.kind,
1853
1906
  id: workspace ? WORKSPACE_GATEWAY_PROVIDER_ID : OPENGENI_GATEWAY_PROVIDER_ID,
@@ -2105,7 +2158,8 @@ function withCodexCatalogProvider(settings) {
2105
2158
  const capabilities = {
2106
2159
  ...legacyModelCapabilities(settings, {
2107
2160
  reasoningEffort: true,
2108
- hostedWebSearch: true
2161
+ hostedWebSearch: true,
2162
+ vision: slug.startsWith("gpt-5.6-")
2109
2163
  }),
2110
2164
  ...builtinPromptCachingForModel(`${CODEX_MODEL_ID_PREFIX}${slug}`) ? {
2111
2165
  promptCaching: builtinPromptCachingForModel(`${CODEX_MODEL_ID_PREFIX}${slug}`)
@@ -2223,7 +2277,8 @@ function configuredModels(settings) {
2223
2277
  const capabilities = {
2224
2278
  ...legacyModelCapabilities(settings, {
2225
2279
  reasoningEffort: true,
2226
- hostedWebSearch: settings.webSearchEnabled
2280
+ hostedWebSearch: settings.webSearchEnabled,
2281
+ vision: id.startsWith("gpt-5.6-")
2227
2282
  }),
2228
2283
  ...builtinPromptCachingForModel(id) ? { promptCaching: builtinPromptCachingForModel(id) } : {},
2229
2284
  latencyModes: builtinLatencyModesForModel(id)
@@ -2498,6 +2553,28 @@ function calculateModelUsageCostMicros(settings, model, usage, options) {
2498
2553
  }
2499
2554
  return total;
2500
2555
  }
2556
+ function calculateGatewayReportedCostMicros(settings, model, inferenceCostUsd, options) {
2557
+ const schedule = configuredModelPricingSchedules(settings)[model];
2558
+ if (!schedule) {
2559
+ throw new Error(`Missing model pricing for ${model}`);
2560
+ }
2561
+ const pricing = selectModelPricing(schedule, positiveInt(options?.inputTokens));
2562
+ const match = /^(0|[1-9]\d*)(?:\.(\d{1,18}))?$/.exec(inferenceCostUsd);
2563
+ if (!match) {
2564
+ throw new Error("Invalid AI Gateway inference cost");
2565
+ }
2566
+ const fraction = match[2] ?? "";
2567
+ const decimalDigits = BigInt(`${match[1]}${fraction}`);
2568
+ const decimalScale = 10n ** BigInt(fraction.length);
2569
+ const marginBps = BigInt(1e4 + (pricing.marginBps ?? 0));
2570
+ const numerator = decimalDigits * 1000000n * marginBps;
2571
+ const denominator = decimalScale * 10000n;
2572
+ const micros = (numerator + denominator - 1n) / denominator;
2573
+ if (micros > BigInt(Number.MAX_SAFE_INTEGER)) {
2574
+ throw new Error("AI Gateway inference cost exceeds the supported billing range");
2575
+ }
2576
+ return Number(micros);
2577
+ }
2501
2578
  function configuredAllowedReasoningEfforts(settings) {
2502
2579
  return uniqueValues([
2503
2580
  settings.openaiReasoningEffort,
@@ -3431,6 +3508,8 @@ function delay(ms) {
3431
3508
  }
3432
3509
  export {
3433
3510
  AGENT_INSTRUCTIONS_CORE_PLACEHOLDER,
3511
+ AI_GATEWAY_REALTIME_MODELS,
3512
+ CODEX_REALTIME_MODEL_ID,
3434
3513
  CapabilityStateV1Schema,
3435
3514
  CapabilitySupportV1,
3436
3515
  DEFAULT_AGENT_INSTRUCTIONS,
@@ -3440,17 +3519,21 @@ export {
3440
3519
  ModelProviderApi,
3441
3520
  OPENGENI_GATEWAY_MODELS,
3442
3521
  OPENGENI_GATEWAY_PROVIDER_ID,
3522
+ OPENGENI_REALTIME_MODEL_ID_PREFIX,
3443
3523
  RegistryProviderKind,
3444
3524
  SANDBOX_REQUIRED_ENV,
3445
3525
  SocialOAuthClientConfigSchema,
3526
+ VERCEL_AI_GATEWAY_AI_SDK_BASE_URL,
3446
3527
  VERCEL_AI_GATEWAY_BASE_URL,
3447
3528
  VERCEL_AI_GATEWAY_CONNECTION_DOMAIN,
3448
3529
  VERCEL_AI_GATEWAY_CONNECTION_ROLE,
3449
3530
  WORKSPACE_GATEWAY_MODEL_ID_PREFIX,
3450
3531
  WORKSPACE_GATEWAY_PROVIDER_ID,
3532
+ WORKSPACE_REALTIME_MODEL_ID_PREFIX,
3451
3533
  applyGitAuthPointerEnvironment,
3452
3534
  assertTurnExecutionPolicyMatchesConfigV1,
3453
3535
  builtinProviderId,
3536
+ calculateGatewayReportedCostMicros,
3454
3537
  calculateModelUsageCostMicros,
3455
3538
  canonicalizeConfiguredModelId,
3456
3539
  collectGitIdentityEnvironment,
@@ -3487,6 +3570,7 @@ export {
3487
3570
  policyProviderIdForModel,
3488
3571
  productLabelForModelId,
3489
3572
  requiredSandboxEnvForBackend,
3573
+ resolveAiGatewayRealtimeModel,
3490
3574
  resolveEnrollmentSigningSecret,
3491
3575
  resolveFirstPartyDelegationSecret,
3492
3576
  resolveModelProvider,