Whatever message this page gives is out now! Go check it out!
CFIDE.adminapi.llm. This allows administrators and automation scripts to manage LLM configurations without using the Admin UI.coldfusion.ai.llms admin role.
llmAdmin = createObject("component", "CFIDE.adminapi.llm");
// Get all configurations
allModels = llmAdmin.getLLMModels();
// Get a specific configuration by alias
model = llmAdmin.getLLMModels("openaiconfig");
| Argument | Type | Required | Description |
|---|---|---|---|
| modelName | String | No | Config alias of the configuration to retrieve. If omitted, all configurations are returned. |
modelName is provided, returns the matching config struct. When omitted, returns a struct of all configs keyed by alias.ModelNotFoundException — if the specified modelName does not existLLMConfigException — on storage read errors
llmAdmin = createObject("component", "CFIDE.adminapi.llm");
llmAdmin.setLLMModel(
configName = "openaiconfig",
config = {
PROVIDER : "openai",
MODELNAME : "gpt-4o-mini",
APIKEY : "sk-...",
TEMPERATURE : 0.7,
MAXTOKENS : 2048
}
);
| Argument | Type | Required | Description |
|---|---|---|---|
| configName | String | Yes | Unique alias for the configuration. Used to reference this config in CFML code. |
| config | Struct | Yes | Full LLM configuration struct. See ChatModel() parameters in Build with AI for all supported keys. |
ValidationException — if the config struct fails validation (detail contains array of error messages)LLMConfigException — on storage write errors
llmAdmin = createObject("component", "CFIDE.adminapi.llm");
llmAdmin.deleteLLMModel("openaiconfig");
| Argument | Type | Required | Description |
|---|---|---|---|
| configName | String | Yes | Alias of the configuration to delete. |
ModelNotFoundException — if the specified config alias does not existLLMConfigException — on storage write errors
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));
}
| Argument | Type | Required | Description |
|---|---|---|---|
| config | Struct | Yes | Configuration struct to validate. |
<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>