/dalle3getimage.cs Secret
Created
February 14, 2024 03:20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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