Incompatible parameters when image creation in request iOS Swift

Hi ı m trying to generate image from api with swift. But ı m getting incompatible parameters error

any idea ?

its the question mark it is a Syntex error why it’s doing that.

Not sure what imageParameters variable looks like but it should be like this when you call the API:

const result = await openai.images.generate({ 
//model: "dall-e-3",  // if not set will default to dall-e-2
prompt: "A cute baby sea otter",
n: 1,
size: '1024x1024', // max for dall-e-2
quality: 'hd',
style: 'vivid'


See Reference page

what library are you using to interact with open AI? it’s possible that it is out of date and the web service requirements have changed.

as an aside: is this a client app you’re building? i would recommend moving your OpenAI logic into a backend service. Having your API key stored on any client is dangerous and could lead to enormous costs for you when someone extracts it

yes in ios when ı fill the all fields like this it is still giving error

This is openAI SDK for iOS Client. Yes storing api_key in ios app not good practice. I m thinking about it but ı don’t have any backend knowledge. Any advice to store this key without backend? I was thinking about the firebase remote config but remote config not enough ı guess. May ı use the firebase cloud function?

yes! i did exactly that myself, using a fire base cloud function. I also recommend checking out this GPT: ChatGPT - Firebase Assistant. It has knowledge of the Firebase APIs and is very useful for generating the bulk of what you’ll need to build.

Depending on your use case, you can also easily make use of fire base storage to store the images that are generated

1 Like