Could you share sample code for replicating the issue.
I was able to download 5 images iteratively from same image source using below source code with .NET SDK 8 (without 403 or 429 issue)
//dalle image generation
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using Azure;
using Azure.AI.OpenAI;
using Azure.Identity;
using OpenAI.Images;
using static System.Environment;
class Program
{
static async Task Main(string[] args)
{
string endpoint = "https://<sourcename>.openai.azure.com/";
string key = "<apikey>";
// Use the recommended keyless credential instead of the AzureKeyCredential credential.
//AzureOpenAIClient openAIClient = new AzureOpenAIClient(new Uri(endpoint), new DefaultAzureCredential());
AzureOpenAIClient openAIClient = new AzureOpenAIClient(new Uri(endpoint), new AzureKeyCredential(key));
// This must match the custom deployment name you chose for your model
ImageClient chatClient = openAIClient.GetImageClient("dall-e-3");
var imageGeneration = await chatClient.GenerateImageAsync(
"a happy monkey sitting in a tree, in watercolor",
new ImageGenerationOptions()
{
Size = GeneratedImageSize.W1024xH1024
}
);
string imageUri = imageGeneration.Value.ImageUri.ToString();
Console.WriteLine(imageUri);
// Download and save the image to the local machine
using (HttpClient client = new HttpClient())
{
HttpResponseMessage response = await client.GetAsync(imageUri);
if (response.IsSuccessStatusCode)
{
byte[] imageBytes = await response.Content.ReadAsByteArrayAsync();
await File.WriteAllBytesAsync("downloaded_image.jpg", imageBytes);
await File.WriteAllBytesAsync("downloaded_image1.jpg", imageBytes);
await File.WriteAllBytesAsync("downloaded_image2.jpg", imageBytes);
await File.WriteAllBytesAsync("downloaded_image3.jpg", imageBytes);
await File.WriteAllBytesAsync("downloaded_image4.jpg", imageBytes);
await File.WriteAllBytesAsync("downloaded_image5.jpg", imageBytes);
Console.WriteLine("Image successfully downloaded and saved as 'downloaded_image.jpg'.");
}
else
{
Console.WriteLine("Failed to download the image.");
}
}
}
}
Key Changes -
string imageUri = imageGeneration.Value.ImageUri.ToString();
Are you using a virtual network protected resource by any chance (there might be intermitted network block on proxy or firewall)
Thank you