
To generate less deterministic and more creative responses with Azure OpenAI chat completions, increase the Temperature setting. Temperature controls sampling randomness: higher values (e.g., ~0.8–1.0) yield more diverse/creative outputs; lower values (~0–0.2) are more deterministic.
The message being sent in the Messages collection is the user’s prompt, so the correct role is ChatRole.User . The role does not control creativity; it only tells the model who authored the message (system/assistant/user/function). Creativity is governed by parameters such as Temperature (and, to a lesser extent, TopP ). PresencePenalty biases against repeating seen tokens/topics but does not primarily increase creativity in the intended way.
So the code should look like:
new ChatCompletionsOptions()
{
Messages =
{
new ChatMessage(ChatRole.User, @ " < user prompt here > " ),
},
Temperature = ( float ) 1.0 ,
MaxTokens = 800 ,
};
Microsoft Azure AI Solution References
Azure OpenAI Service – Chat Completions parameters (Temperature controls randomness/creativity; higher = more diverse results).
Azure OpenAI Service – Message roles in chat ( system , user , assistant , function ) and their purposes.
Azure OpenAI Service – Presence/Frequency penalties vs. Temperature (penalties reduce repetition; temperature changes creativity).