@agentuity/aigateway 2.0.15

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 ADDED
@@ -0,0 +1,50 @@
1
+ # @agentuity/aigateway
2
+
3
+ A standalone package for the Agentuity AI Gateway service.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @agentuity/aigateway
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { AIGatewayClient } from '@agentuity/aigateway';
15
+
16
+ const client = new AIGatewayClient();
17
+
18
+ const models = await client.listModels();
19
+ console.log(Object.keys(models));
20
+
21
+ const completion = await client.complete({
22
+ model: 'openai/gpt-4.1-mini',
23
+ messages: [{ role: 'user', content: 'Say hello' }],
24
+ });
25
+
26
+ console.log(completion.choices?.[0]);
27
+ ```
28
+
29
+ ## Configuration
30
+
31
+ ```typescript
32
+ const client = new AIGatewayClient({
33
+ apiKey: 'your-api-key',
34
+ orgId: 'your-org-id',
35
+ url: 'https://aigateway-usc.agentuity.cloud',
36
+ });
37
+ ```
38
+
39
+ ### Environment Variables
40
+
41
+ | Variable | Description | Default |
42
+ |----------|-------------|---------|
43
+ | `AGENTUITY_AIGATEWAY_KEY` | AI Gateway API key override | Optional |
44
+ | `AGENTUITY_SDK_KEY` | API key for authentication | Required |
45
+ | `AGENTUITY_REGION` | Region for API endpoints | `usc` |
46
+ | `AGENTUITY_AIGATEWAY_URL` | Override AI Gateway API URL | Auto-detected |
47
+
48
+ ## License
49
+
50
+ Apache-2.0
@@ -0,0 +1,18 @@
1
+ export { AIGatewayService, type AIGatewayChatCompletion, type AIGatewayChatCompletionParams, type AIGatewayChatMessage, type AIGatewayModel, type AIGatewayModelProvider, type AIGatewayModels, type AIGatewayModelsResponse, type AIGatewayPricing, AIGatewayChatCompletionParamsSchema, AIGatewayChatCompletionSchema, AIGatewayChatMessageSchema, AIGatewayModelProviderSchema, AIGatewayModelSchema, AIGatewayModelsResponseSchema, AIGatewayModelsSchema, AIGatewayPricingSchema, } from '@agentuity/core/aigateway';
2
+ import { type AIGatewayChatCompletion, type AIGatewayChatCompletionParams, type AIGatewayModels } from '@agentuity/core/aigateway';
3
+ import { type Logger } from '@agentuity/server';
4
+ import { z } from 'zod';
5
+ export declare const AIGatewayClientOptionsSchema: z.ZodObject<{
6
+ apiKey: z.ZodOptional<z.ZodString>;
7
+ url: z.ZodOptional<z.ZodString>;
8
+ orgId: z.ZodOptional<z.ZodString>;
9
+ logger: z.ZodOptional<z.ZodCustom<Logger, Logger>>;
10
+ }, z.core.$strip>;
11
+ export type AIGatewayClientOptions = z.infer<typeof AIGatewayClientOptionsSchema>;
12
+ export declare class AIGatewayClient {
13
+ #private;
14
+ constructor(options?: AIGatewayClientOptions);
15
+ listModels(): Promise<AIGatewayModels>;
16
+ complete(params: AIGatewayChatCompletionParams): Promise<AIGatewayChatCompletion>;
17
+ }
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,mCAAmC,EACnC,6BAA6B,EAC7B,0BAA0B,EAC1B,4BAA4B,EAC5B,oBAAoB,EACpB,6BAA6B,EAC7B,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAEN,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,eAAe,EACpB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAgD,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC9F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,4BAA4B;;;;;iBAKvC,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAElF,qBAAa,eAAe;;gBAGf,OAAO,GAAE,sBAA2B;IAqB1C,UAAU,IAAI,OAAO,CAAC,eAAe,CAAC;IAItC,QAAQ,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAGvF"}
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ export { AIGatewayService, AIGatewayChatCompletionParamsSchema, AIGatewayChatCompletionSchema, AIGatewayChatMessageSchema, AIGatewayModelProviderSchema, AIGatewayModelSchema, AIGatewayModelsResponseSchema, AIGatewayModelsSchema, AIGatewayPricingSchema, } from '@agentuity/core/aigateway';
2
+ import { AIGatewayService, } from '@agentuity/core/aigateway';
3
+ import { createMinimalLogger, getEnv } from '@agentuity/core';
4
+ import { getServiceUrls } from '@agentuity/core/config';
5
+ import { buildClientHeaders, createServerFetchAdapter } from '@agentuity/server';
6
+ import { z } from 'zod';
7
+ const isLogger = (val) => typeof val === 'object' &&
8
+ val !== null &&
9
+ ['info', 'warn', 'error', 'debug', 'trace'].every((m) => typeof val[m] === 'function');
10
+ export const AIGatewayClientOptionsSchema = z.object({
11
+ apiKey: z.string().optional().describe('API key for authentication'),
12
+ url: z.string().optional().describe('Base URL for the AI Gateway API'),
13
+ orgId: z.string().optional().describe('Organization ID for multi-tenant operations'),
14
+ logger: z.custom(isLogger).optional().describe('Custom logger instance'),
15
+ });
16
+ export class AIGatewayClient {
17
+ #service;
18
+ constructor(options = {}) {
19
+ const validatedOptions = AIGatewayClientOptionsSchema.parse(options);
20
+ const apiKey = validatedOptions.apiKey ||
21
+ getEnv('AGENTUITY_AIGATEWAY_KEY') ||
22
+ getEnv('AGENTUITY_SDK_KEY') ||
23
+ getEnv('AGENTUITY_CLI_KEY');
24
+ const region = getEnv('AGENTUITY_REGION') ?? 'usc';
25
+ const serviceUrls = getServiceUrls(region);
26
+ const url = validatedOptions.url || getEnv('AGENTUITY_AIGATEWAY_URL') || serviceUrls.aigateway;
27
+ const logger = validatedOptions.logger ?? createMinimalLogger();
28
+ const headers = buildClientHeaders({
29
+ apiKey,
30
+ orgId: validatedOptions.orgId,
31
+ });
32
+ const adapter = createServerFetchAdapter({ headers }, logger);
33
+ this.#service = new AIGatewayService(url, adapter);
34
+ }
35
+ async listModels() {
36
+ return this.#service.listModels();
37
+ }
38
+ async complete(params) {
39
+ return this.#service.complete(params);
40
+ }
41
+ }
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAShB,mCAAmC,EACnC,6BAA6B,EAC7B,0BAA0B,EAC1B,4BAA4B,EAC5B,oBAAoB,EACpB,6BAA6B,EAC7B,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,gBAAgB,GAIhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAe,MAAM,mBAAmB,CAAC;AAC9F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,QAAQ,GAAG,CAAC,GAAY,EAAiB,EAAE,CAChD,OAAO,GAAG,KAAK,QAAQ;IACvB,GAAG,KAAK,IAAI;IACZ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAChD,CAAC,CAAC,EAAE,EAAE,CAAC,OAAQ,GAA+B,CAAC,CAAC,CAAC,KAAK,UAAU,CAChE,CAAC;AAEH,MAAM,CAAC,MAAM,4BAA4B,GAAG,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AC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,UAAU;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAqC;QACnD,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;CACD"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@agentuity/aigateway",
3
+ "version": "2.0.15",
4
+ "license": "Apache-2.0",
5
+ "author": "Agentuity employees and contributors",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "AGENTS.md",
11
+ "README.md",
12
+ "src",
13
+ "dist"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "import": "./dist/index.js",
18
+ "types": "./dist/index.d.ts"
19
+ }
20
+ },
21
+ "scripts": {
22
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
23
+ "build": "bunx tsc --build --force",
24
+ "typecheck": "bunx tsc --noEmit",
25
+ "prepublishOnly": "bun run clean && bun run build"
26
+ },
27
+ "dependencies": {
28
+ "@agentuity/core": "2.0.15",
29
+ "@agentuity/server": "2.0.15",
30
+ "zod": "^4.3.5"
31
+ },
32
+ "devDependencies": {
33
+ "@types/bun": "latest",
34
+ "@types/node": "^22.0.0",
35
+ "bun-types": "latest",
36
+ "typescript": "^5.9.0"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "sideEffects": false
42
+ }
package/src/index.ts ADDED
@@ -0,0 +1,79 @@
1
+ export {
2
+ AIGatewayService,
3
+ type AIGatewayChatCompletion,
4
+ type AIGatewayChatCompletionParams,
5
+ type AIGatewayChatMessage,
6
+ type AIGatewayModel,
7
+ type AIGatewayModelProvider,
8
+ type AIGatewayModels,
9
+ type AIGatewayModelsResponse,
10
+ type AIGatewayPricing,
11
+ AIGatewayChatCompletionParamsSchema,
12
+ AIGatewayChatCompletionSchema,
13
+ AIGatewayChatMessageSchema,
14
+ AIGatewayModelProviderSchema,
15
+ AIGatewayModelSchema,
16
+ AIGatewayModelsResponseSchema,
17
+ AIGatewayModelsSchema,
18
+ AIGatewayPricingSchema,
19
+ } from '@agentuity/core/aigateway';
20
+
21
+ import {
22
+ AIGatewayService,
23
+ type AIGatewayChatCompletion,
24
+ type AIGatewayChatCompletionParams,
25
+ type AIGatewayModels,
26
+ } from '@agentuity/core/aigateway';
27
+ import { createMinimalLogger, getEnv } from '@agentuity/core';
28
+ import { getServiceUrls } from '@agentuity/core/config';
29
+ import { buildClientHeaders, createServerFetchAdapter, type Logger } from '@agentuity/server';
30
+ import { z } from 'zod';
31
+
32
+ const isLogger = (val: unknown): val is Logger =>
33
+ typeof val === 'object' &&
34
+ val !== null &&
35
+ ['info', 'warn', 'error', 'debug', 'trace'].every(
36
+ (m) => typeof (val as Record<string, unknown>)[m] === 'function'
37
+ );
38
+
39
+ export const AIGatewayClientOptionsSchema = z.object({
40
+ apiKey: z.string().optional().describe('API key for authentication'),
41
+ url: z.string().optional().describe('Base URL for the AI Gateway API'),
42
+ orgId: z.string().optional().describe('Organization ID for multi-tenant operations'),
43
+ logger: z.custom<Logger>(isLogger).optional().describe('Custom logger instance'),
44
+ });
45
+
46
+ export type AIGatewayClientOptions = z.infer<typeof AIGatewayClientOptionsSchema>;
47
+
48
+ export class AIGatewayClient {
49
+ readonly #service: AIGatewayService;
50
+
51
+ constructor(options: AIGatewayClientOptions = {}) {
52
+ const validatedOptions = AIGatewayClientOptionsSchema.parse(options);
53
+ const apiKey =
54
+ validatedOptions.apiKey ||
55
+ getEnv('AGENTUITY_AIGATEWAY_KEY') ||
56
+ getEnv('AGENTUITY_SDK_KEY') ||
57
+ getEnv('AGENTUITY_CLI_KEY');
58
+ const region = getEnv('AGENTUITY_REGION') ?? 'usc';
59
+ const serviceUrls = getServiceUrls(region);
60
+ const url =
61
+ validatedOptions.url || getEnv('AGENTUITY_AIGATEWAY_URL') || serviceUrls.aigateway;
62
+ const logger = validatedOptions.logger ?? createMinimalLogger();
63
+ const headers = buildClientHeaders({
64
+ apiKey,
65
+ orgId: validatedOptions.orgId,
66
+ });
67
+
68
+ const adapter = createServerFetchAdapter({ headers }, logger);
69
+ this.#service = new AIGatewayService(url, adapter);
70
+ }
71
+
72
+ async listModels(): Promise<AIGatewayModels> {
73
+ return this.#service.listModels();
74
+ }
75
+
76
+ async complete(params: AIGatewayChatCompletionParams): Promise<AIGatewayChatCompletion> {
77
+ return this.#service.complete(params);
78
+ }
79
+ }