@truefoundry/ai-gateway-sdk 0.0.7 → 0.0.8

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.
@@ -5946,8 +5946,14 @@
5946
5946
  "provider_accounts": {
5947
5947
  "$ref": "#/definitions/BudgetV2InNotInFilter"
5948
5948
  },
5949
+ "virtual_models": {
5950
+ "$ref": "#/definitions/BudgetV2InNotInFilter"
5951
+ },
5952
+ "virtual_provider_accounts": {
5953
+ "$ref": "#/definitions/BudgetV2InNotInFilter"
5954
+ },
5949
5955
  "metadata": {
5950
- "description": "+usage=Filter by metadata key-value pairs this budget applies to\n+label=Metadata\n+sort=4",
5956
+ "description": "+usage=Filter by metadata key-value pairs this budget applies to\n+label=Metadata\n+sort=6",
5951
5957
  "type": "object",
5952
5958
  "additionalProperties": {
5953
5959
  "$ref": "#/definitions/BudgetV2InNotInFilter"
@@ -5969,8 +5975,14 @@
5969
5975
  "provider_accounts": {
5970
5976
  "$ref": "#/definitions/BudgetV2InNotInFilter"
5971
5977
  },
5978
+ "virtual_models": {
5979
+ "$ref": "#/definitions/BudgetV2InNotInFilter"
5980
+ },
5981
+ "virtual_provider_accounts": {
5982
+ "$ref": "#/definitions/BudgetV2InNotInFilter"
5983
+ },
5972
5984
  "metadata": {
5973
- "description": "+usage=Filter by metadata key-value pairs this budget applies to\n+label=Metadata\n+sort=4",
5985
+ "description": "+usage=Filter by metadata key-value pairs this budget applies to\n+label=Metadata\n+sort=6",
5974
5986
  "type": "object",
5975
5987
  "additionalProperties": {
5976
5988
  "$ref": "#/definitions/BudgetV2InNotInFilter"
@@ -9899,6 +9911,80 @@
9899
9911
  },
9900
9912
  "$schema": "http://json-schema.org/draft-04/schema#"
9901
9913
  },
9914
+ "FireworksApiKeyAuth": {
9915
+ "description": "+label=Fireworks API Key Auth\n+usage=Authentication using a Fireworks API key",
9916
+ "type": "object",
9917
+ "required": ["type", "api_key"],
9918
+ "properties": {
9919
+ "type": {
9920
+ "description": "+value=api-key",
9921
+ "type": "string",
9922
+ "enum": ["api-key"]
9923
+ },
9924
+ "api_key": {
9925
+ "description": "+sort=100\n+usage=Fireworks API key (sent as a Bearer token). Create one in the Fireworks console.\n+message=API key must not be empty\n+uiType=SecretSelect\n+uiProps={\"isPassword\": true, \"enableNew\": true}",
9926
+ "type": "string",
9927
+ "pattern": "^\\S+$"
9928
+ }
9929
+ },
9930
+ "$schema": "http://json-schema.org/draft-04/schema#"
9931
+ },
9932
+ "FireworksGuardrailConfig": {
9933
+ "description": "+label=Fireworks\n+icon=https://assets.production.truefoundry.com/fireworks.svg",
9934
+ "type": "object",
9935
+ "required": ["name", "type", "auth_data", "operation", "enforcing_strategy", "config"],
9936
+ "properties": {
9937
+ "name": {
9938
+ "description": "+label=Name\n+sort=50\n+usage=The name of the Guardrail Config.\n+message=3 to 36 lower case characters long alphanumeric word, may contain - in between, cannot start with a number\n+uiProps={\"disableEdit\":true}",
9939
+ "type": "string",
9940
+ "pattern": "^[a-z][a-z0-9\\-]{1,34}[a-z0-9]$"
9941
+ },
9942
+ "description": {
9943
+ "description": "+label=Description\n+sort=75\n+usage=Optional description for this Guardrail Config.",
9944
+ "type": "string",
9945
+ "default": "Fireworks-hosted safety model (gpt-oss-safeguard or Llama Guard) for policy-based content classification"
9946
+ },
9947
+ "type": {
9948
+ "description": "+uiType=Hidden\n+value=integration/guardrail-config/fireworks",
9949
+ "type": "string",
9950
+ "enum": ["integration/guardrail-config/fireworks"]
9951
+ },
9952
+ "auth_data": {
9953
+ "$ref": "#/definitions/FireworksApiKeyAuth"
9954
+ },
9955
+ "operation": {
9956
+ "description": "+label=Operation\n+usage=Fireworks safety models classify content without modifying it.\n+uiType=MultiSelectPills\n+uiProps={\"hideRadioIcon\": true}\n+sort=100",
9957
+ "type": "string",
9958
+ "enum": ["validate"]
9959
+ },
9960
+ "enforcing_strategy": {
9961
+ "$ref": "#/definitions/EnforcingStrategy"
9962
+ },
9963
+ "config": {
9964
+ "description": "+uiType=Ignore\n+uiProps={\"forwardJsonKey\": true}",
9965
+ "type": "object",
9966
+ "required": ["model", "model_type"],
9967
+ "properties": {
9968
+ "model": {
9969
+ "description": "+label=Model\n+usage=Deployment name from your Fireworks account (accounts/<account>/deployments/<deployment>). Safety models run on dedicated (on-demand) deployments only.\n+message=Model must not be empty\n+sort=50",
9970
+ "type": "string",
9971
+ "pattern": "^\\S+$"
9972
+ },
9973
+ "model_type": {
9974
+ "description": "+label=Model Type\n+usage=gpt-oss-safeguard classifies content against the policy below. llama-guard classifies against Meta's fixed hazard categories (S1 to S14 for Llama Guard 3 8B) and ignores the policy.\n+uiType=Select\n+sort=100",
9975
+ "type": "string",
9976
+ "enum": ["gpt-oss-safeguard", "llama-guard"],
9977
+ "default": "gpt-oss-safeguard"
9978
+ },
9979
+ "policy": {
9980
+ "description": "+label=Policy\n+usage=Safety policy the model applies (required for gpt-oss-safeguard, ignored for llama-guard). Describe what violates and what is safe, with examples. Do not put secrets in the policy.\n+uiType=TextArea\n+uiProps={\"descriptionInline\":true}\n+sort=150",
9981
+ "type": "string"
9982
+ }
9983
+ }
9984
+ }
9985
+ },
9986
+ "$schema": "http://json-schema.org/draft-04/schema#"
9987
+ },
9902
9988
  "FlyteLaunchPlan": {
9903
9989
  "type": "object",
9904
9990
  "required": ["id", "spec", "closure"],
@@ -12728,6 +12814,12 @@
12728
12814
  },
12729
12815
  {
12730
12816
  "$ref": "#/definitions/HiddenLayerGuardrailConfig"
12817
+ },
12818
+ {
12819
+ "$ref": "#/definitions/FireworksGuardrailConfig"
12820
+ },
12821
+ {
12822
+ "$ref": "#/definitions/ZscalerAIGuardGuardrailConfig"
12731
12823
  }
12732
12824
  ],
12733
12825
  "$schema": "http://json-schema.org/draft-04/schema#"
@@ -21336,8 +21428,14 @@
21336
21428
  "provider_accounts": {
21337
21429
  "$ref": "#/definitions/RateLimitV2InNotInFilter"
21338
21430
  },
21431
+ "virtual_models": {
21432
+ "$ref": "#/definitions/RateLimitV2InNotInFilter"
21433
+ },
21434
+ "virtual_provider_accounts": {
21435
+ "$ref": "#/definitions/RateLimitV2InNotInFilter"
21436
+ },
21339
21437
  "metadata": {
21340
- "description": "+usage=Filter by metadata key-value pairs this rate limit applies to\n+label=Metadata\n+sort=4",
21438
+ "description": "+usage=Filter by metadata key-value pairs this rate limit applies to\n+label=Metadata\n+sort=6",
21341
21439
  "type": "object",
21342
21440
  "additionalProperties": {
21343
21441
  "$ref": "#/definitions/RateLimitV2InNotInFilter"
@@ -28411,6 +28509,83 @@
28411
28509
  "type": "string",
28412
28510
  "enum": ["cloudpickle", "joblib", "pickle", "json"],
28413
28511
  "$schema": "http://json-schema.org/draft-04/schema#"
28512
+ },
28513
+ "ZscalerAIGuardApiKeyAuth": {
28514
+ "description": "+label=Zscaler AI Guard API Key Auth",
28515
+ "type": "object",
28516
+ "required": ["type", "api_key"],
28517
+ "properties": {
28518
+ "type": {
28519
+ "description": "+value=api-key",
28520
+ "type": "string",
28521
+ "enum": ["api-key"]
28522
+ },
28523
+ "api_key": {
28524
+ "description": "+sort=100\n+usage=Zscaler AI Guard API key. Sent as a Bearer token against the AI Guard detection API.\n+message=API key must not be empty\n+uiType=SecretSelect\n+uiProps={\"isPassword\": true, \"enableNew\": true}",
28525
+ "type": "string",
28526
+ "pattern": "^\\S+$"
28527
+ }
28528
+ },
28529
+ "$schema": "http://json-schema.org/draft-04/schema#"
28530
+ },
28531
+ "ZscalerAIGuardGuardrailConfig": {
28532
+ "description": "+label=Zscaler AI Guard\n+icon=https://assets.production.truefoundry.com/zscaler.svg",
28533
+ "type": "object",
28534
+ "required": ["name", "type", "auth_data", "operation", "enforcing_strategy", "config"],
28535
+ "properties": {
28536
+ "name": {
28537
+ "description": "+label=Name\n+sort=50\n+usage=The name of the Guardrail Config.\n+message=3 to 36 lower case characters long alphanumeric word, may contain - in between, cannot start with a number\n+uiProps={\"disableEdit\":true}",
28538
+ "type": "string",
28539
+ "pattern": "^[a-z][a-z0-9\\-]{1,34}[a-z0-9]$"
28540
+ },
28541
+ "description": {
28542
+ "description": "+label=Description\n+sort=75\n+usage=Optional description for this Guardrail Config.",
28543
+ "type": "string",
28544
+ "default": "Zscaler AI Guard runtime protection for prompts and model responses"
28545
+ },
28546
+ "type": {
28547
+ "description": "+uiType=Hidden\n+value=integration/guardrail-config/zscaler-ai-guard",
28548
+ "type": "string",
28549
+ "enum": ["integration/guardrail-config/zscaler-ai-guard"]
28550
+ },
28551
+ "auth_data": {
28552
+ "$ref": "#/definitions/ZscalerAIGuardApiKeyAuth"
28553
+ },
28554
+ "operation": {
28555
+ "description": "+label=Operation\n+usage=Validate treats a Zscaler BLOCK action as a violation and leaves the payload unchanged. Mutate also replaces content with Zscaler maskedContent when returned.\nValidate guardrails are run in parallel while mutate guardrails are run sequentially.\n+uiType=MultiSelectPills\n+uiProps={\"hideRadioIcon\": true}\n+sort=100",
28556
+ "type": "string",
28557
+ "enum": ["validate", "mutate"],
28558
+ "default": "validate"
28559
+ },
28560
+ "priority": {
28561
+ "description": "+label=Priority\n+usage=Execution order for mutate guardrails. Lower values run first. Only applicable when operation is mutate.\n+sort=150",
28562
+ "type": "integer",
28563
+ "minimum": 0,
28564
+ "exclusiveMinimum": true,
28565
+ "default": 1
28566
+ },
28567
+ "enforcing_strategy": {
28568
+ "$ref": "#/definitions/EnforcingStrategy"
28569
+ },
28570
+ "config": {
28571
+ "description": "+uiType=Ignore\n+uiProps={\"forwardJsonKey\": true}",
28572
+ "type": "object",
28573
+ "properties": {
28574
+ "base_url": {
28575
+ "description": "+label=Base URL\n+usage=The AI Guard API base URL.\n+sort=100\n+message=Base URL must be an http or https URL",
28576
+ "type": "string",
28577
+ "pattern": "^https?:\\/\\/\\S+$"
28578
+ },
28579
+ "policy_id": {
28580
+ "description": "+label=Policy ID\n+usage=Optional AI Guard policy ID. When set, calls /v1/detection/execute-policy. When omitted, calls /v1/detection/resolve-and-execute-policy for automatic policy resolution.\n+sort=200",
28581
+ "type": "integer",
28582
+ "minimum": 0,
28583
+ "exclusiveMinimum": true
28584
+ }
28585
+ }
28586
+ }
28587
+ },
28588
+ "$schema": "http://json-schema.org/draft-04/schema#"
28414
28589
  }
28415
28590
  },
28416
28591
  "properties": {
@@ -29338,6 +29513,12 @@
29338
29513
  "FiddlerKeyAuth": {
29339
29514
  "$ref": "#/definitions/FiddlerKeyAuth"
29340
29515
  },
29516
+ "FireworksApiKeyAuth": {
29517
+ "$ref": "#/definitions/FireworksApiKeyAuth"
29518
+ },
29519
+ "FireworksGuardrailConfig": {
29520
+ "$ref": "#/definitions/FireworksGuardrailConfig"
29521
+ },
29341
29522
  "FlyteLaunchPlan": {
29342
29523
  "$ref": "#/definitions/FlyteLaunchPlan"
29343
29524
  },
@@ -31323,6 +31504,12 @@
31323
31504
  },
31324
31505
  "XGBoostSerializationFormat": {
31325
31506
  "$ref": "#/definitions/XGBoostSerializationFormat"
31507
+ },
31508
+ "ZscalerAIGuardApiKeyAuth": {
31509
+ "$ref": "#/definitions/ZscalerAIGuardApiKeyAuth"
31510
+ },
31511
+ "ZscalerAIGuardGuardrailConfig": {
31512
+ "$ref": "#/definitions/ZscalerAIGuardGuardrailConfig"
31326
31513
  }
31327
31514
  }
