@base44-preview/sdk 0.8.35-pr.213.b3debb7 → 0.8.35-pr.214.6a78f1b

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/client.js CHANGED
@@ -7,6 +7,7 @@ import { createConnectorsModule, createUserConnectorsModule, } from "./modules/c
7
7
  import { getAccessToken } from "./utils/auth-utils.js";
8
8
  import { createFunctionsModule } from "./modules/functions.js";
9
9
  import { createAgentsModule } from "./modules/agents.js";
10
+ import { createAiGatewayModule } from "./modules/ai-gateway.js";
10
11
  import { createAppLogsModule } from "./modules/app-logs.js";
11
12
  import { createUsersModule } from "./modules/users.js";
12
13
  import { RoomsSocket } from "./utils/socket-utils.js";
@@ -150,6 +151,7 @@ export function createClient(config) {
150
151
  serverUrl,
151
152
  token,
152
153
  }),
154
+ aiGateway: createAiGatewayModule({ serverUrl, token }),
153
155
  appLogs: createAppLogsModule(axiosClient, appId),
154
156
  users: createUsersModule(axiosClient, appId),
155
157
  analytics: createAnalyticsModule({
@@ -192,6 +194,7 @@ export function createClient(config) {
192
194
  serverUrl,
193
195
  token,
194
196
  }),
197
+ aiGateway: createAiGatewayModule({ serverUrl, token: serviceToken }),
195
198
  appLogs: createAppLogsModule(serviceRoleAxiosClient, appId),
196
199
  cleanup: () => {
197
200
  if (socket) {
@@ -5,6 +5,7 @@ import type { SsoModule } from "./modules/sso.types.js";
5
5
  import type { ConnectorsModule, UserConnectorsModule } from "./modules/connectors.types.js";
6
6
  import type { FunctionsModule } from "./modules/functions.types.js";
7
7
  import type { AgentsModule } from "./modules/agents.types.js";
8
+ import type { AiGatewayModule } from "./modules/ai-gateway.types.js";
8
9
  import type { AppLogsModule } from "./modules/app-logs.types.js";
9
10
  import type { AnalyticsModule } from "./modules/analytics.types.js";
10
11
  /**
@@ -81,6 +82,8 @@ export interface CreateClientConfig {
81
82
  export interface Base44Client {
82
83
  /** {@link AgentsModule | Agents module} for managing AI agent conversations. */
83
84
  agents: AgentsModule;
85
+ /** {@link AiGatewayModule | AI Gateway module} for connecting to the Base44 AI Gateway with your own SDK. */
86
+ aiGateway: AiGatewayModule;
84
87
  /** {@link AnalyticsModule | Analytics module} for tracking custom events in your app. */
85
88
  analytics: AnalyticsModule;
86
89
  /** {@link AppLogsModule | App logs module} for tracking app usage. */
@@ -124,6 +127,8 @@ export interface Base44Client {
124
127
  readonly asServiceRole: {
125
128
  /** {@link AgentsModule | Agents module} with elevated permissions. */
126
129
  agents: AgentsModule;
130
+ /** {@link AiGatewayModule | AI Gateway module} with the service-role token. */
131
+ aiGateway: AiGatewayModule;
127
132
  /** {@link AppLogsModule | App logs module} with elevated permissions. */
128
133
  appLogs: AppLogsModule;
129
134
  /** {@link ConnectorsModule | Connectors module} for OAuth token retrieval. */
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, Change
9
9
  export type { IntegrationsModule, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
10
10
  export type { FunctionsModule, FunctionName, FunctionNameRegistry, } from "./modules/functions.types.js";
11
11
  export type { AgentsModule, AgentName, AgentNameRegistry, AgentConversation, AgentMessage, AgentMessageReasoning, AgentMessageToolCall, AgentMessageUsage, AgentMessageCustomContext, AgentMessageMetadata, CreateConversationParams, } from "./modules/agents.types.js";
12
+ export type { AiGatewayModule, GatewayConnection, } from "./modules/ai-gateway.types.js";
12
13
  export type { AppLogsModule } from "./modules/app-logs.types.js";
13
14
  export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
14
15
  export type { ConnectorsModule, UserConnectorsModule, } from "./modules/connectors.types.js";
@@ -0,0 +1,2 @@
1
+ import { AiGatewayModule, AiGatewayModuleConfig } from "./ai-gateway.types.js";
2
+ export declare function createAiGatewayModule({ serverUrl, token, }: AiGatewayModuleConfig): AiGatewayModule;
@@ -0,0 +1,13 @@
1
+ import { getAccessToken } from "../utils/auth-utils.js";
2
+ export function createAiGatewayModule({ serverUrl, token, }) {
3
+ const connection = () => {
4
+ var _a;
5
+ return ({
6
+ baseURL: `${serverUrl}/api/ai/unified/v1`,
7
+ token: (_a = token !== null && token !== void 0 ? token : getAccessToken()) !== null && _a !== void 0 ? _a : "",
8
+ });
9
+ };
10
+ return {
11
+ connection,
12
+ };
13
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * A connection to the Base44 AI Gateway.
3
+ *
4
+ * Contains the base URL and bearer token to use with any OpenAI-compatible client
5
+ * (the OpenAI SDK, Mastra, and others) pointed at the Base44 AI Gateway.
6
+ */
7
+ export interface GatewayConnection {
8
+ /** Base URL of the gateway's OpenAI-compatible endpoint. */
9
+ baseURL: string;
10
+ /** Bearer token used to authenticate requests to the gateway. */
11
+ token: string;
12
+ }
13
+ /**
14
+ * Configuration for the AI Gateway module.
15
+ * @internal
16
+ */
17
+ export interface AiGatewayModuleConfig {
18
+ /** Server URL */
19
+ serverUrl?: string;
20
+ /** Authentication token */
21
+ token?: string;
22
+ }
23
+ /**
24
+ * The AI Gateway module.
25
+ *
26
+ * Exposes the connection details for the Base44 AI Gateway so you can call it from
27
+ * your own code using any OpenAI-compatible SDK — for example, to build a custom
28
+ * agent on top of the gateway.
29
+ */
30
+ export interface AiGatewayModule {
31
+ /**
32
+ * Gets the connection details for the Base44 AI Gateway.
33
+ *
34
+ * Returns the `baseURL` and `token` to pass to any OpenAI-compatible client (the
35
+ * OpenAI SDK, Mastra, and others), so you can call the gateway from your own code
36
+ * without constructing the URL or handling the token yourself.
37
+ *
38
+ * The `token` is the current caller's bearer token: the app user's token for
39
+ * `base44.aiGateway`, or the service-role token for `base44.asServiceRole.aiGateway`.
40
+ *
41
+ * @returns The gateway {@linkcode GatewayConnection | connection} (`baseURL` and `token`).
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * // Inside a backend function, call the gateway with any OpenAI-compatible SDK
46
+ * import { createClientFromRequest } from 'npm:@base44/sdk';
47
+ * import OpenAI from 'npm:openai';
48
+ *
49
+ * Deno.serve(async (req) => {
50
+ * const base44 = createClientFromRequest(req);
51
+ * const { baseURL, token } = base44.aiGateway.connection();
52
+ *
53
+ * const openai = new OpenAI({ baseURL, apiKey: token });
54
+ * const res = await openai.chat.completions.create({
55
+ * model: 'claude_sonnet_4_6',
56
+ * messages: [{ role: 'user', content: 'Hello!' }],
57
+ * });
58
+ * return Response.json({ text: res.choices[0].message.content });
59
+ * });
60
+ * ```
61
+ */
62
+ connection(): GatewayConnection;
63
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  export * from "./app.types.js";
2
2
  export * from "./agents.types.js";
3
+ export * from "./ai-gateway.types.js";
3
4
  export * from "./connectors.types.js";
4
5
  export * from "./analytics.types.js";
@@ -1,4 +1,5 @@
1
1
  export * from "./app.types.js";
2
2
  export * from "./agents.types.js";
3
+ export * from "./ai-gateway.types.js";
3
4
  export * from "./connectors.types.js";
4
5
  export * from "./analytics.types.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.35-pr.213.b3debb7",
3
+ "version": "0.8.35-pr.214.6a78f1b",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",