"Cannot specify both model and engine" in app-request

Hi, I´m trying to make a small iOS app for myself in flutter.
I have a paid subscription and also a valid API key. In my app I want to let describe the Ai a photo. Its working well in the chatGPT app…so it should also work with the API right?
I´m using the endpoint url: httxx://api.openai.com/v1/chat/completions
and as model: gpt-4-turbo

In my app there´s also showing up the error: “Cannot specify both model and engine” and I dont know why.
Here´s the sentence in the flutter file…maybe someone can help me out?

`Future<String> _getImageRecognition(String imagePath) async {
    final url = Uri.parse('https://api.openai.com/v1/chat/completions');

    final bytes = await File(imagePath).readAsBytes();

    final base64Image = base64Encode(bytes);

    try {
      final response = await http.post(
        headers: {
          'Authorization': 'Bearer $apiKey',
          'Content-Type': 'application/json',
        body: jsonEncode({
          'model': 'gpt-4-turbo', // 
          'messages': [
              'role': 'system',
              'role': 'user',
                  'XXXXX: $base64Image. '
          'max_tokens': 100 // Beispielparameter; 

Heya. Welcome to the forum.

I believe you’re not sending the image correctly. Check the API docs… Here’s a good post with some hints…


Thanks! Might be a solution…pretty hard for a complete noob in this field :wink:

Ok, I made it so far. But now the token request is with 473018 way too big than the max of 30000.
I tried to reduce the image size (25%, 128x128px) but nothing works. The requested tokens are always the same.
But it should be possible to upload a photo from the smartphone to analyse it, or? Can´t believe that this is so token-wasting.

Here’s a quicker guide of what you must send to chat completions:


Thanks a lot! That was a good hint…now it works! :slight_smile: