@axemere/gateway 0.1.8 → 0.1.10
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/README.md +1 -1
- package/dist/headers.d.ts +14 -0
- package/dist/headers.js +42 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ console.log(result.metering?.cost_usd); // "0.000042"
|
|
|
41
41
|
## Links
|
|
42
42
|
|
|
43
43
|
- [Axemere AI Gateway](https://axemere.ai)
|
|
44
|
-
- [Documentation](https://axemere.ai/docs)
|
|
44
|
+
- [Documentation](https://axemere.ai/docs/sdks/typescript)
|
|
45
45
|
- [GitHub](https://github.com/Axemere-LLC/axemere-node)
|
|
46
46
|
|
|
47
47
|
## License
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AiGatewayConfig } from "./config";
|
|
2
|
+
/** Placeholder API key passed to provider SDKs that require a non-empty key. The gateway ignores it. */
|
|
3
|
+
export declare const PLACEHOLDER_API_KEY = "axemere-proxy-managed";
|
|
4
|
+
/**
|
|
5
|
+
* Builds the standard Axemere AI Gateway request headers for proxy-mode requests.
|
|
6
|
+
*
|
|
7
|
+
* @param config - Gateway connection and attribution settings.
|
|
8
|
+
* @param opts.targetHost - Upstream provider hostname (e.g. `"api.openai.com"`).
|
|
9
|
+
* Required in proxy mode so the gateway knows where to forward the request.
|
|
10
|
+
* @returns A `Record<string, string>` of HTTP headers to merge into the outgoing request.
|
|
11
|
+
*/
|
|
12
|
+
export declare function aiGatewayHeaders(config: AiGatewayConfig, opts?: {
|
|
13
|
+
targetHost?: string;
|
|
14
|
+
}): Record<string, string>;
|
package/dist/headers.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PLACEHOLDER_API_KEY = void 0;
|
|
4
|
+
exports.aiGatewayHeaders = aiGatewayHeaders;
|
|
5
|
+
/** Placeholder API key passed to provider SDKs that require a non-empty key. The gateway ignores it. */
|
|
6
|
+
exports.PLACEHOLDER_API_KEY = "axemere-proxy-managed";
|
|
7
|
+
/**
|
|
8
|
+
* Builds the standard Axemere AI Gateway request headers for proxy-mode requests.
|
|
9
|
+
*
|
|
10
|
+
* @param config - Gateway connection and attribution settings.
|
|
11
|
+
* @param opts.targetHost - Upstream provider hostname (e.g. `"api.openai.com"`).
|
|
12
|
+
* Required in proxy mode so the gateway knows where to forward the request.
|
|
13
|
+
* @returns A `Record<string, string>` of HTTP headers to merge into the outgoing request.
|
|
14
|
+
*/
|
|
15
|
+
function aiGatewayHeaders(config, opts = {}) {
|
|
16
|
+
const headers = {};
|
|
17
|
+
if (config.gateway_token) {
|
|
18
|
+
headers["Authorization"] = `Bearer ${config.gateway_token}`;
|
|
19
|
+
}
|
|
20
|
+
if (opts.targetHost) {
|
|
21
|
+
headers["X-MVGC-Target-Host"] = opts.targetHost;
|
|
22
|
+
}
|
|
23
|
+
if (config.workload_id) {
|
|
24
|
+
headers["X-MVGC-Workload-ID"] = config.workload_id;
|
|
25
|
+
}
|
|
26
|
+
if (config.project_id) {
|
|
27
|
+
headers["X-MVGC-Project-ID"] = config.project_id;
|
|
28
|
+
}
|
|
29
|
+
if (config.account_id) {
|
|
30
|
+
headers["X-MVGC-Account-ID"] = config.account_id;
|
|
31
|
+
}
|
|
32
|
+
if (config.customer_id) {
|
|
33
|
+
headers["X-MVGC-Customer-ID"] = config.customer_id;
|
|
34
|
+
}
|
|
35
|
+
if (config.labels && Object.keys(config.labels).length > 0) {
|
|
36
|
+
headers["X-MVGC-Labels"] = JSON.stringify(config.labels);
|
|
37
|
+
}
|
|
38
|
+
if (config.provider_api_key) {
|
|
39
|
+
headers["X-MVGC-Provider-API-Key"] = config.provider_api_key;
|
|
40
|
+
}
|
|
41
|
+
return headers;
|
|
42
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { AiGatewayConfig } from "./config";
|
|
2
2
|
export type { AiGatewayOptions } from "./config";
|
|
3
|
+
export { PLACEHOLDER_API_KEY, aiGatewayHeaders } from "./headers";
|
|
3
4
|
export { AiGatewayClient } from "./client";
|
|
4
5
|
export { GatewayError, PolicyDeniedError, QuotaExceededError, GatewayTimeoutError } from "./errors";
|
|
5
6
|
export { PROVIDER_ROUTES } from "./providers";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PROVIDER_ROUTES = exports.GatewayTimeoutError = exports.QuotaExceededError = exports.PolicyDeniedError = exports.GatewayError = exports.AiGatewayClient = exports.AiGatewayConfig = void 0;
|
|
3
|
+
exports.PROVIDER_ROUTES = exports.GatewayTimeoutError = exports.QuotaExceededError = exports.PolicyDeniedError = exports.GatewayError = exports.AiGatewayClient = exports.aiGatewayHeaders = exports.PLACEHOLDER_API_KEY = exports.AiGatewayConfig = void 0;
|
|
4
4
|
var config_1 = require("./config");
|
|
5
5
|
Object.defineProperty(exports, "AiGatewayConfig", { enumerable: true, get: function () { return config_1.AiGatewayConfig; } });
|
|
6
|
+
var headers_1 = require("./headers");
|
|
7
|
+
Object.defineProperty(exports, "PLACEHOLDER_API_KEY", { enumerable: true, get: function () { return headers_1.PLACEHOLDER_API_KEY; } });
|
|
8
|
+
Object.defineProperty(exports, "aiGatewayHeaders", { enumerable: true, get: function () { return headers_1.aiGatewayHeaders; } });
|
|
6
9
|
var client_1 = require("./client");
|
|
7
10
|
Object.defineProperty(exports, "AiGatewayClient", { enumerable: true, get: function () { return client_1.AiGatewayClient; } });
|
|
8
11
|
var errors_1 = require("./errors");
|