LLM Provider Modes for Standalone Overrides in TencentDB-Agent-Memory
TLDR: The TencentDB-Agent-Memory repository supports four LLM provider modes for standalone overrides — openai, azure, anthropic, and custom — each resolved by the llm-provider-resolver.ts gateway when the deployment runs in standalone mode with an OpenAI-compatible proxy.
The TencentCloud/TencentDB-Agent-Memory stack can run in a standalone deployment where the LLM layer is overridden by an OpenAI-compatible proxy. In this mode, the LLM_PROVIDER environment variable and the provider field of the StandaloneLLMConfig determine which back-end the proxy calls. This article explains the supported standalone LLM provider modes, how they are configured, and where the resolution logic lives in the source code.
The Four Standalone LLM Provider Modes
When the gateway runs in standalone mode (as opposed to service mode), it selects an LLM provider based on the provider field of StandaloneLLMConfig. The supported provider modes are:
openai— Calls the standard OpenAI Chat Completion API athttps://api.openai.com/v1/....azure— Routes through Azure OpenAI Service athttps://{resource}.openai.azure.com/...using the same API shape.anthropic— Calls Anthropic's Claude API athttps://api.anthropic.com/v1/....custom— A user-supplied endpoint; the proxy forwards requests to the URL supplied inLLM_CUSTOM_ENDPOINT(or thecustomEndpointfield of the provider config). This is the default mode.
When a request arrives at the proxy with the openai protocol, the dispatcher translates it into the appropriate provider call based on the selected mode. For custom, the request goes to the user-defined endpoint. For the other three modes, built-in adapters handle authentication, model naming, and provider-specific quirks.
How Provider Modes Are Configured and Resolved
The provider mode flows through three distinct layers in the codebase:
-
Environment variable loading —
MemoryKnowledge/src/config.tsreadsLLM_PROVIDERwith a default value ofcustom. This is the entry point for configuring which provider mode is active. -
Gateway configuration —
MemoryCore/src/gateway/config.tsloads the deployment mode (standalonevsservice). When in standalone mode, it selects the LLM provider based on theproviderfield of theStandaloneLLMConfig. -
Runtime resolution —
MemoryProxy/src/adapters/standalone/llm-provider-resolver.tsresolves the correct provider implementation at runtime. The individual adapters live inMemoryProxy/src/injection/adapters/:openai.ts— OpenAI-compatible adapterazure.ts— Azure OpenAI adapteranthropic.ts— Anthropic adaptercustom— handled by direct endpoint forwarding
Code Examples: Configuring Provider Modes
The following examples show how to override the LLM provider in a standalone deployment.
Overriding the Provider in the Gateway Config
// Example: overriding the LLM provider in a stand-alone deployment
import { readConfig } from "./src/gateway/config.js";
const cfg = await readConfig(); // loads config.yaml & env vars
cfg.deployMode = "standalone"; // ensure stand-alone mode
cfg.llm = {
provider: "azure", // one of "openai" | "azure" | "anthropic" | "custom"
model: "gpt-4o", // model name as understood by the provider
apiKey: process.env.AZURE_OPENAI_KEY, // auth for Azure; ignored for other providers
customEndpoint: undefined, // only used when provider === "custom"
};
await startGateway(cfg);
Using the OpenAI Mode Directly
// Example: using the OpenAI proxy directly (protocol = "openai")
import { resolveStandaloneLlmForRuntime } from "./src/adapters/standalone/llm-provider-resolver.js";
const llmConfig = await resolveStandaloneLlmForRuntime({
provider: "openai", // <- selects the OpenAI adapter
model: "gpt-4o-mini",
apiKey: process.env.OPENAI_API_KEY,
});
await llmConfig.runChatCompletion(messages);
Pointing the Custom Mode at Any OpenAI-Compatible API
// Example: custom provider – you can point the proxy at any OpenAI-compatible API
import { resolveStandaloneLlmForRuntime } from "./src/adapters/standalone/llm-provider-resolver.js";
const llmConfig = await resolveStandaloneLlmForRuntime({
provider: "custom",
model: "my-local-gpt",
apiKey: "unused-for-local-proxy",
customEndpoint: "http://localhost:8000/v1",
});
await llmConfig.runChatCompletion(messages);
Official Mapping of Provider Modes to Files
The following table maps each provider mode to its authoritative source file in the repository:
| File | Role |
|---|---|
MemoryCore/src/gateway/config.ts |
Defines DeployMode and loads the LLM_PROVIDER env variable |
MemoryKnowledge/src/config.ts |
Reads LLM_PROVIDER and passes it to the proxy |
MemoryProxy/src/injection/adapters/openai.ts |
Implements the OpenAI-compatible adapter (mode openai) |
MemoryProxy/src/injection/adapters/azure.ts |
Azure OpenAI adapter (mode azure) |
MemoryProxy/src/injection/adapters/anthropic.ts |
Anthropic adapter (mode anthropic) |
MemoryProxy/src/adapters/standalone/llm-provider-resolver.ts |
Resolves the correct provider implementation based on the mode |
Together, these files define the allowed provider modes for standalone overrides, enabling the OpenAI proxy to route requests to OpenAI, Azure, Anthropic, or an arbitrary custom endpoint.
Summary
- The
openaimode calls the standard OpenAI Chat Completion API,azuremode routes to Azure OpenAI Service,anthropicmode targets Claude, andcustommode forwards to a user-defined endpoint. LLM_PROVIDERdefaults tocustomwhen unset.- The
providerfield inStandaloneLLMConfigis only evaluated whendeployModeisstandalone. - Resolution happens at runtime through
resolveStandaloneLlmForRuntimein thellm-provider-resolver.tsmodule, with each provider having a dedicated adapter inMemoryProxy/src/injection/adapters/.
Frequently Asked Questions
What is the default LLM provider mode in standalone deployments?
The default provider mode is custom. This is set as the fallback in MemoryKnowledge/src/config.ts when the LLM_PROVIDER environment variable is not explicitly defined.
How do I switch from the OpenAI provider to a custom endpoint?
Set the provider field to "custom" in the StandaloneLLMConfig and supply the target URL through either the LLM_CUSTOM_ENDPOINT environment variable or the customEndpoint config field. The proxy then forwards incoming requests to that URL.
Which file determines which provider adapter gets loaded?
The runtime resolution is performed by MemoryProxy/src/adapters/standalone/llm-provider-resolver.ts. It reads the provider mode and instantiates the corresponding adapter from MemoryProxy/src/injection/adapters/ (e.g., openai.ts, azure.ts, anthropic.ts).
Does the custom mode still use the OpenAI protocol?
Yes. The request that arrives at the proxy uses the openai protocol shape, but with custom mode the proxy forwards it to the user-defined endpoint rather than a built-in provider. This is useful when you have a local or third-party OpenAI-compatible server.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →