diff --git a/public/index.html b/public/index.html
index b13f2f3cf..a16e3109e 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1987,7 +1987,7 @@
menu to attach an image file to the chat.
-
+
@@ -134,6 +135,8 @@
+
+
diff --git a/public/scripts/extensions/shared.js b/public/scripts/extensions/shared.js
index 3ac65b894..569a08073 100644
--- a/public/scripts/extensions/shared.js
+++ b/public/scripts/extensions/shared.js
@@ -153,6 +153,10 @@ function throwIfInvalidModel(useReverseProxy) {
throw new Error('Cohere API key is not set.');
}
+ if (extension_settings.caption.multimodal_api === 'xai' && !secret_state[SECRET_KEYS.XAI]) {
+ throw new Error('xAI API key is not set.');
+ }
+
if (extension_settings.caption.multimodal_api === 'ollama' && !textgenerationwebui_settings.server_urls[textgen_types.OLLAMA]) {
throw new Error('Ollama server URL is not set.');
}
diff --git a/src/endpoints/openai.js b/src/endpoints/openai.js
index c8f1701ce..8cbc1bb76 100644
--- a/src/endpoints/openai.js
+++ b/src/endpoints/openai.js
@@ -65,6 +65,10 @@ router.post('/caption-image', async (request, response) => {
key = readSecret(request.user.directories, SECRET_KEYS.COHERE);
}
+ if (request.body.api === 'xai') {
+ key = readSecret(request.user.directories, SECRET_KEYS.XAI);
+ }
+
if (!key && !request.body.reverse_proxy && ['custom', 'ooba', 'koboldcpp', 'vllm'].includes(request.body.api) === false) {
console.warn('No key found for API', request.body.api);
return response.sendStatus(400);
@@ -134,6 +138,10 @@ router.post('/caption-image', async (request, response) => {
apiUrl = 'https://api.cohere.ai/v2/chat';
}
+ if (request.body.api === 'xai') {
+ apiUrl = 'https://api.x.ai/v1/chat/completions';
+ }
+
if (request.body.api === 'ooba') {
apiUrl = `${trimV1(request.body.server_url)}/v1/chat/completions`;
const imgMessage = body.messages.pop();