Whatever message this page gives is out now! Go check it out!
ChatModel.chat() and Agent.chat().
<cfscript>
// configure chat model
chatModelConfig = {
provider : "openAI",
modelName : "gpt-5.4",
apiKey : "#application.apiKey#"
}
// instantiate chat model
chatModel= ChatModel(chatModelConfig)
// chat with model
response = chatModel.chat("Summarize the key features of ColdFusion 2025.")
writeDump(response)
writeOutput(response.message)
</cfscript>
Agent.chat(). ChatModel.chat() accepts plain strings only.
<cfscript>
// configure chat model
chatModelConfig = {
provider : "openAI",
modelName : "gpt-5-nano",
apiKey : "#application.apiKey#",
temperature : 0.2
}
// instantiate chat model
chatModel= ChatModel(chatModelConfig)
agent=agent({
chatModel: chatModel,
description: "Converts code snippets between programming languages."
});
try {
// chat with agent
response = agent.chat("Convert 'console.log(x)' to ColdFusion.");
writeDump(response)
writeOutput(response.message);
} catch (any e) {
writeOutput("Error: " & e.message);
writedump(e);
}
</cfscript>
<cfscript>
// configure chat model
chatModelConfig = {
provider : "Anthropic",
modelName : "claude-sonnet-4-6",
apiKey : "#application.anthropicKey#"
}
// instantiate chat model
chatModel= ChatModel(chatModelConfig)
// 2. Create an Agent
agent = Agent({ CHATMODEL : chatModel });
chatRequest = {
systemMessage: "You are a ColdFusion developer. Reply in 2 lines.",
userMessage: "What is ColdFusion CFC"
};
//agent.chat(chatRequest);
response=agent.chat(chatRequest);
writeOutput(response.message);
</cfscript>
<cfscript>
// configure chat model
chatModelConfig = {
provider : "openAI",
modelName : "gpt-5-nano",
apiKey : "#application.apiKey#",
temperature : 0.2
}
// instantiate chat model
chatModel= ChatModel(chatModelConfig)
chatRequest = {
chatModel: chatModel,
SYSTEMMESSAGE : "You are a stock trader.",
USERMESSAGE : { MESSAGE : "Should I buy or sell tech stocks?" }
};
response = agent.chat(chatRequest);
writeOutput(response.message);
</cfscript>