I saw a post from several weeks ago that said it is down across the board, if so is there an eta?
When I submit an image the api says it cant read images.
I have tried with both 4o and 4o-turbo models.
private void OpenFileButton_Click(object sender, EventArgs e)
{
using OpenFileDialog openFileDialog = new OpenFileDialog
{
Title = "Select Images Files",
Filter = "Image Files|*.jpg;*.jpeg;*.png;*.gif;*.bmp",
Multiselect = true
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
selectedImagePaths = new List<string>(openFileDialog.FileNames);
UpdateSubmitButtonState();
}
}
private void PromptTextBox_TextChanged(object sender, EventArgs e)
{
UpdateSubmitButtonState();
}
private void UpdateSubmitButtonState()
{
submitButton.Enabled = !string.IsNullOrWhiteSpace(promptTextBox.Text) && selectedImagePaths.Count > 0;
}
private async void SubmitButton_Click(object sender, EventArgs e)
{
submitButton.Enabled = false;
progressBar.Minimum = 0;
progressBar.Maximum = selectedImagePaths.Count;
progressBar.Value = 0;
for (int i = 0; i < selectedImagePaths.Count; i++)
{
string imagePath = selectedImagePaths[i];
byte[] imageBytes = File.ReadAllBytes(imagePath);
string base64Image = Convert.ToBase64String(imageBytes);
var requestBody = new
{
model = "gpt-4-turbo",
messages = new[]
{
new
{
role = "user",
content = promptTextBox.Text,
image = base64Image // Use the base64 image directly
}
},
max_tokens = 512
};
var content = new StringContent(JsonSerializer.Serialize(requestBody), Encoding.UTF8, "application/json");
try
{
var response = await httpClient.PostAsync("https://api.openai.com/v1/chat/completions", content);
response.EnsureSuccessStatusCode(); // Throws an exception if the status code is not successful
var responseBody = await response.Content.ReadAsStringAsync();
var jsonResponse = JsonSerializer.Deserialize<JsonElement>(responseBody);
if (jsonResponse.TryGetProperty("choices", out JsonElement choices) &&
choices[0].TryGetProperty("message", out JsonElement message) &&
message.TryGetProperty("content", out JsonElement contentElement))
{
string caption = contentElement.GetString();
string textFilePath = Path.ChangeExtension(imagePath, ".txt");
File.WriteAllText(textFilePath, caption);
}
else
{
MessageBox.Show("Unexpected response format.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
progressBar.Value = i + 1;
}
MessageBox.Show("All captions have been generated and saved.", "Process Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
submitButton.Enabled = true;
}