> ## Documentation Index
> Fetch the complete documentation index at: https://autorender.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Python

> Upload files, manage folders, and call the full Autorender API from your Python server.

The `autorender` package is the official server-side client for Python. Use it to upload files, list and manage files and folders, run multipart uploads, and call the Autorender API from your backend.

## Prerequisites

* An Autorender account with an API key — [create one in the dashboard](https://app.autorender.io)
* Python **3.8** or later

## Guide

<Steps>
  <Step title="Install the package.">
    <CodeGroup>
      ```bash pip theme={null}
      pip install autorender
      ```

      ```bash poetry theme={null}
      poetry add autorender
      ```
    </CodeGroup>
  </Step>

  <Step title="Set your API key.">
    Create an API key in the dashboard and set it as an environment variable:

    ```bash theme={null}
    export AUTORENDER_API_KEY=your-api-key
    ```
  </Step>

  <Step title="Upload a file.">
    Create a client and upload your first file. Read `AUTORENDER_API_KEY` from the environment — never hardcode the key.

    ```python {5} theme={null}
    import os
    import autorender

    client = autorender.Autorender(
        api_key=os.environ.get("AUTORENDER_API_KEY"),
    )

    with open("products/chair.jpg", "rb") as f:
        upload = client.uploads.create(
            file=f,
            file_name="chair.jpg",
        )

    print(upload.file_no)  # e.g. "fi_abc123"
    print(upload.url)      # CDN URL
    ```
  </Step>
</Steps>

## Examples

### Upload from URL

```python theme={null}
upload = client.uploads.create_from_url(
    remote_url="https://acme-assets.s3.amazonaws.com/products/chair.jpg",
)
```

### List files

```python theme={null}
result = client.files.list(limit=10)

for file in result.files:
    print(file.file_no, file.name, file.url)
```

### Get file details

```python theme={null}
file = client.files.retrieve("fi_abc123")
print(file.data.url)
```

### Rename a file

```python theme={null}
client.files.rename("fi_abc123", name="new-name")
```

### Delete a file

```python theme={null}
client.files.delete("fi_abc123")
```

### Folders

```python theme={null}
# List folders
result = client.folders.list()

# Create a folder
folder = client.folders.create(name="products")

# Rename a folder
client.folders.rename(folder.data.folder_no, name="product-images")

# Delete a folder
client.folders.delete(folder.data.folder_no)
```

### Multipart upload

For files larger than **100 MB**, use a multipart upload to split the file into parts:

```python theme={null}
import httpx

with open("large-video.mp4", "rb") as f:
    file_data = f.read()

# Start session
session = client.multipart_uploads.start(
    file_name="large-video.mp4",
    file_size=len(file_data),
)

# Upload parts
res = httpx.put(session.parts[0].url, content=file_data)
etag = res.headers["etag"]

# Complete
result = client.multipart_uploads.complete(
    upload_id=session.upload_id,
    parts=[{"part_number": 1, "etag": etag}],
)
```

### Error handling

```python theme={null}
import autorender

try:
    file = client.files.retrieve("fi_notexist")
except autorender.APIStatusError as e:
    print(e.status_code)  # 404
    print(e.message)
```

## Resources

* [PyPI package](https://pypi.org/project/autorender/)
* [GitHub](https://github.com/autorender/autorender-python)
* [API reference](https://github.com/autorender/autorender-python/blob/main/api.md)

## Next steps

<CardGroup cols={2}>
  <Card title="Direct upload API" icon="cloud-arrow-up" iconType="solid" href="/docs/api-reference/direct-upload">
    The upload endpoint this SDK calls.
  </Card>

  <Card title="Create an API key" icon="key" iconType="solid" href="/docs/create-an-api-key">
    Generate the key the client reads from the environment.
  </Card>

  <Card title="Image transformations" icon="wand-magic-sparkles" iconType="solid" href="/docs/transformations/introduction">
    Build delivery URLs from your uploaded files.
  </Card>

  <Card title="All SDKs" icon="cubes" iconType="solid" href="/docs/resources/sdks">
    Server-side clients for every language.
  </Card>
</CardGroup>
