# It is recommended to create this in the Portkey Config creator, but we're writing the config here to show the process
config = {
    "strategy": {
        "mode": "fallback"
    },
    "targets": [{
        "strategy": {
            "mode": "loadbalance"
        },
        "targets": [{
            "provider": "openai",
            "api_key": OPENAI_API_KEY,
        },{
            "provider": "stability-ai",
            "api_key": STABILITY_API_KEY,
            "override_params": {"model": "stable-diffusion-v1-6"}
        }]
    },{
        "provider": "openai",
        "api_key": "OPENAI_API_KEY",
        "override_params": {"model": "dall-e-2"}
    }]
}
client = OpenAI(
    api_key="X", # Not necessary since we''ll pick it up from the config
    base_url=PORTKEY_GATEWAY_URL,
    default_headers=createHeaders(
        config=config,
        api_key=PORTKEY_API_KEY
    )
)
image = client.images.generate(
  model="dall-e-3",
  prompt="Lucy in the sky with diamonds",
  response_format='b64_json',
  size="1024x1024"
)
# Display the image
image_bytes = base64.b64decode(image.data[0].b64_json)
display(Image(data=image_bytes))