Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: add openai app connection

adilson371573d4073a
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 5518bb22ff..da57f38cc9 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -2922,6 +2922,9 @@ export const AppConnections = {
OPEN_ROUTER: {
apiKey: "The OpenRouter Provisioning API key used to manage API keys."
},
+ OPENAI: {
+ apiKey: "The OpenAI Admin API key used to manage API keys."
+ },
ANTHROPIC: {
apiKey: "The Anthropic API key used to authenticate with the Anthropic API."
},
diff --git a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
index 7e991ffdd1..779ac5e6a0 100644
--- a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
@@ -166,6 +166,7 @@ import {
OpenRouterConnectionListItemSchema,
SanitizedOpenRouterConnectionSchema
} from "@app/services/app-connection/open-router";
+import { OpenAIConnectionListItemSchema, SanitizedOpenAIConnectionSchema } from "@app/services/app-connection/openai";
import { OvhConnectionListItemSchema, SanitizedOvhConnectionSchema } from "@app/services/app-connection/ovh";
import {
PostgresConnectionListItemSchema,
@@ -280,6 +281,7 @@ const SanitizedAppConnectionSchema = z.union([
...SanitizedSshConnectionSchema.options,
...SanitizedDbtConnectionSchema.options,
...SanitizedOpenRouterConnectionSchema.options,
+ ...SanitizedOpenAIConnectionSchema.options,
...SanitizedAnthropicConnectionSchema.options,
...SanitizedDevinConnectionSchema.options,
...SanitizedAzureEntraIdConnectionSchema.options,
@@ -356,6 +358,7 @@ const AppConnectionOptionsSchema = z.discriminatedUnion("app", [
SshConnectionListItemSchema,
DbtConnectionListItemSchema,
OpenRouterConnectionListItemSchema,
+ OpenAIConnectionListItemSchema,
AzureEntraIdConnectionListItemSchema,
VenafiConnectionListItemSchema,
VenafiTppConnectionListItemSchema,
diff --git a/backend/src/server/routes/v1/app-connection-routers/index.ts b/backend/src/server/routes/v1/app-connection-routers/index.ts
index 360015696a..34fd2ec36b 100644
--- a/backend/src/server/routes/v1/app-connection-routers/index.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/index.ts
@@ -53,6 +53,7 @@ import { registerOctopusDeployConnectionRouter } from "./octopus-deploy-connecti
import { registerOktaConnectionRouter } from "./okta-connection-router";
import { registerOnaConnectionRouter } from "./ona-connection-router";
import { registerOpenRouterConnectionRouter } from "./open-router-connection-router";
+import { registerOpenAIConnectionRouter } from "./openai-connection-router";
import { registerOvhConnectionRouter } from "./ovh-connection-router";
import { registerPostgresConnectionRouter } from "./postgres-connection-router";
import { registerQoveryConnectionRouter } from "./qovery-connection-router";
@@ -129,6 +130,7 @@ export const APP_CONNECTION_REGISTER_ROUTER_MAP: Record<AppConnection, (server:
[AppConnection.Dbt]: registerDbtConnectionRouter,
[AppConnection.SMB]: registerSmbConnectionRouter,
[AppConnection.OpenRouter]: registerOpenRouterConnectionRouter,
+ [AppConnection.OpenAI]: registerOpenAIConnectionRouter,
[AppConnection.CircleCI]: registerCircleCIConnectionRouter,
[AppConnection.Cloud66]: registerCloud66ConnectionRouter,
[AppConnection.AzureEntraId]: registerAzureEntraIdConnectionRouter,
diff --git a/backend/src/server/routes/v1/app-connection-routers/openai-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/openai-connection-router.ts
new file mode 100644
index 0000000000..19b09b55b0
--- /dev/null
+++ b/backend/src/server/routes/v1/app-connection-routers/openai-connection-router.ts
@@ -0,0 +1,18 @@
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+import {
+ CreateOpenAIConnectionSchema,
+ SanitizedOpenAIConnectionSchema,
+ UpdateOpenAIConnectionSchema
+} from "@app/services/app-connection/openai";
+
+import { registerAppConnectionEndpoints } from "./app-connection-endpoints";
+
+export const registerOpenAIConnectionRouter = async (server: FastifyZodProvider) => {
+ registerAppConnectionEndpoints({
+ app: AppConnection.OpenAI,
+ server,
+ sanitizedResponseSchema: SanitizedOpenAIConnectionSchema,
+ createSchema: CreateOpenAIConnectionSchema,
+ updateSchema: UpdateOpenAIConnectionSchema
+ });
+};
diff --git a/backend/src/services/app-connection/app-connection-enums.ts b/backend/src/services/app-connection/app-connection-enums.ts
index 8103a45f21..d7c3dac2d5 100644
--- a/backend/src/services/app-connection/app-connection-enums.ts
+++ b/backend/src/services/app-connection/app-connection-enums.ts
@@ -50,6 +50,7 @@ export enum AppConnection {
Dbt = "dbt",
SMB = "smb",
OpenRouter = "open-router",
+ OpenAI = "openai",
CircleCI = "circleci",
AzureEntraId = "azure-entra-id",
Venafi = "venafi",
diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.ts
index 167866aa49..a7b37826ab 100644
--- a/backend/src/services/app-connection/app-connection-fns.ts
+++ b/backend/src/services/app-connection/app-connection-fns.ts
@@ -214,6 +214,7 @@ import {
OpenRouterConnectionMethod,
validateOpenRouterConnectionCredentials
} from "./open-router";
+import { getOpenAIConnectionListItem, OpenAIConnectionMethod, validateOpenAIConnectionCredentials } from "./openai";
import { getOvhConnectionListItem, OVHConnectionMethod, validateOvhConnectionCredentials } from "./ovh";
import { getPostgresConnectionListItem, PostgresConnectionMethod } from "./postgres";
import { getQoveryConnectionListItem, QoveryConnectionMethod, validateQoveryConnectionCredentials } from "./qovery";
@@ -357,6 +358,7 @@ export const listAppConnectionOptions = (projectType?: ProjectType) => {
getDbtConnectionListItem(),
getSmbConnectionListItem(),
getOpenRouterConnectionListItem(),
+ getOpenAIConnectionListItem(),
getAnthropicConnectionListItem(),
getDevinConnectionListItem(),
getCircleCIConnectionListItem(),
@@ -593,6 +595,7 @@ export const validateAppConnectionCredentials = async (
[AppConnection.Dbt]: validateDbtConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.SMB]: validateSmbConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.OpenRouter]: validateOpenRouterConnectionCredentials as TAppConnectionCredentialsValidator,
+ [AppConnection.OpenAI]: validateOpenAIConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.Anthropic]: validateAnthropicConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.Devin]: validateDevinConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.CircleCI]: validateCircleCIConnectionCredentials as TAppConnectionCredentialsValidator,
@@ -714,6 +717,7 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>
case ChecklyConnectionMethod.ApiKey:
case OctopusDeployConnectionMethod.ApiKey:
case OpenRouterConnectionMethod.ApiKey:
+ case OpenAIConnectionMethod.ApiKey:
case AnthropicConnectionMethod.ApiKey:
case DevinConnectionMethod.ApiKey:
case DigiCertConnectionMethod.ApiKey:
@@ -850,6 +854,7 @@ export const TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM: Record<
[AppConnection.Dbt]: platformManagedCredentialsNotSupported,
[AppConnection.SMB]: platformManagedCredentialsNotSupported,
[AppConnection.OpenRouter]: platformManagedCredentialsNotSupported,
+ [AppConnection.OpenAI]: platformManagedCredentialsNotSupported,
[AppConnection.Anthropic]: platformManagedCredentialsNotSupported,
[AppConnection.Devin]: platformManagedCredentialsNotSupported,
[AppConnection.CircleCI]: platformManagedCredentialsNotSupported,
diff --git a/backend/src/services/app-connection/app-connection-maps.ts b/backend/src/services/app-connection/app-connection-maps.ts
index 21e4a9a999..3690453723 100644
--- a/backend/src/services/app-connection/app-connection-maps.ts
+++ b/backend/src/services/app-connection/app-connection-maps.ts
@@ -52,6 +52,7 @@ export const APP_CONNECTION_NAME_MAP: Record<AppConnection, string> = {
[AppConnection.Dbt]: "DBT",
[AppConnection.SMB]: "SMB",
[AppConnection.OpenRouter]: "OpenRouter",
+ [AppConnection.OpenAI]: "OpenAI",
[AppConnection.CircleCI]: "CircleCI",
[AppConnection.AzureEntraId]: "Azure Entra ID",
[AppConnection.Venafi]: "Venafi TLS Protect Cloud",
@@ -128,6 +129,7 @@ export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanTyp
[AppConnection.Dbt]: AppConnectionPlanType.Regular,
[AppConnection.SMB]: AppConnectionPlanType.Regular,
[AppConnection.OpenRouter]: AppConnectionPlanType.Regular,
+ [AppConnection.OpenAI]: AppConnectionPlanType.Regular,
[AppConnection.CircleCI]: AppConnectionPlanType.Regular,
[AppConnection.AzureEntraId]: AppConnectionPlanType.Regular,
[AppConnection.Venafi]: AppConnectionPlanType.Regular,
diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.ts
index 780eafcd80..58ce98cbcf 100644
--- a/backend/src/services/app-connection/app-connection-service.ts
+++ b/backend/src/services/app-connection/app-connection-service.ts
@@ -145,6 +145,7 @@ import { oktaConnectionService } from "./okta/okta-connection-service";
import { ValidateOnaConnectionCredentialsSchema } from "./ona";
import { onaConnectionService } from "./ona/ona-connection-service";
import { ValidateOpenRouterConnectionCredentialsSchema } from "./open-router";
+import { ValidateOpenAIConnectionCredentialsSchema } from "./openai";
import { ValidateOvhConnectionCredentialsSchema } from "./ovh";
import { ValidatePostgresConnectionCredentialsSchema } from "./postgres";
import { ValidateQoveryConnectionCredentialsSchema } from "./qovery";
@@ -248,6 +249,7 @@ const VALIDATE_APP_CONNECTION_CREDENTIALS_MAP: Record<AppConnection, TValidateAp
[AppConnection.Northflank]: ValidateNorthflankConnectionCredentialsSchema,
[AppConnection.Okta]: ValidateOktaConnectionCredentialsSchema,
[AppConnection.OpenRouter]: ValidateOpenRouterConnectionCredentialsSchema,
+ [AppConnection.OpenAI]: ValidateOpenAIConnectionCredentialsSchema,
[AppConnection.Redis]: ValidateRedisConnectionCredentialsSchema,
[AppConnection.MongoDB]: ValidateMongoDBConnectionCredentialsSchema,
[AppConnection.Chef]: ValidateChefConnectionCredentialsSchema,
diff --git a/backend/src/services/app-connection/app-connection-types.ts b/backend/src/services/app-connection/app-connection-types.ts
index 4cf6b7375b..dbf8d20bd3 100644
--- a/backend/src/services/app-connection/app-connection-types.ts
+++ b/backend/src/services/app-connection/app-connection-types.ts
@@ -312,6 +312,12 @@ import {
TOpenRouterConnectionInput,
TValidateOpenRouterConnectionCredentialsSchema
} from "./open-router";
+import {
+ TOpenAIConnection,
+ TOpenAIConnectionConfig,
+ TOpenAIConnectionInput,
+ TValidateOpenAIConnectionCredentialsSchema
+} from "./openai";
import {
TOvhConnection,
TOvhConnectionConfig,
@@ -486,6 +492,7 @@ export type TAppConnection = { id: string; configuration?: TAppConnectionConfigu
| TDbtConnection
| TSmbConnection
| TOpenRouterConnection
+ | TOpenAIConnection
| TCircleCIConnection
| TCloud66Connection
| TAzureEntraIdConnection
@@ -570,6 +577,7 @@ export type TAppConnectionInput = { id: string } & (
| TDbtConnectionInput
| TSmbConnectionInput
| TOpenRouterConnectionInput
+ | TOpenAIConnectionInput
| TCircleCIConnectionInput
| TCloud66ConnectionInput
| TAzureEntraIdConnectionInput
@@ -686,6 +694,7 @@ export type TAppConnectionConfig =
| TDbtConnectionConfig
| TSmbConnectionConfig
| TOpenRouterConnectionConfig
+ | TOpenAIConnectionConfig
| TCircleCIConnectionConfig
| TCloud66ConnectionConfig
| TAzureEntraIdConnectionConfig
@@ -761,6 +770,7 @@ export type TValidateAppConnectionCredentialsSchema =
| TValidateDbtConnectionCredentialsSchema
| TValidateSmbConnectionCredentialsSchema
| TValidateOpenRouterConnectionCredentialsSchema
+ | TValidateOpenAIConnectionCredentialsSchema
| TValidateCircleCIConnectionCredentialsSchema
| TValidateCloud66ConnectionCredentialsSchema
| TValidateAzureEntraIdConnectionCredentialsSchema
diff --git a/backend/src/services/app-connection/openai/index.ts b/backend/src/services/app-connection/openai/index.ts
new file mode 100644
index 0000000000..80b1d485c5
--- /dev/null
+++ b/backend/src/services/app-connection/openai/index.ts
@@ -0,0 +1,4 @@
+export * from "./openai-connection-enums";
+export * from "./openai-connection-fns";
+export * from "./openai-connection-schemas";
+export * from "./openai-connection-types";
diff --git a/backend/src/services/app-connection/openai/openai-connection-enums.ts b/backend/src/services/app-connection/openai/openai-connection-enums.ts
new file mode 100644
index 0000000000..958a7b5906
--- /dev/null
+++ b/backend/src/services/app-connection/openai/openai-connection-enums.ts
@@ -0,0 +1,3 @@
+export enum OpenAIConnectionMethod {
+ ApiKey = "api-key"
+}
diff --git a/backend/src/services/app-connection/openai/openai-connection-fns.ts b/backend/src/services/app-connection/openai/openai-connection-fns.ts
new file mode 100644
index 0000000000..ec3bc7c008
--- /dev/null
+++ b/backend/src/services/app-connection/openai/openai-connection-fns.ts
@@ -0,0 +1,37 @@
+import { request } from "@app/lib/config/request";
+import { UnauthorizedError } from "@app/lib/errors";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+
+import { OpenAIConnectionMethod } from "./openai-connection-enums";
+import { TOpenAIConnectionConfig } from "./openai-connection-types";
+
+export const OPENAI_API_BASE_URL = "https://api.openai.com/v1";
+
+export const getOpenAIConnectionListItem = () => {
+ return {
+ name: "OpenAI" as const,
+ app: AppConnection.OpenAI as const,
+ methods: Object.values(OpenAIConnectionMethod) as [OpenAIConnectionMethod.ApiKey]
+ };
+};
+
+export const validateOpenAIConnectionCredentials = async (config: TOpenAIConnectionConfig) => {
+ const { apiKey } = config.credentials;
+
+ try {
+ // Validate by listing admin API keys (requires a valid admin key)
+ await request.get(`${OPENAI_API_BASE_URL}/organization/admin_api_keys?limit=1`, {
+ headers: {
+ Authorization: `Bearer ${apiKey}`,
+ "Content-Type": "application/json"
+ },
+ validateStatus: (status) => status === 200
+ });
+ } catch (error: unknown) {
+ throw new UnauthorizedError({
+ message: "Unable to validate connection: invalid API key or insufficient permissions"
+ });
+ }
+
+ return config.credentials;
+};
diff --git a/backend/src/services/app-connection/openai/openai-connection-schemas.ts b/backend/src/services/app-connection/openai/openai-connection-schemas.ts
new file mode 100644
index 0000000000..cb098b9a15
--- /dev/null
+++ b/backend/src/services/app-connection/openai/openai-connection-schemas.ts
@@ -0,0 +1,59 @@
+import z from "zod";
+
+import { AppConnections } from "@app/lib/api-docs";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+import {
+ BaseAppConnectionSchema,
+ GenericCreateAppConnectionFieldsSchema,
+ GenericUpdateAppConnectionFieldsSchema
+} from "@app/services/app-connection/app-connection-schemas";
+
+import { APP_CONNECTION_NAME_MAP } from "../app-connection-maps";
+import { OpenAIConnectionMethod } from "./openai-connection-enums";
+
+export const OpenAIConnectionApiKeyCredentialsSchema = z.object({
+ apiKey: z.string().trim().min(1, "API Key required").describe(AppConnections.CREDENTIALS.OPENAI.apiKey)
+});
+
+const BaseOpenAIConnectionSchema = BaseAppConnectionSchema.extend({ app: z.literal(AppConnection.OpenAI) });
+
+export const OpenAIConnectionSchema = BaseOpenAIConnectionSchema.extend({
+ method: z.literal(OpenAIConnectionMethod.ApiKey),
+ credentials: OpenAIConnectionApiKeyCredentialsSchema
+});
+
+export const SanitizedOpenAIConnectionSchema = z.discriminatedUnion("method", [
+ BaseOpenAIConnectionSchema.extend({
+ method: z.literal(OpenAIConnectionMethod.ApiKey),
+ credentials: z.object({})
+ }).describe(JSON.stringify({ title: `${APP_CONNECTION_NAME_MAP[AppConnection.OpenAI]} (API Key)` }))
+]);
+
+export const ValidateOpenAIConnectionCredentialsSchema = z.discriminatedUnion("method", [
+ z.object({
+ method: z.literal(OpenAIConnectionMethod.ApiKey).describe(AppConnections.CREATE(AppConnection.OpenAI).method),
+ credentials: OpenAIConnectionApiKeyCredentialsSchema.describe(
+ AppConnections.CREATE(AppConnection.OpenAI).credentials
+ )
+ })
+]);
+
+export const CreateOpenAIConnectionSchema = ValidateOpenAIConnectionCredentialsSchema.and(
+ GenericCreateAppConnectionFieldsSchema(AppConnection.OpenAI)
+);
+
+export const UpdateOpenAIConnectionSchema = z
+ .object({
+ credentials: OpenAIConnectionApiKeyCredentialsSchema.optional().describe(
+ AppConnections.UPDATE(AppConnection.OpenAI).credentials
+ )
+ })
+ .and(GenericUpdateAppConnectionFieldsSchema(AppConnection.OpenAI));
+
+export const OpenAIConnectionListItemSchema = z
+ .object({
+ name: z.literal("OpenAI"),
+ app: z.literal(AppConnection.OpenAI),
+ methods: z.nativeEnum(OpenAIConnectionMethod).array()
+ })
+ .describe(JSON.stringify({ title: APP_CONNECTION_NAME_MAP[AppConnection.OpenAI] }));
diff --git a/backend/src/services/app-connection/openai/openai-connection-types.ts b/backend/src/services/app-connection/openai/openai-connection-types.ts
new file mode 100644
index 0000000000..74edaf0dd8
--- /dev/null
+++ b/backend/src/services/app-connection/openai/openai-connection-types.ts
@@ -0,0 +1,22 @@
+import z from "zod";
+
+import { DiscriminativePick } from "@app/lib/types";
+
+import { AppConnection } from "../app-connection-enums";
+import {
+ CreateOpenAIConnectionSchema,
+ OpenAIConnectionSchema,
+ ValidateOpenAIConnectionCredentialsSchema
+} from "./openai-connection-schemas";
+
+export type TOpenAIConnection = z.infer<typeof OpenAIConnectionSchema>;
+
+export type TOpenAIConnectionInput = z.infer<typeof CreateOpenAIConnectionSchema> & {
+ app: AppConnection.OpenAI;
+};
+
+export type TValidateOpenAIConnectionCredentialsSchema = typeof ValidateOpenAIConnectionCredentialsSchema;
+
+export type TOpenAIConnectionConfig = DiscriminativePick<TOpenAIConnectionInput, "method" | "app" | "credentials"> & {
+ orgId: string;
+};
diff --git a/frontend/public/images/integrations/OpenAI.png b/frontend/public/images/integrations/OpenAI.png
new file mode 100644
index 0000000000..270980dba6
Binary files /dev/null and b/frontend/public/images/integrations/OpenAI.png differ
diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.ts
index a63e152398..9e69d50aed 100644
--- a/frontend/src/helpers/appConnections.ts
+++ b/frontend/src/helpers/appConnections.ts
@@ -75,6 +75,7 @@ import { NetScalerConnectionMethod } from "@app/hooks/api/appConnections/types/n
import { NorthflankConnectionMethod } from "@app/hooks/api/appConnections/types/northflank-connection";
import { OCIConnectionMethod } from "@app/hooks/api/appConnections/types/oci-connection";
import { OnaConnectionMethod } from "@app/hooks/api/appConnections/types/ona-connection";
+import { OpenAIConnectionMethod } from "@app/hooks/api/appConnections/types/open-ai-connection";
import { OpenRouterConnectionMethod } from "@app/hooks/api/appConnections/types/open-router-connection";
import { OVHConnectionMethod } from "@app/hooks/api/appConnections/types/ovh-connection";
import { RailwayConnectionMethod } from "@app/hooks/api/appConnections/types/railway-connection";
@@ -413,6 +414,12 @@ export const APP_CONNECTION_MAP: Record<
category: "AI",
description: "Route requests across LLM providers."
},
+ [AppConnection.OpenAI]: {
+ name: "OpenAI",
+ image: "OpenAI.png",
+ category: "AI",
+ description: "Manage OpenAI API access."
+ },
[AppConnection.CircleCI]: {
name: "CircleCI",
image: "CircleCI.png",
@@ -650,6 +657,7 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])
case RenderConnectionMethod.ApiKey:
case ChecklyConnectionMethod.ApiKey:
case OpenRouterConnectionMethod.ApiKey:
+ case OpenAIConnectionMethod.ApiKey:
case AnthropicConnectionMethod.ApiKey:
case DevinConnectionMethod.ApiKey:
case DigiCertConnectionMethod.ApiKey:
diff --git a/frontend/src/hooks/api/appConnections/enums.ts b/frontend/src/hooks/api/appConnections/enums.ts
index 9a35cf11ee..56246ed24b 100644
--- a/frontend/src/hooks/api/appConnections/enums.ts
+++ b/frontend/src/hooks/api/appConnections/enums.ts
@@ -49,6 +49,7 @@ export enum AppConnection {
Dbt = "dbt",
SMB = "smb",
OpenRouter = "open-router",
+ OpenAI = "openai",
CircleCI = "circleci",
AzureEntraId = "azure-entra-id",
Venafi = "venafi",
diff --git a/frontend/src/hooks/api/appConnections/types/app-options.ts b/frontend/src/hooks/api/appConnections/types/app-options.ts
index 6541fa1c2e..3711a32ec3 100644
--- a/frontend/src/hooks/api/appConnections/types/app-options.ts
+++ b/frontend/src/hooks/api/appConnections/types/app-options.ts
@@ -224,6 +224,10 @@ export type TOpenRouterConnectionOption = TAppConnectionOptionBase & {
app: AppConnection.OpenRouter;
};
+export type TOpenAIConnectionOption = TAppConnectionOptionBase & {
+ app: AppConnection.OpenAI;
+};
+
export type TCircleCISyncConnectionOption = TAppConnectionOptionBase & {
app: AppConnection.CircleCI;
};
@@ -346,6 +350,7 @@ export type TAppConnectionOption =
| TNorthflankConnectionOption
| TOktaConnectionOption
| TOpenRouterConnectionOption
+ | TOpenAIConnectionOption
| TCircleCISyncConnectionOption
| TCloud66ConnectionOption
| TAzureAdCsConnectionOption
@@ -422,6 +427,7 @@ export type TAppConnectionOptionMap = {
[AppConnection.Northflank]: TNorthflankConnectionOption;
[AppConnection.Okta]: TOktaConnectionOption;
[AppConnection.OpenRouter]: TOpenRouterConnectionOption;
+ [AppConnection.OpenAI]: TOpenAIConnectionOption;
[AppConnection.AzureADCS]: TAzureAdCsConnectionOption;
[AppConnection.Redis]: TRedisConnectionOption;
[AppConnection.MongoDB]: TMongoDBConnectionOption;
diff --git a/frontend/src/hooks/api/appConnections/types/index.ts b/frontend/src/hooks/api/appConnections/types/index.ts
index 956de5365d..38e3146054 100644
--- a/frontend/src/hooks/api/appConnections/types/index.ts
+++ b/frontend/src/hooks/api/appConnections/types/index.ts
@@ -51,6 +51,7 @@ import { TOCIConnection } from "./oci-connection";
import { TOctopusDeployConnection } from "./octopus-deploy-connection";
import { TOktaConnection } from "./okta-connection";
import { TOnaConnection } from "./ona-connection";
+import { TOpenAIConnection } from "./open-ai-connection";
import { TOpenRouterConnection } from "./open-router-connection";
import { TOracleDBConnection } from "./oracledb-connection";
import { TOvhConnection } from "./ovh-connection";
@@ -122,6 +123,7 @@ export * from "./oci-connection";
export * from "./octopus-deploy-connection";
export * from "./okta-connection";
export * from "./ona-connection";
+export * from "./open-ai-connection";
export * from "./open-router-connection";
export * from "./oracledb-connection";
export * from "./ovh-connection";
@@ -196,6 +198,7 @@ export type TAppConnection =
| TDbtConnection
| TSmbConnection
| TOpenRouterConnection
+ | TOpenAIConnection
| TAnthropicConnection
| TCircleCIConnection
| TCloud66Connection
diff --git a/frontend/src/hooks/api/appConnections/types/open-ai-connection.ts b/frontend/src/hooks/api/appConnections/types/open-ai-connection.ts
new file mode 100644
index 0000000000..c0bbeada70
--- /dev/null
+++ b/frontend/src/hooks/api/appConnections/types/open-ai-connection.ts
@@ -0,0 +1,13 @@
+import { AppConnection } from "@app/hooks/api/appConnections/enums";
+import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
+
+export enum OpenAIConnectionMethod {
+ ApiKey = "api-key"
+}
+
+export type TOpenAIConnection = TRootAppConnection & { app: AppConnection.OpenAI } & {
+ method: OpenAIConnectionMethod.ApiKey;
+ credentials: {
+ apiKey: string;
+ };
+};
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
index 5476e5e78c..b271802ac5 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
@@ -66,6 +66,7 @@ import { OCIConnectionForm } from "./OCIConnectionForm";
import { OctopusDeployConnectionForm } from "./OctopusDeployConnectionForm";
import { OktaConnectionForm } from "./OktaConnectionForm";
import { OnaConnectionForm } from "./OnaConnectionForm";
+import { OpenAIConnectionForm } from "./OpenAIConnectionForm";
import { OpenRouterConnectionForm } from "./OpenRouterConnectionForm";
import { OracleDBConnectionForm } from "./OracleDBConnectionForm";
import { OVHConnectionForm } from "./OVHConnectionForm";
@@ -293,6 +294,8 @@ const CreateForm = ({ app, onComplete, projectId }: CreateFormProps) => {
return <SmbConnectionForm onSubmit={onSubmit} />;
case AppConnection.OpenRouter:
return <OpenRouterConnectionForm onSubmit={onSubmit} />;
+ case AppConnection.OpenAI:
+ return <OpenAIConnectionForm onSubmit={onSubmit} />;
case AppConnection.Anthropic:
return <AnthropicConnectionForm onSubmit={onSubmit} />;
case AppConnection.Devin:
@@ -548,6 +551,8 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {
return <SmbConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
case AppConnection.OpenRouter:
return <OpenRouterConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
+ case AppConnection.OpenAI:
+ return <OpenAIConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
case AppConnection.Anthropic:
return <AnthropicConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
case AppConnection.Devin:
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/OpenAIConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/OpenAIConnectionForm.tsx
new file mode 100644
index 0000000000..d96c1493a6
--- /dev/null
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/OpenAIConnectionForm.tsx
@@ -0,0 +1,132 @@
+import { Controller, FormProvider, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { Info } from "lucide-react";
+import { z } from "zod";
+
+import {
+ Field,
+ FieldError,
+ FieldLabel,
+ SecretInput,
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
+} from "@app/components/v3";
+import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections";
+import { AppConnection } from "@app/hooks/api/appConnections/enums";
+import {
+ OpenAIConnectionMethod,
+ TOpenAIConnection
+} from "@app/hooks/api/appConnections/types/open-ai-connection";
+
+import { AppConnectionFormFooter } from "./AppConnectionFormFooter";
+import {
+ genericAppConnectionFieldsSchema,
+ GenericAppConnectionsFields
+} from "./GenericAppConnectionFields";
+
+type Props = {
+ appConnection?: TOpenAIConnection;
+ onSubmit: (formData: FormData) => void;
+};
+
+const rootSchema = genericAppConnectionFieldsSchema.extend({
+ app: z.literal(AppConnection.OpenAI)
+});
+
+const formSchema = z.discriminatedUnion("method", [
+ rootSchema.extend({
+ method: z.literal(OpenAIConnectionMethod.ApiKey),
+ credentials: z.object({
+ apiKey: z.string().trim().min(1, "API Key required")
+ })
+ })
+]);
+
+type FormData = z.infer<typeof formSchema>;
+
+export const OpenAIConnectionForm = ({ appConnection, onSubmit }: Props) => {
+ const isUpdate = Boolean(appConnection);
+
+ const form = useForm<FormData>({
+ resolver: zodResolver(formSchema),
+ defaultValues: appConnection ?? {
+ app: AppConnection.OpenAI,
+ method: OpenAIConnectionMethod.ApiKey
+ }
+ });
+
+ const { handleSubmit, control } = form;
+
+ return (
+ <FormProvider {...form}>
+ <form onSubmit={handleSubmit(onSubmit)}>
+ {!isUpdate && <GenericAppConnectionsFields />}
+ <Controller
+ name="method"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <Field className="mb-4">
+ <FieldLabel>
+ Method
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Info />
+ </TooltipTrigger>
+ <TooltipContent className="max-w-sm">
+ {`The method you would like to use to connect with ${
+ APP_CONNECTION_MAP[AppConnection.OpenAI].name
+ }. This field cannot be changed after creation.`}
+ </TooltipContent>
+ </Tooltip>
+ </FieldLabel>
+ <Select disabled={isUpdate} value={value} onValueChange={(val) => onChange(val)}>
+ <SelectTrigger className="w-full" isError={Boolean(error)}>
+ <SelectValue placeholder="Select a method..." />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ {Object.values(OpenAIConnectionMethod).map((method) => (
+ <SelectItem value={method} key={method}>
+ {getAppConnectionMethodDetails(method).name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ <FieldError errors={[error]} />
+ </Field>
+ )}
+ />
+ <Controller
+ name="credentials.apiKey"
+ control={control}
+ shouldUnregister
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <Field className="mb-4">
+ <FieldLabel htmlFor="api-key">
+ Admin API Key
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Info />
+ </TooltipTrigger>
+ <TooltipContent className="max-w-sm">
+ The OpenAI Admin API key used to manage API keys.
+ </TooltipContent>
+ </Tooltip>
+ </FieldLabel>
+ <SecretInput value={value} onChange={(e) => onChange(e.target.value)} />
+ <FieldError errors={[error]} />
+ </Field>
+ )}
+ />
+ <AppConnectionFormFooter
+ submitLabel={isUpdate ? "Update Credentials" : "Connect to OpenAI"}
+ />
+ </form>
+ </FormProvider>
+ );
+};