Skip to content

Instantly share code, notes, and snippets.

@vman
Created February 14, 2024 03:20
[HttpGet]
public async Task<IActionResult> Get(string imagePrompt)
{
string deploymentName = Configuration["AzureOpenAI:ImageModelName"];
Response<ImageGenerations> imageGenerations = await _openAIClient.GetImageGenerationsAsync(
new ImageGenerationOptions()
{
DeploymentName = deploymentName,
Prompt = imagePrompt,
Size = ImageSize.Size1024x1024
});
Uri imageUri = imageGenerations.Value.Data[0].Url;
string revisedPrompt = imageGenerations.Value.Data[0].RevisedPrompt;
return Ok(new
{
Url = imageUri.ToString(),
RevisedPrompt = revisedPrompt
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment