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

# Python

> Use the Mixfont Python client

Use the Python client in Python 3.9 or newer.

## Install

```bash theme={null}
pip install mixfont
```

View the package on [PyPI](https://pypi.org/project/mixfont/).

## Generate a font

```python theme={null}
import os
from mixfont import Mixfont

mixfont = Mixfont(api_key=os.environ["MIXFONT_API_KEY"])

generation = mixfont.generations.create(
    prompt="a cute and bubbly font",
    glyph_set="standard",
)

result = mixfont.generations.wait(generation["id"])

print(result["ttf_url"])
```

## Create from an image

```python theme={null}
generation = mixfont.generations.create(
    image_url="https://images.example.com/reference-wordmark.png",
    glyph_set="standard",
)
```

## Methods

| Method                                         | Description                                                             |
| ---------------------------------------------- | ----------------------------------------------------------------------- |
| `mixfont.generations.create(...)`              | Starts a new generation and returns immediately.                        |
| `mixfont.generations.get(generation_id)`       | Fetches the current generation status.                                  |
| `mixfont.generations.wait(generation_id, ...)` | Polls until the generation succeeds, fails, is cancelled, or times out. |

## Create arguments

Provide exactly one of `prompt` or `image_url`.

| Argument    | Type                         | Description                                                                                                                                                                                                                 |
| ----------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `prompt`    | `str`                        | Text prompt for the generated font.                                                                                                                                                                                         |
| `image_url` | `str`                        | Public HTTPS URL for a reference image.                                                                                                                                                                                     |
| `glyph_set` | `"standard"` or `"extended"` | Optional glyph set. Defaults to `standard`. `standard` generates 72 glyphs for English with basic letters, numbers, and punctuation. `extended` generates 319 glyphs for all Latin languages, including special characters. |

## Response

The Python client returns the API response as a dictionary with snake-case keys.

| Key                | Type            | Description                                                              |
| ------------------ | --------------- | ------------------------------------------------------------------------ |
| `id`               | `str`           | Generation id.                                                           |
| `name`             | `str`           | Generated font display name.                                             |
| `ttf_url`          | `str` or `None` | Generated TTF download URL. `None` until the generation succeeds.        |
| `status`           | `str`           | `preparing`, `queued`, `running`, `succeeded`, `cancelled`, or `failed`. |
| `input_type`       | `str`           | `text` or `image`.                                                       |
| `glyph_set`        | `str`           | Selected glyph set: `standard` or `extended`.                            |
| `progress_percent` | `float`         | Approximate progress from `0` to `100`.                                  |
| `poll_url`         | `str`           | Present on create responses.                                             |
| `error`            | `str`           | Present only when a generation fails and an error message is available.  |
| `created_at`       | `str`           | ISO timestamp for when the generation was created.                       |

## Wait arguments

| Argument           | Type    | Description                             |
| ------------------ | ------- | --------------------------------------- |
| `interval_seconds` | `float` | Polling interval. Defaults to `5.0`.    |
| `timeout_seconds`  | `float` | Maximum wait time. Defaults to `600.0`. |