31328
31515
  }
@@ -37,10 +37,10 @@ const AnthropicAPIConfig = {
37
37
  const account = providerOptions.providerAccount.manifest;
38
38
  const storedApiKey = account.auth_data?.api_key;
39
39
  const apiKey = storedApiKey ?? callConfig.bearerTokenOverride;
40
- // pick auth header based on scheme(bearer or api-key). Match live: stored key → X-API-Key; subscription passthrough → Bearer.
41
- const headers = storedApiKey
42
- ? { 'X-API-Key': `${apiKey}` }
43
- : { Authorization: `Bearer ${apiKey}` };
40
+ // Anthropic documents `Authorization: Bearer` as the auth header and `x-api-key` as a legacy
41
+ // fallback. Bearer accepts both Console API keys and the short-lived Workload Identity
42
+ // Federation tokens from `POST /v1/oauth/token`; `x-api-key` rejects the latter outright.
43
+ const headers = { Authorization: `Bearer ${apiKey}` };
44
44
  const body = request.body;
45
45
  const { betaHeader, version } = resolveAnthropicBetaAndVersion({
46
46
  endpoint,
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/providers/anthropic/api.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,+BAA+B,EAAoC,MAAM,SAAS,CAAC;AAE5F,MAAM,cAAc,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,qBAAqB,CAAC,CAAC;AAExG,MAAM,CAAC,MAAM,yBAAyB,GAAG,YAAY,CAAC;AACtD,MAAM,CAAC,MAAM,6BAA6B,GAAG,qBAAqB,CAAC;AACnE,MAAM,CAAC,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAI5D;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAAC,EAC7C,QAAQ,EACR,eAAe,EACf,WAAW,GAKZ;IACC,8CAA8C;IAC9C,IAAI,iBAAiB,GAAG,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,6BAA6B,CAAC;IAElH,6FAA6F;IAC7F,IAAI,QAAQ,KAAK,cAAc,IAAI,WAAW,IAAI,mBAAmB,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5F,iBAAiB,GAAG,qBAAqB,CAAC;IAC5C,CAAC;IAED,8GAA8G;IAC9G,oFAAoF;IACpF,8DAA8D;IAC9D,MAAM,WAAW,GAAG,+BAA+B,CAAC,eAAe,EAAE,WAAW,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACtG,MAAM,UAAU,GAAG,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;IACnF,MAAM,OAAO,GAAG,eAAe,EAAE,gBAAgB,IAAI,WAAW,EAAE,CAAC,mBAAmB,CA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CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxE,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;QAEtD,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,UAAU;gBACb,OAAO,WAAW,CAAC;YACrB,KAAK,cAAc;gBACjB,OAAO,WAAW,CAAC;YACrB,KAAK,UAAU;gBACb,OAAO,WAAW,CAAC;YACrB,KAAK,qBAAqB;gBACxB,OAAO,wBAAwB,CAAC;YAClC,KAAK,YAAY;gBACf,OAAO,QAAQ,CAAC;YAClB,KAAK,WAAW;gBACd,OAAO,QAAQ,CAAC;YAClB,KAAK,cAAc;gBACjB,OAAO,UAAU,MAAM,EAAE,CAAC;YAC5B,KAAK,YAAY;gBACf,OAAO,UAAU,MAAM,EAAE,CAAC;YAC5B,KAAK,qBAAqB;gBACxB,OAAO,UAAU,MAAM,UAAU,CAAC;YACpC;gBACE,OAAO,EAAE,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -9,6 +9,8 @@ import { chatCompleteParams, completeParams, createModelResponseParams, embedPar
9
9
  import { OpenAILikeChatCompleteResponseTransform, OpenAILikeChatCompleteStreamChunkTransform, } from '../openai-like/chatComplete.js';
10
10
  import { OpenAILikeEmbedResponseTransform } from '../openai-like/embed.js';
11
11
  import TrueFoundryManagedAPIConfig from './api.js';
12
+ import { withInsufficientCreditError } from './insufficientCredit.js';
13
+ const { complete, ...baseResponseTransforms } = responseTransformers(TRUEFOUNDRY_MANAGED, { complete: true });
12
14
  const TrueFoundryManagedConfig = {
13
15
  chatComplete: chatCompleteParams([]),
14
16
  complete: completeParams([]),
@@ -16,10 +18,11 @@ const TrueFoundryManagedConfig = {
16
18
  embed: embedParams([]),
17
19
  api: TrueFoundryManagedAPIConfig,
18
20
  responseTransforms: {
19
- ...responseTransformers(TRUEFOUNDRY_MANAGED, { complete: true }),
20
- chatComplete: OpenAILikeChatCompleteResponseTransform(TRUEFOUNDRY_MANAGED),
21
- embed: OpenAILikeEmbedResponseTransform(TRUEFOUNDRY_MANAGED),
22
- createModelResponse: OpenAICreateModelResponseTransformer(TRUEFOUNDRY_MANAGED),
21
+ ...baseResponseTransforms,
22
+ complete: complete && withInsufficientCreditError(complete),
23
+ chatComplete: withInsufficientCreditError(OpenAILikeChatCompleteResponseTransform(TRUEFOUNDRY_MANAGED)),
24
+ embed: withInsufficientCreditError(OpenAILikeEmbedResponseTransform(TRUEFOUNDRY_MANAGED)),
25
+ createModelResponse: withInsufficientCreditError(OpenAICreateModelResponseTransformer(TRUEFOUNDRY_MANAGED)),
23
26
  'stream-chatComplete': OpenAILikeChatCompleteStreamChunkTransform(TRUEFOUNDRY_MANAGED),
24
27
  },
25
28
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/truefoundry-managed/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,yBAAyB,EACzB,WAAW,EACX,oCAAoC,EACpC,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,uCAAuC,EACvC,0CAA0C,GAC3C,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,2BAA2B,MAAM,OAAO,CAAC;AAEhD,MAAM,wBAAwB,GAAoB;IAChD,YAAY,EAAE,kBAAkB,CAAC,EAAE,CAAC;IACpC,QAAQ,EAAE,cAAc,CAAC,EAAE,CAAC;IAC5B,mBAAmB,EAAE,yBAAyB,CAAC,EAAE,CAAC;IAClD,KAAK,EAAE,WAAW,CAAC,EAAE,CA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B,GAAG,sBAAsB;QACzB,QAAQ,EAAE,QAAQ,IAAI,2BAA2B,CAAC,QAAQ,CAAC;QAC3D,YAAY,EAAE,2BAA2B,CAAC,uCAAuC,CAAC,mBAAmB,CAAC,CAAC;QACvG,KAAK,EAAE,2BAA2B,CAAC,gCAAgC,CAAC,mBAAmB,CAAC,CAAC;QACzF,mBAAmB,EAAE,2BAA2B,CAAC,oCAAoC,CAAC,mBAAmB,CAAC,CAAC;QAC3G,qBAAqB,EAAE,0CAA0C,CAAC,mBAAmB,CAAC;KACvF;CACF,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const INSUFFICIENT_CREDIT_ERROR: {
2
+ message: string;
3
+ type: string;
4
+ code: string;
5
+ };
6
+ export declare function withInsufficientCreditError(transform: Function): (response: unknown, responseStatus: number, ...rest: unknown[]) => any;
@@ -0,0 +1,20 @@
1
+ import { TRUEFOUNDRY_MANAGED } from '../../globals.js';
2
+ // The upstream budget is the tenant's TrueFoundry credit, so its rule and reset window stay hidden.
3
+ export const INSUFFICIENT_CREDIT_ERROR = {
4
+ message: "You've run out of credit for TrueFoundry Managed Models. Add credits to resume requests.",
5
+ type: 'insufficient_credit',
6
+ code: 'insufficient_credit',
7
+ };
8
+ const UPSTREAM_BUDGET_LIMIT_ORIGIN = 'budget_limit';
9
+ function isUpstreamBudgetLimit(response, responseStatus) {
10
+ return (responseStatus !== 200 &&
11
+ typeof response === 'object' &&
12
+ response !== null &&
13
+ response.error_origin_level === UPSTREAM_BUDGET_LIMIT_ORIGIN);
14
+ }
15
+ export function withInsufficientCreditError(transform) {
16
+ return (response, responseStatus, ...rest) => isUpstreamBudgetLimit(response, responseStatus)
17
+ ? { error: { ...INSUFFICIENT_CREDIT_ERROR }, provider: TRUEFOUNDRY_MANAGED }
18
+ : transform(response, responseStatus, ...rest);
19
+ }
20
+ //# sourceMappingURL=insufficientCredit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insufficientCredit.js","sourceRoot":"","sources":["../../../src/providers/truefoundry-managed/insufficientCredit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,oGAAoG;AACpG,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,OAAO,EAAE,0FAA0F;IACnG,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,qBAAqB;CAC5B,CAAC;AAEF,MAAM,4BAA4B,GAAG,cAAc,CAAC;AAEpD,SAAS,qBAAqB,CAAC,QAAiB,EAAE,cAAsB;IACtE,OAAO,CACL,cAAc,KAAK,GAAG;QACtB,OAAO,QAAQ,KAAK,QAAQ;QAC5B,QAAQ,KAAK,IAAI;QAChB,QAA6C,CAAC,kBAAkB,KAAK,4BAA4B,CACnG,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,SAAmB;IAC7D,OAAO,CAAC,QAAiB,EAAE,cAAsB,EAAE,GAAG,IAAe,EAAE,EAAE,CACvE,qBAAqB,CAAC,QAAQ,EAAE,cAAc,CAAC;QAC7C,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,GAAG,yBAAyB,EAAE,EAAE,QAAQ,EAAE,mBAAmB,EAAE;QAC5E,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,CAAC;AACrD,CAAC"}
@@ -190,8 +190,6 @@ export interface Options {
190
190
  anthropicBetaSuppressed?: boolean;
191
191
  anthropicVersion?: string;
192
192
  anthropicApiKey?: string;
193
- /** `'api-key'` -> `X-API-Key`, `'bearer'` -> `Authorization: Bearer`. */
194
- anthropicAuthScheme?: 'api-key' | 'bearer';
195
193
  /** Claude Platform on AWS workspace id, sent as the `anthropic-workspace-id` header. */
196
194
  awsClaudePlatformWorkspaceId?: string;
197
195
  /** Fireworks finetune required fields */
@@ -1 +1 @@
1
- {"version":3,"file":"requestBody.js","sourceRoot":"","sources":["../../src/types/requestBody.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAwBH,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,4CAA2B,CAAA;IAC3B,sCAAqB,CAAA;IACrB,kCAAiB,CAAA;IACjB,4CAA2B,CAAA;AAC7B,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB;AAyVD,MAAM,CAAN,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,8BAAa,CAAA;IACb,wCAAuB,CAAA;IACvB,sCAAqB,CAAA;IACrB,8BAAa,CAAA;IACb,wCAAuB,CAAA;AACzB,CAAC,EAPW,aAAa,KAAb,aAAa,QAOxB;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC"}
1
+ {"version":3,"file":"requestBody.js","sourceRoot":"","sources":["../../src/types/requestBody.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAwBH,MAAM,CAAN,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,4CAA2B,CAAA;IAC3B,sCAAqB,CAAA;IACrB,kCAAiB,CAAA;IACjB,4CAA2B,CAAA;AAC7B,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB;AAuVD,MAAM,CAAN,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,8BAAa,CAAA;IACb,wCAAuB,CAAA;IACvB,sCAAqB,CAAA;IACrB,8BAAa,CAAA;IACb,wCAAuB,CAAA;AACzB,CAAC,EAPW,aAAa,KAAb,aAAa,QAOxB;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truefoundry/ai-gateway-sdk",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "LLM provider translation SDK",
5
5
  "author": "Truefoundry",
6
6
  "license": "UNLICENSED",