---
title: Get variants setting
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/python)

[Cache](https://developers.cloudflare.com/api/python/resources/cache)

[Variants](https://developers.cloudflare.com/api/python/resources/cache/subresources/variants)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Get variants setting

cache.variants.get(VariantGetParams\*\*kwargs) -> [VariantGetResponse](<https://developers.cloudflare.com/api/python/resources/cache#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)>)

GET/zones/{zone\_id}/cache/variants

Variant support enables caching variants of images with certain file extensions in addition to the original. This only applies when the origin server sends the ‘Vary: Accept’ response header. If the origin server sends ‘Vary: Accept’ but does not serve the variant requested, the response will not be cached. This will be indicated with BYPASS cache status in the response headers.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

**Example:**<code>X-Auth-Email: user@example.com</code>

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### Accepted Permissions (at least one required)

`Zone Settings Write``Zone Settings Read``Zone Read``Zone Write`

##### ParametersExpand Collapse

zone\_id: str

Identifier.

maxLength32

[Link to this property](<#(resource)%20cache.variants%20%3E%20(method)%20get%20%3E%20(params)%20default%20%3E%20(param)%20zone_id%20%3E%20(schema)>)

##### ReturnsExpand Collapse

<details>

<summary>

class VariantGetResponse: …

</summary>

id: Literal\["variants"]

The identifier of the caching setting.

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

editable: bool

Whether the setting is editable.

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20editable">Link to this property</a>

<details>

<summary>

value: Value

Value of the zone setting.

</summary>

avif: Optional\[List\[str]]

List of strings with the MIME types of all the variants that should be served for avif.

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20value%20%3E%20(property)%20avif">Link to this property</a>

bmp: Optional\[List\[str]]

List of strings with the MIME types of all the variants that should be served for bmp.

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20value%20%3E%20(property)%20bmp">Link to this property</a>

gif: Optional\[List\[str]]

List of strings with the MIME types of all the variants that should be served for gif.

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20value%20%3E%20(property)%20gif">Link to this property</a>

jp2: Optional\[List\[str]]

List of strings with the MIME types of all the variants that should be served for jp2.

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20value%20%3E%20(property)%20jp2">Link to this property</a>

jpeg: Optional\[List\[str]]

List of strings with the MIME types of all the variants that should be served for jpeg.

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20value%20%3E%20(property)%20jpeg">Link to this property</a>

jpg: Optional\[List\[str]]

List of strings with the MIME types of all the variants that should be served for jpg.

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20value%20%3E%20(property)%20jpg">Link to this property</a>

jpg2: Optional\[List\[str]]

List of strings with the MIME types of all the variants that should be served for jpg2.

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20value%20%3E%20(property)%20jpg2">Link to this property</a>

png: Optional\[List\[str]]

List of strings with the MIME types of all the variants that should be served for png.

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20value%20%3E%20(property)%20png">Link to this property</a>

tif: Optional\[List\[str]]

List of strings with the MIME types of all the variants that should be served for tif.

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20value%20%3E%20(property)%20tif">Link to this property</a>

tiff: Optional\[List\[str]]

List of strings with the MIME types of all the variants that should be served for tiff.

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20value%20%3E%20(property)%20tiff">Link to this property</a>

webp: Optional\[List\[str]]

List of strings with the MIME types of all the variants that should be served for webp.

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20value%20%3E%20(property)%20webp">Link to this property</a>

</details>

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20value">Link to this property</a>

modified\_on: Optional\[datetime]

Last time this setting was modified.

formatdate-time

<a href="#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)%20%3E%20(property)%20modified_on">Link to this property</a>

</details>

[Link to this property](<#(resource)%20cache.variants%20%3E%20(model)%20variant_get_response%20%3E%20(schema)>)

### Get variants setting

Python

HTTPTypeScriptPythonGoTerraform

```
import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
variant = client.cache.variants.get(
    zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(variant.id)
```

200 example

```
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "variants",
    "editable": true,
    "value": {
      "avif": [
        "image/webp",
        "image/jpeg"
      ],
      "bmp": [
        "image/webp",
        "image/jpeg"
      ],
      "gif": [
        "image/webp",
        "image/jpeg"
      ],
      "jp2": [
        "image/webp",
        "image/avif"
      ],
      "jpeg": [
        "image/webp",
        "image/avif"
      ],
      "jpg": [
        "image/webp",
        "image/avif"
      ],
      "jpg2": [
        "image/webp",
        "image/avif"
      ],
      "png": [
        "image/webp",
        "image/avif"
      ],
      "tif": [
        "image/webp",
        "image/avif"
      ],
      "tiff": [
        "image/webp",
        "image/avif"
      ],
      "webp": [
        "image/jpeg",
        "image/avif"
      ]
    },
    "modified_on": "2014-01-01T05:20:00.12345Z"
  }
}
```

##### Returns Examples

200 example

```
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "variants",
    "editable": true,
    "value": {
      "avif": [
        "image/webp",
        "image/jpeg"
      ],
      "bmp": [
        "image/webp",
        "image/jpeg"
      ],
      "gif": [
        "image/webp",
        "image/jpeg"
      ],
      "jp2": [
        "image/webp",
        "image/avif"
      ],
      "jpeg": [
        "image/webp",
        "image/avif"
      ],
      "jpg": [
        "image/webp",
        "image/avif"
      ],
      "jpg2": [
        "image/webp",
        "image/avif"
      ],
      "png": [
        "image/webp",
        "image/avif"
      ],
      "tif": [
        "image/webp",
        "image/avif"
      ],
      "tiff": [
        "image/webp",
        "image/avif"
      ],
      "webp": [
        "image/jpeg",
        "image/avif"
      ]
    },
    "modified_on": "2014-01-01T05:20:00.12345Z"
  }
}
```