mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🎯 feat(config): Custom Endpoint Request Headers (#1588)
This commit is contained in:
parent
ab3339210a
commit
7e2e19a134
4 changed files with 25 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue