Understanding Aspect Ratios in Our APIs

Introduction

Aspect ratios are a crucial parameter in image generation, determining the width-to-height relationship of your images. When using our API, selecting the appropriate aspect ratio ensures that your images meet your specific requirements. This article outlines the valid aspect ratios available through our API and their corresponding image dimensions.

What is an Aspect Ratio?

An aspect ratio expresses the proportional relationship between an image's width and height. It is represented as two numbers separated by a colon (e.g., 16:9). Understanding and selecting the correct aspect ratio can help maintain the visual integrity of your images, especially when used in specific contexts like social media, websites, or presentations.

Valid Aspect Ratios and Image Dimensions

Here is a list of valid aspect ratios you can use in your API requests, along with their corresponding image dimensions:


Aspect Ratio Image Dimensions (Width x Height)
16:9 1344 x 768
1:1 1024 x 1024
21:9 1536 x 640
2:3 832 x 1216
3:2 1216 x 832
4:5 896 x 1088
5:4 1088 x 896
9:16 768 x 1344
9:21 640 x 1536

How to Use Aspect Ratios in Your API Request

When making an API call, you can specify the desired aspect ratio as a parameter. For example:

Please note that only the following API endpoints currently have support for the "aspect_ratio": parameter to be set: 

Conclusion

Selecting the appropriate aspect ratio is essential for generating images that fit your needs. By understanding how aspect ratios translate to specific image dimensions, you can make informed decisions when using our API.