Whatever message this page gives is out now! Go check it out!

Admin API

Last update:
May 18, 2026
The ColdFusion Admin API exposes LLM configuration management programmatically via CFIDE.adminapi.llm. This allows administrators and automation scripts to manage LLM configurations without using the Admin UI.
Access control: All methods require the coldfusion.ai.llms admin role.
Security: API keys and proxy passwords are encrypted at rest. The Admin API automatically encrypts new values and decrypts them only when returning configurations to authorized callers. Re-encryption is skipped when an existing value is unchanged.

getLLMModels()

Returns all saved LLM configurations, or a specific configuration by alias.
Syntax

llmAdmin = createObject("component", "CFIDE.adminapi.llm");

// Get all configurations
allModels = llmAdmin.getLLMModels();

// Get a specific configuration by alias
model = llmAdmin.getLLMModels("openaiconfig");
            
Arguments
ArgumentTypeRequiredDescription
modelNameStringNoConfig alias of the configuration to retrieve. If omitted, all configurations are returned.
Returns: Struct. When modelName is provided, returns the matching config struct. When omitted, returns a struct of all configs keyed by alias.
Throws:
  • ModelNotFoundException — if the specified modelName does not exist
  • LLMConfigException — on storage read errors

setLLMModel()

Adds a new LLM configuration or updates an existing one.
Syntax

llmAdmin = createObject("component", "CFIDE.adminapi.llm");

llmAdmin.setLLMModel(
    configName = "openaiconfig",
    config = {
        PROVIDER    : "openai",
        MODELNAME   : "gpt-4o-mini",
        APIKEY      : "sk-...",
        TEMPERATURE : 0.7,
        MAXTOKENS   : 2048
    }
);
            
Arguments
ArgumentTypeRequiredDescription
configNameStringYesUnique alias for the configuration. Used to reference this config in CFML code.
configStructYesFull LLM configuration struct. See ChatModel() parameters in Build with AI for all supported keys.
Returns: void
Throws:
  • ValidationException — if the config struct fails validation (detail contains array of error messages)
  • LLMConfigException — on storage write errors

deleteLLMModel()

Deletes a saved LLM configuration by alias.
Syntax

llmAdmin = createObject("component", "CFIDE.adminapi.llm");
llmAdmin.deleteLLMModel("openaiconfig");
            
Arguments
ArgumentTypeRequiredDescription
configNameStringYesAlias of the configuration to delete.
Returns: void
Throws:
  • ModelNotFoundException — if the specified config alias does not exist
  • LLMConfigException — on storage write errors

validateLLMConfig()

Validates an LLM configuration struct before saving. Returns an array of error messages. An empty array means the configuration is valid.
Syntax

llmAdmin = createObject("component", "CFIDE.adminapi.llm");

errors = llmAdmin.validateLLMConfig({
    PROVIDER  : "openai",
    MODELNAME : "gpt-4o-mini",
    APIKEY    : "sk-..."
});

if (arrayLen(errors) eq 0) {
    writeOutput("Configuration is valid.");
} else {
    writeOutput("Errors: " & serializeJSON(errors));
}
            
Arguments
ArgumentTypeRequiredDescription
configStructYesConfiguration struct to validate.
Returns: Array of String. Empty array if valid; one entry per validation error if invalid.

Admin API — full example


<cfscript>
    llmAdmin = createObject("component", "CFIDE.adminapi.llm");

    // 1. Validate before saving
    config = {
        PROVIDER    : "openai",
        MODELNAME   : "gpt-4o-mini",
        APIKEY      : "#application.apiKey#",
        TEMPERATURE : 0.7,
        MAXTOKENS   : 2048
    };

    errors = llmAdmin.validateLLMConfig(config);

    if (arrayLen(errors) gt 0) {
        writeOutput("Validation failed: " & serializeJSON(errors));
        abort;
    }

    // 2. Save configuration
    llmAdmin.setLLMModel("openaiconfig", config);

    // 3. Retrieve and verify
    saved = llmAdmin.getLLMModels("openaiconfig");
    writeOutput("Saved provider: " & saved.PROVIDER);

    // 4. List all configurations
    allModels = llmAdmin.getLLMModels();
    writeOutput("Total configs: " & structCount(allModels));

    // 5. Delete when no longer needed
    llmAdmin.deleteLLMModel("openaiconfig");
</cfscript>
            

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page