Skip to content

[Enhancement]: Custom Endpoint support for Memory LLM Config #11012

@jcbartle

Description

@jcbartle

What happened?

We are implementing the Memory feature. Our librechat.yaml file specifies mostly custom endpoints - we are hoping to retire the azureOpenAI endpoint (see this discussion for details).

When pointing the memory.agent configuration item to either the ID value of an agent pointing at a custom endpoint or directly to a custom endpoint via the provider and model items, custom headers configured under that custom endpoint which point to an environment variable are not getting expanded. In our implementation this causes authentication to fail, because we have to send over a custom api-key header. We have the following custom headers defined:

X-User-Identifier: "{{LIBRECHAT_USER_EMAIL}}"
X-Application-Identifier: "LibreChat - Dev"
api-key: "${LIBRECHAT_SUBSCRIPTION_KEY}"

Viewing our API gateway logs, the custom headers are getting sent over, but the ones which are pointing to environment variables are not getting expanded - it's just sending over the raw value.

In our scenario, this causing auth to fail for the memory calls.

As a temporary workaround, I've pointed the memory config to an azureOpenAI endpoint, as that is properly expanding environment variables.

Version Information

da10815

Steps to Reproduce

Set up a custom endpoint with custom headers defined which point to environment variables, something like this:

custom:
  - name: "Azure OpenAI - General Purpose"
    apiKey: "${LIBRECHAT_SUBSCRIPTION_KEY}"
    baseURL: "https://<custom_domain>/ai/azure-oaiv1"
    customParams:
      defaultParamsEndpoint: azureOpenAI
    headers:
      X-User-Identifier: "{{LIBRECHAT_USER_EMAIL}}"
      X-Application-Identifier: "LibreChat - Dev"
      api-key: "${LIBRECHAT_SUBSCRIPTION_KEY}"
    models:
      default:
        - "gpt-5-chat-2025-10-03"
        - "gpt-4.1-2025-04-14"
        - "gpt-4.1-mini-2025-04-14"
        - "gpt-4.1-nano-2025-04-14"
        - "gpt-4o-2024-11-20"
        - "gpt-4o-mini-2024-07-18"
      fetch: false
    summarize: false
    titleConvo: true
    titleModel: "gpt-4.1-nano-2025-04-14"

Then configure memory to point to this:

memory:
  disabled: false
  tokenLimit: 3000
  personalize: true
  messageWindowSize: 10
  agent:
    provider: "Azure OpenAI - General Purpose"
    model: "gpt-5-chat-2025-10-03"

What browsers are you seeing the problem on?

No response

Relevant log output

error: Memory Agent failed to process memory 401 status code (no body)

Screenshots

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions