@hebo-ai/gateway 0.10.7 → 0.11.0

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.
Files changed (111) hide show
  1. package/README.md +97 -84
  2. package/dist/config.js +21 -4
  3. package/dist/endpoints/chat-completions/handler.js +9 -5
  4. package/dist/endpoints/conversations/handler.js +3 -3
  5. package/dist/endpoints/embeddings/handler.js +2 -2
  6. package/dist/endpoints/messages/converters.js +17 -21
  7. package/dist/endpoints/messages/handler.js +5 -5
  8. package/dist/endpoints/responses/handler.js +9 -5
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +1 -0
  11. package/dist/models/alibaba/index.d.ts +2 -0
  12. package/dist/models/alibaba/index.js +2 -0
  13. package/dist/models/alibaba/middleware.d.ts +2 -0
  14. package/dist/models/alibaba/middleware.js +31 -0
  15. package/dist/models/alibaba/presets.d.ts +900 -0
  16. package/dist/models/alibaba/presets.js +252 -0
  17. package/dist/models/amazon/presets.d.ts +31 -31
  18. package/dist/models/anthropic/presets.d.ts +68 -68
  19. package/dist/models/cohere/presets.d.ts +38 -38
  20. package/dist/models/deepseek/index.d.ts +2 -0
  21. package/dist/models/deepseek/index.js +2 -0
  22. package/dist/models/deepseek/middleware.d.ts +2 -0
  23. package/dist/models/deepseek/middleware.js +25 -0
  24. package/dist/models/deepseek/presets.d.ts +51 -0
  25. package/dist/models/deepseek/presets.js +33 -0
  26. package/dist/models/google/presets.d.ts +94 -94
  27. package/dist/models/google/presets.js +3 -1
  28. package/dist/models/meta/presets.d.ts +84 -84
  29. package/dist/models/meta/presets.js +11 -12
  30. package/dist/models/minimax/index.d.ts +2 -0
  31. package/dist/models/minimax/index.js +2 -0
  32. package/dist/models/minimax/middleware.d.ts +2 -0
  33. package/dist/models/minimax/middleware.js +43 -0
  34. package/dist/models/minimax/presets.d.ts +99 -0
  35. package/dist/models/minimax/presets.js +47 -0
  36. package/dist/models/moonshot/index.d.ts +2 -0
  37. package/dist/models/moonshot/index.js +2 -0
  38. package/dist/models/moonshot/middleware.d.ts +2 -0
  39. package/dist/models/moonshot/middleware.js +32 -0
  40. package/dist/models/moonshot/presets.d.ts +104 -0
  41. package/dist/models/moonshot/presets.js +36 -0
  42. package/dist/models/openai/presets.d.ts +128 -128
  43. package/dist/models/openai/presets.js +1 -1
  44. package/dist/models/types.d.ts +1 -1
  45. package/dist/models/types.js +39 -0
  46. package/dist/models/voyage/presets.d.ts +46 -46
  47. package/dist/models/xai/index.d.ts +2 -0
  48. package/dist/models/xai/index.js +2 -0
  49. package/dist/models/xai/middleware.d.ts +2 -0
  50. package/dist/models/xai/middleware.js +37 -0
  51. package/dist/models/xai/presets.d.ts +210 -0
  52. package/dist/models/xai/presets.js +55 -0
  53. package/dist/models/zai/index.d.ts +2 -0
  54. package/dist/models/zai/index.js +2 -0
  55. package/dist/models/zai/middleware.d.ts +2 -0
  56. package/dist/models/zai/middleware.js +25 -0
  57. package/dist/models/zai/presets.d.ts +141 -0
  58. package/dist/models/zai/presets.js +41 -0
  59. package/dist/providers/alibaba/canonical.d.ts +3 -0
  60. package/dist/providers/alibaba/canonical.js +13 -0
  61. package/dist/providers/alibaba/index.d.ts +1 -0
  62. package/dist/providers/alibaba/index.js +1 -0
  63. package/dist/providers/bedrock/canonical.js +3 -0
  64. package/dist/providers/chutes/canonical.d.ts +3 -0
  65. package/dist/providers/chutes/canonical.js +14 -0
  66. package/dist/providers/chutes/index.d.ts +1 -0
  67. package/dist/providers/chutes/index.js +1 -0
  68. package/dist/providers/deepinfra/canonical.d.ts +3 -0
  69. package/dist/providers/deepinfra/canonical.js +40 -0
  70. package/dist/providers/deepinfra/index.d.ts +1 -0
  71. package/dist/providers/deepinfra/index.js +1 -0
  72. package/dist/providers/deepseek/canonical.d.ts +3 -0
  73. package/dist/providers/deepseek/canonical.js +9 -0
  74. package/dist/providers/deepseek/index.d.ts +1 -0
  75. package/dist/providers/deepseek/index.js +1 -0
  76. package/dist/providers/fireworks/canonical.d.ts +3 -0
  77. package/dist/providers/fireworks/canonical.js +27 -0
  78. package/dist/providers/fireworks/index.d.ts +2 -0
  79. package/dist/providers/fireworks/index.js +2 -0
  80. package/dist/providers/fireworks/middleware.d.ts +2 -0
  81. package/dist/providers/fireworks/middleware.js +35 -0
  82. package/dist/providers/groq/canonical.js +1 -1
  83. package/dist/providers/minimax/canonical.d.ts +3 -0
  84. package/dist/providers/minimax/canonical.js +9 -0
  85. package/dist/providers/minimax/index.d.ts +1 -0
  86. package/dist/providers/minimax/index.js +1 -0
  87. package/dist/providers/moonshot/canonical.d.ts +3 -0
  88. package/dist/providers/moonshot/canonical.js +6 -0
  89. package/dist/providers/moonshot/index.d.ts +1 -0
  90. package/dist/providers/moonshot/index.js +1 -0
  91. package/dist/providers/togetherai/canonical.d.ts +3 -0
  92. package/dist/providers/togetherai/canonical.js +24 -0
  93. package/dist/providers/togetherai/index.d.ts +1 -0
  94. package/dist/providers/togetherai/index.js +1 -0
  95. package/dist/providers/types.d.ts +1 -1
  96. package/dist/providers/types.js +10 -0
  97. package/dist/providers/vertex/canonical.js +5 -1
  98. package/dist/providers/xai/canonical.d.ts +3 -0
  99. package/dist/providers/xai/canonical.js +12 -0
  100. package/dist/providers/xai/index.d.ts +1 -0
  101. package/dist/providers/xai/index.js +1 -0
  102. package/dist/providers/zai/canonical.d.ts +3 -0
  103. package/dist/providers/zai/canonical.js +10 -0
  104. package/dist/providers/zai/index.d.ts +1 -0
  105. package/dist/providers/zai/index.js +1 -0
  106. package/dist/types.d.ts +30 -16
  107. package/dist/utils/index.d.ts +8 -0
  108. package/dist/utils/index.js +8 -0
  109. package/dist/utils/request.d.ts +2 -1
  110. package/dist/utils/request.js +35 -7
  111. package/package.json +133 -9
@@ -0,0 +1,27 @@
1
+ import {} from "@ai-sdk/fireworks";
2
+ import { withCanonicalIds } from "../registry";
3
+ const MAPPING = {
4
+ "meta/llama-3.1-8b": "accounts/fireworks/models/llama-v3p1-8b-instruct",
5
+ "meta/llama-3.1-405b": "accounts/fireworks/models/llama-v3p1-405b-instruct",
6
+ "meta/llama-3.2-3b": "accounts/fireworks/models/llama-v3p2-3b-instruct",
7
+ "meta/llama-3.2-11b": "accounts/fireworks/models/llama-v3p2-11b-vision-instruct",
8
+ "meta/llama-3.3-70b": "accounts/fireworks/models/llama-v3p3-70b-instruct",
9
+ "openai/gpt-oss-20b": "accounts/fireworks/models/gpt-oss-20b",
10
+ "openai/gpt-oss-120b": "accounts/fireworks/models/gpt-oss-120b",
11
+ "minimax/m2.7": "accounts/fireworks/models/minimax-m2p7",
12
+ "alibaba/qwen3-235b": "accounts/fireworks/models/qwen3-235b-a22b",
13
+ "alibaba/qwen3-32b": "accounts/fireworks/models/qwen3-32b",
14
+ "alibaba/qwen3.5-397b": "accounts/fireworks/models/qwen3p5-397b-a17b",
15
+ "alibaba/qwen3.5-35b": "accounts/fireworks/models/qwen3p5-35b-a3b",
16
+ "alibaba/qwen3.5-27b": "accounts/fireworks/models/qwen3p5-27b",
17
+ "alibaba/qwen3.5-9b": "accounts/fireworks/models/qwen3p5-9b",
18
+ "deepseek/deepseek-v3.2": "accounts/fireworks/models/deepseek-v3p2",
19
+ "moonshot/kimi-k2.5": "accounts/fireworks/models/kimi-k2p5",
20
+ "moonshot/kimi-k2.6": "accounts/fireworks/models/kimi-k2p6",
21
+ "zhipu/glm-5": "accounts/fireworks/models/glm-5",
22
+ "zhipu/glm-5.1": "accounts/fireworks/models/glm-5p1",
23
+ };
24
+ export const withCanonicalIdsForFireworks = (provider, extraMapping) => withCanonicalIds(provider, {
25
+ mapping: { ...MAPPING, ...extraMapping },
26
+ options: { stripNamespace: false },
27
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./canonical";
2
+ export * from "./middleware";
@@ -0,0 +1,2 @@
1
+ export * from "./canonical";
2
+ export * from "./middleware";
@@ -0,0 +1,2 @@
1
+ import type { LanguageModelMiddleware } from "ai";
2
+ export declare const fireworksReasoningMiddleware: LanguageModelMiddleware;
@@ -0,0 +1,35 @@
1
+ import { modelMiddlewareMatcher } from "../../middleware/matcher";
2
+ import { calculateReasoningBudgetFromEffort } from "../../middleware/utils";
3
+ const FIREWORKS_MAX_OUTPUT_TOKENS = 131072;
4
+ export const fireworksReasoningMiddleware = {
5
+ specificationVersion: "v3",
6
+ // oxlint-disable-next-line require-await
7
+ transformParams: async ({ params }) => {
8
+ const fireworks = params.providerOptions?.["fireworks"];
9
+ if (!fireworks || typeof fireworks !== "object")
10
+ return params;
11
+ const reasoning = fireworks["reasoning"];
12
+ if (!reasoning)
13
+ return params;
14
+ if (!reasoning.enabled) {
15
+ fireworks.thinking = { type: "disabled" };
16
+ }
17
+ else if (reasoning.max_tokens) {
18
+ fireworks.thinking = { type: "enabled", budgetTokens: reasoning.max_tokens };
19
+ }
20
+ else if (reasoning.effort) {
21
+ fireworks.thinking = {
22
+ type: "enabled",
23
+ budgetTokens: calculateReasoningBudgetFromEffort(reasoning.effort, params.maxOutputTokens ?? FIREWORKS_MAX_OUTPUT_TOKENS, 1024),
24
+ };
25
+ }
26
+ else {
27
+ fireworks.thinking = { type: "enabled" };
28
+ }
29
+ delete fireworks["reasoning"];
30
+ return params;
31
+ },
32
+ };
33
+ modelMiddlewareMatcher.useForProvider("fireworks", {
34
+ language: [fireworksReasoningMiddleware],
35
+ });
@@ -4,7 +4,7 @@ const MAPPING = {
4
4
  "meta/llama-3.1-8b": "llama-3.1-8b-instant",
5
5
  "meta/llama-3.3-70b": "llama-3.3-70b-versatile",
6
6
  "meta/llama-4-scout": "meta-llama/llama-4-scout-17b-16e-instruct",
7
- "meta/llama-4-maverick": "meta-llama/llama-4-maverick-17b-128e-instruct",
7
+ "alibaba/qwen3-32b": "qwen/qwen3-32b",
8
8
  };
9
9
  export const withCanonicalIdsForGroq = (provider, extraMapping) => withCanonicalIds(provider, {
10
10
  mapping: { ...MAPPING, ...extraMapping },
@@ -0,0 +1,3 @@
1
+ import type { ProviderV3 } from "@ai-sdk/provider";
2
+ import type { ModelId } from "../../models/types";
3
+ export declare const withCanonicalIdsForMinimax: (provider: ProviderV3, extraMapping?: Record<ModelId, string>) => ProviderV3;
@@ -0,0 +1,9 @@
1
+ import { withCanonicalIds } from "../registry";
2
+ const MAPPING = {
3
+ "minimax/m2.5": "MiniMax-M2.5",
4
+ "minimax/m2.7": "MiniMax-M2.7",
5
+ };
6
+ export const withCanonicalIdsForMinimax = (provider, extraMapping) => withCanonicalIds(provider, {
7
+ mapping: { ...MAPPING, ...extraMapping },
8
+ options: { stripNamespace: false },
9
+ });
@@ -0,0 +1 @@
1
+ export * from "./canonical";
@@ -0,0 +1 @@
1
+ export * from "./canonical";
@@ -0,0 +1,3 @@
1
+ import { type MoonshotAIProvider } from "@ai-sdk/moonshotai";
2
+ import type { ModelId } from "../../models/types";
3
+ export declare const withCanonicalIdsForMoonshot: (provider: MoonshotAIProvider, extraMapping?: Partial<Record<ModelId, string>>) => import("@ai-sdk/provider").ProviderV3;
@@ -0,0 +1,6 @@
1
+ import {} from "@ai-sdk/moonshotai";
2
+ import { withCanonicalIds } from "../registry";
3
+ export const withCanonicalIdsForMoonshot = (provider, extraMapping) => withCanonicalIds(provider, {
4
+ mapping: extraMapping,
5
+ options: { stripNamespace: true },
6
+ });
@@ -0,0 +1 @@
1
+ export * from "./canonical";
@@ -0,0 +1 @@
1
+ export * from "./canonical";
@@ -0,0 +1,3 @@
1
+ import { type TogetherAIProvider } from "@ai-sdk/togetherai";
2
+ import type { ModelId } from "../../models/types";
3
+ export declare const withCanonicalIdsForTogetherAI: (provider: TogetherAIProvider, extraMapping?: Record<ModelId, string>) => import("@ai-sdk/provider").ProviderV3;
@@ -0,0 +1,24 @@
1
+ import {} from "@ai-sdk/togetherai";
2
+ import { withCanonicalIds } from "../registry";
3
+ const MAPPING = {
4
+ "google/gemma-4-31b": "google/gemma-4-31B-it",
5
+ "meta/llama-3.1-8b": "meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",
6
+ "meta/llama-3.1-70b": "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
7
+ "meta/llama-3.1-405b": "meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo",
8
+ "meta/llama-3.2-3b": "meta-llama/Llama-3.2-3B-Instruct-Turbo",
9
+ "meta/llama-3.3-70b": "meta-llama/Llama-3.3-70B-Instruct-Turbo",
10
+ "meta/llama-4-maverick": "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",
11
+ "minimax/m2.5": "MiniMax/MiniMax-M2.5",
12
+ "minimax/m2.7": "MiniMax/MiniMax-M2.7",
13
+ "alibaba/qwen3-235b": "Qwen/Qwen3-235B-A22B",
14
+ "alibaba/qwen3-32b": "Qwen/Qwen3-32B",
15
+ "alibaba/qwen3.5-397b": "Qwen/Qwen3.5-397B-A17B",
16
+ "alibaba/qwen3.5-9b": "Qwen/Qwen3.5-9B",
17
+ "moonshot/kimi-k2.5": "moonshotai/Kimi-K2.5",
18
+ "zhipu/glm-5": "zai-org/GLM-5",
19
+ "zhipu/glm-5.1": "zai-org/GLM-5.1",
20
+ };
21
+ export const withCanonicalIdsForTogetherAI = (provider, extraMapping) => withCanonicalIds(provider, {
22
+ mapping: { ...MAPPING, ...extraMapping },
23
+ options: { stripNamespace: false },
24
+ });
@@ -0,0 +1 @@
1
+ export * from "./canonical";
@@ -0,0 +1 @@
1
+ export * from "./canonical";
@@ -1,5 +1,5 @@
1
1
  import { type ProviderV3 } from "@ai-sdk/provider";
2
- export declare const CANONICAL_PROVIDER_IDS: readonly ["anthropic", "azure", "bedrock", "cohere", "groq", "openai", "vertex", "voyage"];
2
+ export declare const CANONICAL_PROVIDER_IDS: readonly ["alibaba", "anthropic", "azure", "bedrock", "chutes", "cohere", "deepinfra", "deepseek", "fireworks", "groq", "minimax", "moonshot", "openai", "togetherai", "vertex", "voyage", "xai", "zai"];
3
3
  export type CanonicalProviderId = (typeof CANONICAL_PROVIDER_IDS)[number];
4
4
  export type ProviderId = CanonicalProviderId | (string & {});
5
5
  export type ProviderRegistry = {
@@ -1,11 +1,21 @@
1
1
  import {} from "@ai-sdk/provider";
2
2
  export const CANONICAL_PROVIDER_IDS = [
3
+ "alibaba",
3
4
  "anthropic",
4
5
  "azure",
5
6
  "bedrock",
7
+ "chutes",
6
8
  "cohere",
9
+ "deepinfra",
10
+ "deepseek",
11
+ "fireworks",
7
12
  "groq",
13
+ "minimax",
14
+ "moonshot",
8
15
  "openai",
16
+ "togetherai",
9
17
  "vertex",
10
18
  "voyage",
19
+ "xai",
20
+ "zai",
11
21
  ];
@@ -1,6 +1,10 @@
1
1
  import { withCanonicalIds } from "../registry";
2
+ const MAPPING = {
3
+ "alibaba/qwen3-235b": "qwen3-235b-a22b-instruct-2507-maas",
4
+ "deepseek/deepseek-v3.2": "deepseek-v3.2-maas",
5
+ };
2
6
  export const withCanonicalIdsForVertex = (provider, extraMapping) => withCanonicalIds(provider, {
3
- mapping: extraMapping,
7
+ mapping: { ...MAPPING, ...extraMapping },
4
8
  options: {
5
9
  stripNamespace: true,
6
10
  normalizeDelimiters: ["anthropic"],
@@ -0,0 +1,3 @@
1
+ import { type XaiProvider } from "@ai-sdk/xai";
2
+ import type { ModelId } from "../../models/types";
3
+ export declare const withCanonicalIdsForXai: (provider: XaiProvider, extraMapping?: Partial<Record<ModelId, string>>) => import("@ai-sdk/provider").ProviderV3;
@@ -0,0 +1,12 @@
1
+ import {} from "@ai-sdk/xai";
2
+ import { withCanonicalIds } from "../registry";
3
+ const MAPPING = {
4
+ "xai/grok-4.1-fast": "grok-4-1-fast-non-reasoning",
5
+ "xai/grok-4.2": "grok-4.20-0309-non-reasoning",
6
+ "xai/grok-4.2-reasoning": "grok-4.20-0309-reasoning",
7
+ "xai/grok-4.2-multi-agent": "grok-4.20-multi-agent-0309",
8
+ };
9
+ export const withCanonicalIdsForXai = (provider, extraMapping) => withCanonicalIds(provider, {
10
+ mapping: { ...MAPPING, ...extraMapping },
11
+ options: { stripNamespace: true, normalizeDelimiters: true },
12
+ });
@@ -0,0 +1 @@
1
+ export * from "./canonical";
@@ -0,0 +1 @@
1
+ export * from "./canonical";
@@ -0,0 +1,3 @@
1
+ import type { ZhipuProvider } from "zhipu-ai-provider";
2
+ import type { ModelId } from "../../models/types";
3
+ export declare const withCanonicalIdsForZai: (provider: ZhipuProvider, extraMapping?: Partial<Record<ModelId, string>>) => import("@ai-sdk/provider").ProviderV3;
@@ -0,0 +1,10 @@
1
+ import { withCanonicalIds } from "../registry";
2
+ const MAPPING = {
3
+ "zhipu/glm-5": "glm-5-20260211",
4
+ "zhipu/glm-5-turbo": "glm-5-turbo-20260315",
5
+ "zhipu/glm-5.1": "glm-5.1-20260406",
6
+ };
7
+ export const withCanonicalIdsForZai = (provider, extraMapping) => withCanonicalIds(provider, {
8
+ mapping: { ...MAPPING, ...extraMapping },
9
+ options: { stripNamespace: true },
10
+ });
@@ -0,0 +1 @@
1
+ export * from "./canonical";
@@ -0,0 +1 @@
1
+ export * from "./canonical";
package/dist/types.d.ts CHANGED
@@ -209,27 +209,41 @@ export type GatewayConfig = {
209
209
  };
210
210
  };
211
211
  /**
212
- * Optional timeout for server responses.
213
- * Supports a number in milliseconds, or tiered config.
212
+ * Advanced configuration for timeouts, body limits, and header forwarding.
214
213
  */
215
- timeouts?: GatewayTimeout;
216
- /**
217
- * Maximum *decompressed* request body size in bytes for gzip/deflate-encoded requests.
218
- * Plain (uncompressed) request body size limits should be configured at the
219
- * framework or server level (e.g. Hono `bodyLimit` middleware, Bun `maxRequestBodySize`).
220
- * Set to `0` to disable the decompressed size limit.
221
- * Defaults to 10 MB (10,485,760 bytes).
222
- */
223
- maxBodySize?: number;
214
+ advanced?: {
215
+ /**
216
+ * Optional timeout for server responses.
217
+ * Supports a number in milliseconds, or tiered config.
218
+ */
219
+ timeouts?: GatewayTimeout;
220
+ /**
221
+ * Maximum *decompressed* request body size in bytes for gzip/deflate-encoded requests.
222
+ * Plain (uncompressed) request body size limits should be configured at the
223
+ * framework or server level (e.g. Hono `bodyLimit` middleware, Bun `maxRequestBodySize`).
224
+ * Set to `0` to disable the decompressed size limit.
225
+ * Defaults to 10 MB (10,485,760 bytes).
226
+ */
227
+ maxBodySize?: number;
228
+ /**
229
+ * Additional headers to forward to upstream providers,
230
+ * merged with the built-in allowlist at startup.
231
+ * Header names are matched case-insensitively.
232
+ */
233
+ forwardHeaders?: string[];
234
+ };
224
235
  };
225
236
  export declare const kParsed: unique symbol;
226
- export type GatewayConfigParsed = Omit<GatewayConfig, "storage" | "timeouts"> & {
237
+ export type GatewayConfigParsed = Omit<GatewayConfig, "storage" | "advanced"> & {
227
238
  storage: ConversationStorage;
228
- timeouts: {
229
- normal?: number;
230
- flex?: number;
239
+ advanced: {
240
+ timeouts: {
241
+ normal?: number;
242
+ flex?: number;
243
+ };
244
+ maxBodySize: number;
245
+ forwardHeaders: string[];
231
246
  };
232
- maxBodySize: number;
233
247
  [kParsed]: true;
234
248
  };
235
249
  export interface Endpoint {
@@ -0,0 +1,8 @@
1
+ export * from "./body";
2
+ export * from "./env";
3
+ export * from "./headers";
4
+ export * from "./preset";
5
+ export * from "./request";
6
+ export * from "./response";
7
+ export * from "./stream";
8
+ export * from "./url";
@@ -0,0 +1,8 @@
1
+ export * from "./body";
2
+ export * from "./env";
3
+ export * from "./headers";
4
+ export * from "./preset";
5
+ export * from "./request";
6
+ export * from "./response";
7
+ export * from "./stream";
8
+ export * from "./url";
@@ -1,2 +1,3 @@
1
+ export declare const FORWARD_HEADER_ALLOWLIST: readonly ["openai-beta", "openai-organization", "openai-project", "or_app_name", "or_site_url", "x-openrouter-categories", "x-openrouter-title", "x-title", "anthropic-beta", "anthropic-version", "x-claude-code-session-id", "x-amzn-bedrock-guardrailidentifier", "x-amzn-bedrock-guardrailversion", "x-amzn-bedrock-performanceconfig-latency", "x-amzn-bedrock-trace", "x-goog-api-client", "x-vertex-ai-endpoint-id", "x-vertex-ai-llm-request-type", "x-vertex-ai-llm-shared-request-type", "x-kilo-session", "x-kilocode-taskid", "x-kilocode-editorname", "x-kilocode-feature", "x-kilocode-machineid", "x-kilocode-organizationid", "x-kilocode-projectid", "x-kilocode-tester", "agent-session-id", "x-client", "x-client-name", "x-client-type", "x-client-version", "x-platform", "x-platform-version", "x-task-id", "x-stainless-arch", "x-stainless-lang", "x-stainless-os", "x-stainless-package-version", "x-stainless-runtime", "x-stainless-runtime-version"];
1
2
  export declare const resolveOrCreateRequestId: (request: Request) => string;
2
- export declare const prepareForwardHeaders: (request: Request) => Record<string, string>;
3
+ export declare const prepareForwardHeaders: (request: Request, allowlist?: readonly string[]) => Record<string, string>;
@@ -1,32 +1,60 @@
1
1
  import pkg from "../../package.json" with { type: "json" };
2
2
  import { resolveRequestId } from "./headers";
3
3
  const GATEWAY_VERSION = pkg.version;
4
- const FORWARD_HEADER_ALLOWLIST = [
5
- // OpenAI + OpenAI-compatible providers (Azure, Groq, Together, Fireworks, etc.)
4
+ export const FORWARD_HEADER_ALLOWLIST = [
5
+ // OpenAI
6
6
  "openai-beta",
7
7
  "openai-organization",
8
8
  "openai-project",
9
9
  // OpenRouter
10
+ "or_app_name",
11
+ "or_site_url",
10
12
  "x-openrouter-categories",
11
13
  "x-openrouter-title",
12
14
  "x-title",
13
15
  // Anthropic
14
16
  "anthropic-beta",
17
+ "anthropic-version",
18
+ "x-claude-code-session-id",
15
19
  // AWS Bedrock
16
20
  "x-amzn-bedrock-guardrailidentifier",
17
21
  "x-amzn-bedrock-guardrailversion",
18
22
  "x-amzn-bedrock-performanceconfig-latency",
19
23
  "x-amzn-bedrock-trace",
20
- // Cohere
21
- "x-client-name",
22
- // Vertex provisioned throughput / endpoint routing
24
+ // Google Vertex
25
+ "x-goog-api-client",
23
26
  "x-vertex-ai-endpoint-id",
24
27
  "x-vertex-ai-llm-request-type",
25
28
  "x-vertex-ai-llm-shared-request-type",
29
+ // Kilocode
30
+ "x-kilo-session",
31
+ "x-kilocode-taskid",
32
+ "x-kilocode-editorname",
33
+ "x-kilocode-feature",
34
+ "x-kilocode-machineid",
35
+ "x-kilocode-organizationid",
36
+ "x-kilocode-projectid",
37
+ "x-kilocode-tester",
38
+ // Agent / org / project / session ids
39
+ "agent-session-id",
40
+ "x-client",
41
+ "x-client-name",
42
+ "x-client-type",
43
+ "x-client-version",
44
+ "x-platform",
45
+ "x-platform-version",
46
+ "x-task-id",
47
+ // SDK / protocol identification
48
+ "x-stainless-arch",
49
+ "x-stainless-lang",
50
+ "x-stainless-os",
51
+ "x-stainless-package-version",
52
+ "x-stainless-runtime",
53
+ "x-stainless-runtime-version",
26
54
  ];
27
55
  const createRequestId = () => "req_" + crypto.getRandomValues(new Uint32Array(2)).reduce((s, n) => s + n.toString(36), "");
28
56
  export const resolveOrCreateRequestId = (request) => resolveRequestId(request) ?? createRequestId();
29
- export const prepareForwardHeaders = (request) => {
57
+ export const prepareForwardHeaders = (request, allowlist = FORWARD_HEADER_ALLOWLIST) => {
30
58
  const userAgent = request.headers.get("user-agent");
31
59
  const appendedUserAgent = userAgent
32
60
  ? `${userAgent} @hebo-ai/gateway/${GATEWAY_VERSION}`
@@ -34,7 +62,7 @@ export const prepareForwardHeaders = (request) => {
34
62
  const headers = {
35
63
  "user-agent": appendedUserAgent,
36
64
  };
37
- for (const key of FORWARD_HEADER_ALLOWLIST) {
65
+ for (const key of allowlist) {
38
66
  const value = request.headers.get(key);
39
67
  if (value !== null)
40
68
  headers[key] = value;