Using `stop=[]` fails when passing images

When sending images to gpt-4o with stop=[] as such:

import openai

response = openai.chat.completions.create(
    model="gpt-4o",
    messages=[{
        'role': 'user', 
        'content': [
            # {'type': 'text', 'text': "1+1=?"}, # no images
            {'type': 'image_url', 'image_url': {'url': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJIAAABgCAYAAAD2ISucAAAMQGlDQ1BJQ0MgUHJvZmlsZQAASImVVwdYU8kWnluSkEBoAQSkhN4EESkBpITQQu9NVEISIJQYA0HFji4quHaxgA1dFVGw0iwoYmdR7H2xoKCsiwW78iYFdN1XvjffN3f++8+Z/5w5d+6dOwConeCIRLmoOgB5wgJxTJAfPSk5hU7qATgwAtqACDQ43HwRMyoqDMAy1P69vLsBEGl71V6q9c/+/1o0ePx8LgBIFMTpvHxuHsSHAMAruSJxAQBEKW82tUAkxbACLTEMEOJFUpwpx5VSnC7H+2Q2cTEsiNsAUFLhcMSZAKhehjy9kJsJNVT7IXYU8gRCANToEHvn5U3mQZwGsTW0EUEs1Wek/6CT+TfN9GFNDidzGMvnIitK/oJ8US5n+v+Zjv9d8nIlQz4sYVXJEgfHSOcM83YrZ3KoFKtA3CdMj4iEWBPiDwKezB5ilJIlCY6X26MG3HwWzBnQgdiRx/EPhdgA4kBhbkSYgk/PEASyIYYrBJ0mKGDHQawL8SJ+fkCswmaLeHKMwhdanyFmMRX8OY5Y5lfq64EkJ56p0H+dxWcr9DHVoqy4RIgpEJsXChIiIFaF2CE/JzZUYTOuKIsVMWQjlsRI4zeHOIYvDPKT62OFGeLAGIV9aV7+0HyxLVkCdoQCHyjIiguW5wdr43Jk8cO5YJf5Qmb8kA4/PylsaC48vn+AfO5YD18YH6vQ+SAq8IuRj8UpotwohT1uys8NkvKmEDvnF8YqxuIJBXBByvXxDFFBVJw8TrwomxMSJY8HXw7CAAv4AzqQwJoOJoNsIOjoa+iDd/KeQMABYpAJ+MBewQyNSJT1COE1FhSBPyHig/zhcX6yXj4ohPzXYVZ+tQcZst5C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xxIDGwyDRc5kGisMgM2OJAY2GQaLnIg0VhlBmxwIDGwyTRc5ECiscoM2OBAYmCTabjIgURjlRmwwYHEwCbTcJEDicYqM2CDA4mBTabhIgcSjVVmwAYHEgObTMNFDiQaq8yADQ4kBjaZhoscSDRWmQEbHEgMbDINFzmQaKwyAzY4kBjYZBouciDRWGUGbHAgMbDJNFzkQKKxygzY4EBiYJNpuMiBRGOVGbDBgcTAJtNw8T+KDaOdpR3CpQAAAABJRU5ErkJggg=='}}
        ]
    }],
    stop=[] # fails with None too
)

response.choices[0].message.content

I get a 400 BadRequest error:

BadRequestError: Error code: 400 - {
	'error': {
		'message': '3 validation errors for Request
			body -> stop
  				str type expected (type=type_error.str)
			body -> stop
  				ensure this value has at least 1 items (type=value_error.list.min_items; limit_value=1)
			body -> stop
  				ensure this value has at least 1 items (type=value_error.list.min_items; limit_value=1)',
  		'type': 'invalid_request_error',
  		'param': None,
  		'code': None
  	}
 }

Without images or without specifying stop sequences, I don’t get errors.

Hi @desaxce

Welcome to the dev forum.

By default the stop sequence is null.

If you want to send a list of stop sequences use an array. The array should have atleast 1 item.

I’d also recommend sharing your code that’s making the API call so the community can help you better.

1 Like