Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🎯 feat(config): Custom Endpoint Request Headers (#1588)

Danny Avila7e2e19a1349b
diff --git a/api/server/services/Endpoints/custom/initializeClient.js b/api/server/services/Endpoints/custom/initializeClient.js
index 0c0ad9e7e2..978506b7b4 100644
--- a/api/server/services/Endpoints/custom/initializeClient.js
+++ b/api/server/services/Endpoints/custom/initializeClient.js
@@ -22,6 +22,13 @@ const initializeClient = async ({ req, res, endpointOption }) => {
const CUSTOM_API_KEY = extractEnvVariable(endpointConfig.apiKey);
const CUSTOM_BASE_URL = extractEnvVariable(endpointConfig.baseURL);
+ let resolvedHeaders = {};
+ if (endpointConfig.headers && typeof endpointConfig.headers === 'object') {
+ Object.keys(endpointConfig.headers).forEach((key) => {
+ resolvedHeaders[key] = extractEnvVariable(endpointConfig.headers[key]);
+ });
+ }
+
if (CUSTOM_API_KEY.match(envVarRegex)) {
throw new Error(`Missing API Key for ${endpoint}.`);
}
@@ -31,6 +38,7 @@ const initializeClient = async ({ req, res, endpointOption }) => {
}
const customOptions = {
+ headers: resolvedHeaders,
addParams: endpointConfig.addParams,
dropParams: endpointConfig.dropParams,
titleConvo: endpointConfig.titleConvo,
diff --git a/docs/install/configuration/custom_config.md b/docs/install/configuration/custom_config.md
index 6847e158ed..b7bba50309 100644
--- a/docs/install/configuration/custom_config.md
+++ b/docs/install/configuration/custom_config.md
@@ -253,6 +253,21 @@ endpoints:
- **Description**: Excludes specified [default parameters](#default-parameters). Useful for APIs that do not accept or recognize certain parameters.
- **Example**: `dropParams: ["stop", "user", "frequency_penalty", "presence_penalty"]`
- **Note**: For a list of default parameters sent with every request, see the ["Default Parameters"](#default-parameters) Section below.
+
+### **headers**:
+
+ > Adds additional headers to requests. Can reference an environment variable
+
+ - Type: Object/Dictionary
+ - **Description**: The `headers` object specifies custom headers for requests. Useful for authentication and setting content types.
+ - **Example**:
+ - **Note**: Supports dynamic environment variable values, which use the format: `"${VARIABLE_NAME}"`
+```yaml
+ headers:
+ x-api-key: "${ENVIRONMENT_VARIABLE}"
+ Content-Type: "application/json"
+```
+
## Additional Notes
- Ensure that all URLs and keys are correctly specified to avoid connectivity issues.
diff --git a/packages/data-provider/package.json b/packages/data-provider/package.json
index 9148305ce1..40c3e175ce 100644
--- a/packages/data-provider/package.json
+++ b/packages/data-provider/package.json
@@ -1,6 +1,6 @@
{
"name": "librechat-data-provider",
- "version": "0.3.6",
+ "version": "0.3.7",
"description": "data services for librechat apps",
"main": "dist/index.js",
"module": "dist/index.es.js",
diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.ts
index 145fc12452..b8ba08a956 100644
--- a/packages/data-provider/src/config.ts
+++ b/packages/data-provider/src/config.ts
@@ -23,6 +23,7 @@ export const endpointSchema = z.object({
summaryModel: z.string().optional(),
forcePrompt: z.boolean().optional(),
modelDisplayLabel: z.string().optional(),
+ headers: z.record(z.any()).optional(),
});
export const configSchema = z.object({