@opengeni/config 0.10.1 → 0.10.3

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";
@@ -743,6 +746,7 @@ declare const RegistryProviderSchema: z.ZodObject<{
743
746
  efforts: z.ZodArray<z.ZodEnum<{
744
747
  high: "high";
745
748
  low: "low";
749
+ max: "max";
746
750
  medium: "medium";
747
751
  minimal: "minimal";
748
752
  none: "none";
@@ -751,6 +755,7 @@ declare const RegistryProviderSchema: z.ZodObject<{
751
755
  defaultEffort: z.ZodNullable<z.ZodEnum<{
752
756
  high: "high";
753
757
  low: "low";
758
+ max: "max";
754
759
  medium: "medium";
755
760
  minimal: "minimal";
756
761
  none: "none";
@@ -940,7 +945,7 @@ export interface ConfiguredModel {
940
945
  capabilities: ModelCapabilitiesV1;
941
946
  requestPolicy?: {
942
947
  gateway: {
943
- only: [string];
948
+ only: [string, ...string[]];
944
949
  caching: "auto" | "none";
945
950
  };
946
951
  };
@@ -954,26 +959,59 @@ export interface ConfiguredModel {
954
959
  hostedWebSearch: boolean;
955
960
  }
956
961
  export declare const VERCEL_AI_GATEWAY_BASE_URL: "https://ai-gateway.vercel.sh/v1";
962
+ export declare const VERCEL_AI_GATEWAY_AI_SDK_BASE_URL: "https://ai-gateway.vercel.sh/v4/ai";
957
963
  export declare const OPENGENI_GATEWAY_PROVIDER_ID: "opengeni-gateway";
958
964
  export declare const WORKSPACE_GATEWAY_PROVIDER_ID: "workspace-gateway";
959
965
  export declare const WORKSPACE_GATEWAY_MODEL_ID_PREFIX: "workspace-gateway/";
960
966
  export declare const VERCEL_AI_GATEWAY_CONNECTION_DOMAIN: "ai-gateway.vercel.sh";
961
967
  export declare const VERCEL_AI_GATEWAY_CONNECTION_ROLE: "vercel_ai_gateway";
968
+ export declare const CODEX_REALTIME_MODEL_ID: "gpt-live-1-boulder-alpha";
969
+ export declare const OPENGENI_REALTIME_MODEL_ID_PREFIX: "opengeni-gateway/";
970
+ export declare const WORKSPACE_REALTIME_MODEL_ID_PREFIX: "workspace-gateway/";
971
+ /** Curated voice models exposed through AI Gateway's normalized realtime API. */
972
+ export declare const AI_GATEWAY_REALTIME_MODELS: {
973
+ readonly openaiRealtime21: {
974
+ readonly upstreamModelId: "openai/gpt-realtime-2.1";
975
+ readonly managedModelId: "opengeni-gateway/openai/gpt-realtime-2.1";
976
+ readonly workspaceModelId: "workspace-gateway/openai/gpt-realtime-2.1";
977
+ readonly label: "GPT Realtime 2.1";
978
+ readonly description: "Best overall voice intelligence";
979
+ };
980
+ readonly openaiRealtimeMini: {
981
+ readonly upstreamModelId: "openai/gpt-realtime-mini";
982
+ readonly managedModelId: "opengeni-gateway/openai/gpt-realtime-mini";
983
+ readonly workspaceModelId: "workspace-gateway/openai/gpt-realtime-mini";
984
+ readonly label: "GPT Realtime Mini";
985
+ readonly description: "Faster, lighter live voice";
986
+ };
987
+ readonly grokVoiceThinkFast20: {
988
+ readonly upstreamModelId: "xai/grok-voice-think-fast-2.0";
989
+ readonly managedModelId: "opengeni-gateway/xai/grok-voice-think-fast-2.0";
990
+ readonly workspaceModelId: "workspace-gateway/xai/grok-voice-think-fast-2.0";
991
+ readonly label: "Grok Voice Think Fast 2.0";
992
+ readonly description: "Fast, natural xAI voice";
993
+ };
994
+ };
995
+ export type AiGatewayRealtimeModel = (typeof AI_GATEWAY_REALTIME_MODELS)[keyof typeof AI_GATEWAY_REALTIME_MODELS];
996
+ export declare function resolveAiGatewayRealtimeModel(modelId: string): {
997
+ source: "managed" | "workspace";
998
+ upstreamModelId: string;
999
+ } | null;
962
1000
  export declare const OPENGENI_GATEWAY_MODELS: {
963
1001
  readonly deepseek: {
964
1002
  readonly productId: "deepseek-v4-flash-0731";
965
1003
  readonly workspaceProductId: "workspace-gateway/deepseek-v4-flash-0731";
966
1004
  readonly upstreamModelId: "deepseek/deepseek-v4-flash-0731";
967
1005
  readonly label: "DeepSeek V4 Flash 0731";
968
- readonly provider: "deepinfra";
1006
+ readonly providers: readonly ["baseten", "novita", "deepinfra"];
969
1007
  readonly implicitCaching: true;
970
1008
  };
971
1009
  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";
1010
+ readonly productId: "kimi-k3";
1011
+ readonly workspaceProductId: "workspace-gateway/kimi-k3";
1012
+ readonly upstreamModelId: "moonshotai/kimi-k3";
1013
+ readonly label: "Kimi K3";
1014
+ readonly providers: readonly ["baseten", "fireworks"];
977
1015
  readonly implicitCaching: true;
978
1016
  };
979
1017
  };
@@ -1184,6 +1222,14 @@ export declare function configuredEntitlements(settings: Settings): Entitlements
1184
1222
  export declare function calculateModelUsageCostMicros(settings: Settings, model: string, usage: ModelUsageInput, options?: {
1185
1223
  latencyMode?: LatencyMode;
1186
1224
  }): number;
1225
+ /**
1226
+ * Convert AI Gateway's exact USD inference cost to OpenGeni credit micros and
1227
+ * apply the configured model margin. Decimal arithmetic is integer-only so a
1228
+ * sub-micro provider charge cannot be lost to floating-point rounding.
1229
+ */
1230
+ export declare function calculateGatewayReportedCostMicros(settings: Settings, model: string, inferenceCostUsd: string, options?: {
1231
+ inputTokens?: number;
1232
+ }): number;
1187
1233
  export declare function configuredAllowedReasoningEfforts(settings: Settings): Array<z.infer<typeof ReasoningEffort>>;
1188
1234
  /**
1189
1235
  * Decodes OPENGENI_ENVIRONMENTS_ENCRYPTION_KEY (base64, exactly 32 bytes) for
package/dist/index.js CHANGED
@@ -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
@@ -1106,26 +1106,64 @@ var IntegrationOAuthClientConfigSchema = z.object({
1106
1106
  tokenEndpointAuthMethod: z.enum(["none", "client_secret_post", "client_secret_basic"]).default("none")
1107
1107
  });
1108
1108
  var VERCEL_AI_GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh/v1";
1109
+ var VERCEL_AI_GATEWAY_AI_SDK_BASE_URL = "https://ai-gateway.vercel.sh/v4/ai";
1109
1110
  var OPENGENI_GATEWAY_PROVIDER_ID = "opengeni-gateway";
1110
1111
  var WORKSPACE_GATEWAY_PROVIDER_ID = "workspace-gateway";
1111
1112
  var WORKSPACE_GATEWAY_MODEL_ID_PREFIX = "workspace-gateway/";
1112
1113
  var VERCEL_AI_GATEWAY_CONNECTION_DOMAIN = "ai-gateway.vercel.sh";
1113
1114
  var VERCEL_AI_GATEWAY_CONNECTION_ROLE = "vercel_ai_gateway";
1115
+ var CODEX_REALTIME_MODEL_ID = "gpt-live-1-boulder-alpha";
1116
+ var OPENGENI_REALTIME_MODEL_ID_PREFIX = "opengeni-gateway/";
1117
+ var WORKSPACE_REALTIME_MODEL_ID_PREFIX = "workspace-gateway/";
1118
+ var AI_GATEWAY_REALTIME_MODELS = {
1119
+ openaiRealtime21: {
1120
+ upstreamModelId: "openai/gpt-realtime-2.1",
1121
+ managedModelId: `${OPENGENI_REALTIME_MODEL_ID_PREFIX}openai/gpt-realtime-2.1`,
1122
+ workspaceModelId: `${WORKSPACE_REALTIME_MODEL_ID_PREFIX}openai/gpt-realtime-2.1`,
1123
+ label: "GPT Realtime 2.1",
1124
+ description: "Best overall voice intelligence"
1125
+ },
1126
+ openaiRealtimeMini: {
1127
+ upstreamModelId: "openai/gpt-realtime-mini",
1128
+ managedModelId: `${OPENGENI_REALTIME_MODEL_ID_PREFIX}openai/gpt-realtime-mini`,
1129
+ workspaceModelId: `${WORKSPACE_REALTIME_MODEL_ID_PREFIX}openai/gpt-realtime-mini`,
1130
+ label: "GPT Realtime Mini",
1131
+ description: "Faster, lighter live voice"
1132
+ },
1133
+ grokVoiceThinkFast20: {
1134
+ upstreamModelId: "xai/grok-voice-think-fast-2.0",
1135
+ managedModelId: `${OPENGENI_REALTIME_MODEL_ID_PREFIX}xai/grok-voice-think-fast-2.0`,
1136
+ workspaceModelId: `${WORKSPACE_REALTIME_MODEL_ID_PREFIX}xai/grok-voice-think-fast-2.0`,
1137
+ label: "Grok Voice Think Fast 2.0",
1138
+ description: "Fast, natural xAI voice"
1139
+ }
1140
+ };
1141
+ function resolveAiGatewayRealtimeModel(modelId) {
1142
+ for (const model of Object.values(AI_GATEWAY_REALTIME_MODELS)) {
1143
+ if (model.managedModelId === modelId) {
1144
+ return { source: "managed", upstreamModelId: model.upstreamModelId };
1145
+ }
1146
+ if (model.workspaceModelId === modelId) {
1147
+ return { source: "workspace", upstreamModelId: model.upstreamModelId };
1148
+ }
1149
+ }
1150
+ return null;
1151
+ }
1114
1152
  var OPENGENI_GATEWAY_MODELS = {
1115
1153
  deepseek: {
1116
1154
  productId: "deepseek-v4-flash-0731",
1117
1155
  workspaceProductId: `${WORKSPACE_GATEWAY_MODEL_ID_PREFIX}deepseek-v4-flash-0731`,
1118
1156
  upstreamModelId: "deepseek/deepseek-v4-flash-0731",
1119
1157
  label: "DeepSeek V4 Flash 0731",
1120
- provider: "deepinfra",
1158
+ providers: ["baseten", "novita", "deepinfra"],
1121
1159
  implicitCaching: true
1122
1160
  },
1123
1161
  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",
1162
+ productId: "kimi-k3",
1163
+ workspaceProductId: `${WORKSPACE_GATEWAY_MODEL_ID_PREFIX}kimi-k3`,
1164
+ upstreamModelId: "moonshotai/kimi-k3",
1165
+ label: "Kimi K3",
1166
+ providers: ["baseten", "fireworks"],
1129
1167
  implicitCaching: true
1130
1168
  }
1131
1169
  };
@@ -1188,24 +1226,24 @@ var defaultModelPricing = {
1188
1226
  }
1189
1227
  ]
1190
1228
  },
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.
1229
+ // Conservative Vercel AI Gateway fallback prices. Normal managed Gateway
1230
+ // billing uses the exact response Gateway `cost` / `inferenceCost` and applies
1231
+ // the same margin. These token rates are used only if that
1232
+ // metadata is absent. DeepSeek therefore carries the highest approved route
1233
+ // (Novita); both approved Kimi routes have the same list price.
1196
1234
  [OPENGENI_GATEWAY_MODELS.deepseek.productId]: {
1197
1235
  default: {
1198
- inputMicrosPerMillionTokens: 9e4,
1199
- cachedInputMicrosPerMillionTokens: 18e3,
1200
- outputMicrosPerMillionTokens: 18e4,
1236
+ inputMicrosPerMillionTokens: 14e4,
1237
+ cachedInputMicrosPerMillionTokens: 28e3,
1238
+ outputMicrosPerMillionTokens: 28e4,
1201
1239
  marginBps: 2500
1202
1240
  }
1203
1241
  },
1204
1242
  [OPENGENI_GATEWAY_MODELS.kimi.productId]: {
1205
1243
  default: {
1206
- inputMicrosPerMillionTokens: 45e5,
1207
- cachedInputMicrosPerMillionTokens: 45e4,
1208
- outputMicrosPerMillionTokens: 225e5,
1244
+ inputMicrosPerMillionTokens: 3e6,
1245
+ cachedInputMicrosPerMillionTokens: 3e5,
1246
+ outputMicrosPerMillionTokens: 15e6,
1209
1247
  marginBps: 2500
1210
1248
  }
1211
1249
  },
@@ -1809,7 +1847,7 @@ function gatewayRequestPolicyForUpstreamModel(upstreamModelId) {
1809
1847
  }
1810
1848
  return {
1811
1849
  gateway: {
1812
- only: [model.provider],
1850
+ only: [...model.providers],
1813
1851
  caching: model.implicitCaching ? "auto" : "none"
1814
1852
  }
1815
1853
  };
@@ -1828,26 +1866,29 @@ function gatewayModelCapabilities(settings, input) {
1828
1866
  sse: { upstream: "supported", runnable: true }
1829
1867
  },
1830
1868
  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.
1869
+ // Both Gateway products expose one reviewed route policy and no separately
1870
+ // billed latency mode.
1833
1871
  latencyModes: [{ id: "standard", upstream: "supported", runnable: true }]
1834
1872
  });
1835
1873
  }
1836
1874
  function gatewayRegistryProvider(settings, input) {
1837
1875
  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
- }));
1876
+ const models = [OPENGENI_GATEWAY_MODELS.deepseek, OPENGENI_GATEWAY_MODELS.kimi].map((model) => {
1877
+ const kimi = model === OPENGENI_GATEWAY_MODELS.kimi;
1878
+ return {
1879
+ id: workspace ? model.workspaceProductId : model.productId,
1880
+ upstreamModelId: model.upstreamModelId,
1881
+ label: model.label,
1882
+ capabilities: gatewayModelCapabilities(settings, {
1883
+ implicitCaching: model.implicitCaching,
1884
+ vision: kimi
1885
+ }),
1886
+ contextWindowTokens: 1e6,
1887
+ effectiveContextWindowTokens: 9e5,
1888
+ autoCompactTokenLimit: 85e4,
1889
+ toolOutputTruncationTokens: settings.modelToolOutputTruncationTokens
1890
+ };
1891
+ });
1851
1892
  return {
1852
1893
  kind: input.kind,
1853
1894
  id: workspace ? WORKSPACE_GATEWAY_PROVIDER_ID : OPENGENI_GATEWAY_PROVIDER_ID,
@@ -2498,6 +2539,28 @@ function calculateModelUsageCostMicros(settings, model, usage, options) {
2498
2539
  }
2499
2540
  return total;
2500
2541
  }
2542
+ function calculateGatewayReportedCostMicros(settings, model, inferenceCostUsd, options) {
2543
+ const schedule = configuredModelPricingSchedules(settings)[model];
2544
+ if (!schedule) {
2545
+ throw new Error(`Missing model pricing for ${model}`);
2546
+ }
2547
+ const pricing = selectModelPricing(schedule, positiveInt(options?.inputTokens));
2548
+ const match = /^(0|[1-9]\d*)(?:\.(\d{1,18}))?$/.exec(inferenceCostUsd);
2549
+ if (!match) {
2550
+ throw new Error("Invalid AI Gateway inference cost");
2551
+ }
2552
+ const fraction = match[2] ?? "";
2553
+ const decimalDigits = BigInt(`${match[1]}${fraction}`);
2554
+ const decimalScale = 10n ** BigInt(fraction.length);
2555
+ const marginBps = BigInt(1e4 + (pricing.marginBps ?? 0));
2556
+ const numerator = decimalDigits * 1000000n * marginBps;
2557
+ const denominator = decimalScale * 10000n;
2558
+ const micros = (numerator + denominator - 1n) / denominator;
2559
+ if (micros > BigInt(Number.MAX_SAFE_INTEGER)) {
2560
+ throw new Error("AI Gateway inference cost exceeds the supported billing range");
2561
+ }
2562
+ return Number(micros);
2563
+ }
2501
2564
  function configuredAllowedReasoningEfforts(settings) {
2502
2565
  return uniqueValues([
2503
2566
  settings.openaiReasoningEffort,
@@ -3431,6 +3494,8 @@ function delay(ms) {
3431
3494
  }
3432
3495
  export {
3433
3496
  AGENT_INSTRUCTIONS_CORE_PLACEHOLDER,
3497
+ AI_GATEWAY_REALTIME_MODELS,
3498
+ CODEX_REALTIME_MODEL_ID,
3434
3499
  CapabilityStateV1Schema,
3435
3500
  CapabilitySupportV1,
3436
3501
  DEFAULT_AGENT_INSTRUCTIONS,
@@ -3440,17 +3505,21 @@ export {
3440
3505
  ModelProviderApi,
3441
3506
  OPENGENI_GATEWAY_MODELS,
3442
3507
  OPENGENI_GATEWAY_PROVIDER_ID,
3508
+ OPENGENI_REALTIME_MODEL_ID_PREFIX,
3443
3509
  RegistryProviderKind,
3444
3510
  SANDBOX_REQUIRED_ENV,
3445
3511
  SocialOAuthClientConfigSchema,
3512
+ VERCEL_AI_GATEWAY_AI_SDK_BASE_URL,
3446
3513
  VERCEL_AI_GATEWAY_BASE_URL,
3447
3514
  VERCEL_AI_GATEWAY_CONNECTION_DOMAIN,
3448
3515
  VERCEL_AI_GATEWAY_CONNECTION_ROLE,
3449
3516
  WORKSPACE_GATEWAY_MODEL_ID_PREFIX,
3450
3517
  WORKSPACE_GATEWAY_PROVIDER_ID,
3518
+ WORKSPACE_REALTIME_MODEL_ID_PREFIX,
3451
3519
  applyGitAuthPointerEnvironment,
3452
3520
  assertTurnExecutionPolicyMatchesConfigV1,
3453
3521
  builtinProviderId,
3522
+ calculateGatewayReportedCostMicros,
3454
3523
  calculateModelUsageCostMicros,
3455
3524
  canonicalizeConfiguredModelId,
3456
3525
  collectGitIdentityEnvironment,
@@ -3487,6 +3556,7 @@ export {
3487
3556
  policyProviderIdForModel,
3488
3557
  productLabelForModelId,
3489
3558
  requiredSandboxEnvForBackend,
3559
+ resolveAiGatewayRealtimeModel,
3490
3560
  resolveEnrollmentSigningSecret,
3491
3561
  resolveFirstPartyDelegationSecret,
3492
3562
  resolveModelProvider,