diff --git a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/AIEndpointAuth.jsx b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/AIEndpointAuth.jsx index d347539b4bf..64f8a5ee82f 100644 --- a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/AIEndpointAuth.jsx +++ b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/AIEndpointAuth.jsx @@ -46,7 +46,8 @@ export default function AIEndpointAuth(props) { let newApiKeyValue = api.endpointConfig?.endpoint_security?.[isProduction ? 'production' : 'sandbox']?.apiKeyValue === '' ? '' : null; - if ((llmProviderName === 'MistralAI' || llmProviderName === 'OpenAI') && newApiKeyValue !== '') { + if ((llmProviderName === 'MistralAI' || llmProviderName === 'OpenAI') && + newApiKeyValue != null && newApiKeyValue !== '') { newApiKeyValue = `Bearer ${newApiKeyValue}`; } @@ -68,7 +69,8 @@ export default function AIEndpointAuth(props) { let updatedApiKeyValue = event.target.value === '********' ? '' : event.target.value; - if ((llmProviderName === 'MistralAI' || llmProviderName === 'OpenAI') && updatedApiKeyValue !== '') { + if ((llmProviderName === 'MistralAI' || llmProviderName === 'OpenAI') && + updatedApiKeyValue !== null && updatedApiKeyValue !== '') { updatedApiKeyValue = `Bearer ${updatedApiKeyValue}`; } diff --git a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/Endpoints.jsx b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/Endpoints.jsx index 1cfaf0c4da0..558be616c3d 100644 --- a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/Endpoints.jsx +++ b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/Endpoints.jsx @@ -471,7 +471,8 @@ function Endpoints(props) { } } } else if (production.type === 'apikey') { - if (production.apiKeyValue === null && endpointConfig.production_endpoints) { + if ((production.apiKeyValue === null || production.apiKeyValue === '') && + endpointConfig.production_endpoints) { return { isValid: false, message: intl.formatMessage({ @@ -525,7 +526,8 @@ function Endpoints(props) { } } } else if (sandbox.type === 'apikey') { - if (sandbox.apiKeyValue === null && endpointConfig.sandbox_endpoints) { + if ((sandbox.apiKeyValue === null || sandbox.apiKeyValue === '') && + endpointConfig.sandbox_endpoints) { return { isValid: false, message: intl.formatMessage({