> ## 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.

# Font generation

> Generate TTF font files from a text prompt or a reference image

export const FontPreview = ({fontFamily, children}) => <div className="font-preview-editor" contentEditable role="textbox" aria-label="Editable font preview" spellCheck={false} suppressContentEditableWarning style={{
  fontFamily: `"${fontFamily}", sans-serif`
}} tabIndex={0}>
    {children}
  </div>;

Generate TTF font files from a text prompt or a public reference image. Font generation is asynchronous: create a generation, then poll until the job reaches `succeeded`, `failed`, or `cancelled`.

The font generation API is available through HTTP or Mixfont's language specific SDKs.

View the packages on [npm](https://www.npmjs.com/package/mixfont) and [PyPI](https://pypi.org/project/mixfont/).

## Install a client

<CodeGroup>
  ```bash JavaScript theme={null}
  npm install mixfont
  ```

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

  ```bash cURL theme={null}
  # No client library is required.
  ```
</CodeGroup>

## Generate from an image

Reference image URLs must use HTTPS, be publicly reachable, point to a JPEG, PNG, or WebP image, and be no larger than 20 MB.

<CodeGroup>
  ```javascript JavaScript theme={null}
  import { Mixfont } from "mixfont";

  const mixfont = new Mixfont({
  apiKey: process.env.MIXFONT_API_KEY,
  });

  const generation = await mixfont.generations.create({
  imageUrl: "https://images.example.com/reference-wordmark.png",
  glyphSet: "standard",
  });

  const result = await mixfont.generations.wait(generation.id);

  console.log(result.ttfUrl);

  ```

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

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

  generation = mixfont.generations.create(
      image_url="https://images.example.com/reference-wordmark.png",
      glyph_set="standard",
  )

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

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

  ```bash cURL theme={null}
  curl https://api.mixfont.com/v1/font-generations/image \
    -H "Content-Type: application/json" \
    -H "x-api-key: $MIXFONT_API_KEY" \
    -d '{
      "image_url": "https://images.example.com/reference-wordmark.png",
      "glyph_set": "standard"
    }'

  curl https://api.mixfont.com/v1/font-generations/GENERATION_ID \
    -H "x-api-key: $MIXFONT_API_KEY"
  ```
</CodeGroup>

Image generation returns a generation `id` and polling URL. Poll until `status` is `succeeded`, then download the generated TTF from the response. A generated font from this reference image can look like this:

<table
  className="font-use-cases-table"
  style={{
width: "100%",
maxWidth: "100%",
tableLayout: "fixed",
borderCollapse: "collapse",
borderBottom: "0",
}}
>
  <colgroup>
    <col style={{ width: "25%" }} />

    <col style={{ width: "75%" }} />
  </colgroup>

  <thead>
    <tr style={{ borderBottom: "0" }}>
      <th
        style={{
      border: "0",
      color: "#111111",
      fontWeight: 700,
      paddingRight: "0.75rem",
      textAlign: "left",
      verticalAlign: "top",
    }}
      >
        <span className="font-table-heading">Input</span>
      </th>

      <th
        style={{
      border: "0",
      color: "#111111",
      fontWeight: 700,
      paddingLeft: "0.75rem",
      textAlign: "left",
      verticalAlign: "top",
    }}
      >
        <span className="font-table-heading">Output</span>
      </th>
    </tr>
  </thead>

  <tbody>
    <tr style={{ borderBottom: "0" }}>
      <td style={{ border: "0", paddingRight: "0.75rem", verticalAlign: "top" }}>
        <img
          src="https://static.mixfont.com/assets/20260603-210216-image-n06hmmov.webp"
          alt="Gossamer Editorial Serif input example"
          style={{
        display: "block",
        marginTop: "0",
        width: "100px",
        maxWidth: "100%",
        borderRadius: "4px",
      }}
        />
      </td>

      <td style={{ border: "0", paddingLeft: "0.75rem", verticalAlign: "top" }}>
        <FontPreview fontFamily="Gossamer Editorial Serif">
          The skills behind better performance
        </FontPreview>

        <a href="https://static.mixfont.com/assets/20260603-212006-font-001-gossamereditorialserif-regular-1-weyynop8.ttf" download="Gossamer-Editorial-Serif.ttf" className="font-download-button" style={{ verticalAlign: "top" }}>
          <Icon icon="download" size={16} color="#111111" />

          Gossamer-Editorial-Serif.ttf
        </a>
      </td>
    </tr>
  </tbody>
</table>

## Generate from a prompt

<CodeGroup>
  ```javascript JavaScript theme={null}
  import { Mixfont } from "mixfont";

  const mixfont = new Mixfont({
  apiKey: process.env.MIXFONT_API_KEY,
  });

  const generation = await mixfont.generations.create({
  prompt: "a cute and bubbly font",
  glyphSet: "standard",
  });

  const result = await mixfont.generations.wait(generation.id);

  console.log(result.ttfUrl);

  ```

  ```python 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"])
  ```

  ```bash cURL theme={null}
  curl https://api.mixfont.com/v1/font-generations/text \
    -H "Content-Type: application/json" \
    -H "x-api-key: $MIXFONT_API_KEY" \
    -d '{
      "prompt": "a cute and bubbly font",
      "glyph_set": "standard"
    }'

  curl https://api.mixfont.com/v1/font-generations/GENERATION_ID \
    -H "x-api-key: $MIXFONT_API_KEY"
  ```
</CodeGroup>

Prompt generation returns a generation `id` and polling URL. Poll until `status` is `succeeded`, then download the generated TTF from the response. A generated font from this prompt can look like this:

<table
  className="font-use-cases-table"
  style={{
width: "100%",
maxWidth: "100%",
tableLayout: "fixed",
borderCollapse: "collapse",
borderBottom: "0",
}}
>
  <colgroup>
    <col style={{ width: "25%" }} />

    <col style={{ width: "75%" }} />
  </colgroup>

  <thead>
    <tr style={{ borderBottom: "0" }}>
      <th
        style={{
      border: "0",
      color: "#111111",
      fontWeight: 700,
      paddingRight: "0.75rem",
      textAlign: "left",
      verticalAlign: "top",
    }}
      >
        <span className="font-table-heading">Input</span>
      </th>

      <th
        style={{
      border: "0",
      color: "#111111",
      fontWeight: 700,
      paddingLeft: "0.75rem",
      textAlign: "left",
      verticalAlign: "top",
    }}
      >
        <span className="font-table-heading">Output</span>
      </th>
    </tr>
  </thead>

  <tbody>
    <tr style={{ borderBottom: "0" }}>
      <td style={{ border: "0", paddingRight: "0.75rem", verticalAlign: "top" }}>
        <div className="font-prompt-input">a cute and bubbly font</div>
      </td>

      <td style={{ border: "0", paddingLeft: "0.75rem", verticalAlign: "top" }}>
        <FontPreview fontFamily="Iridescent Bubble Tone">
          A cute and bubbly font generated from a prompt on Mixfont!
        </FontPreview>

        <a href="https://static.mixfont.com/assets/20260603-215639-font-001-iridescentbubbletone-regular-y1pt732y.ttf" download="Iridescent-Bubble-Tone.ttf" className="font-download-button" style={{ verticalAlign: "top" }}>
          <Icon icon="download" size={16} color="#111111" />

          Iridescent-Bubble-Tone.ttf
        </a>
      </td>
    </tr>
  </tbody>
</table>

## Request structure

The REST API uses snake case. The JavaScript client maps request fields to camel case. The Python client uses snake case.

| REST field  | JavaScript | Python      | Used by          | Description                                                                                                                                                                                                                 |
| ----------- | ---------- | ----------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `image_url` | `imageUrl` | `image_url` | Image generation | Public HTTPS URL for a JPEG, PNG, or WebP reference image up to 20 MB.                                                                                                                                                      |
| `prompt`    | `prompt`   | `prompt`    | Text generation  | Text prompt describing the font to generate.                                                                                                                                                                                |
| `glyph_set` | `glyphSet` | `glyph_set` | Both             | Optional glyph set. `standard` generates 72 glyphs for English with basic letters, numbers, and punctuation. `extended` generates 319 glyphs for all Latin languages, including special characters. Defaults to `standard`. |

`standard` costs 20 API credits and takes on average around 25 seconds. `extended` costs 50 API credits and may take 2-3 minutes to complete.

## Response structure

Create endpoints return `201 Created` with the generation object and a polling URL.

```json theme={null}
{
  "id": "7d58a66d-f129-4f9a-bf9a-4f2c6d0c3e4d",
  "name": "Nebula Sans",
  "ttf_url": null,
  "status": "preparing",
  "input_type": "text",
  "glyph_set": "standard",
  "progress_percent": 0,
  "poll_url": "https://api.mixfont.com/v1/font-generations/7d58a66d-f129-4f9a-bf9a-4f2c6d0c3e4d",
  "created_at": "2026-06-02T21:12:42.000Z"
}
```

Polling returns the generation object without `poll_url`. When the job succeeds, `ttf_url` contains the generated TTF download URL.

```json theme={null}
{
  "id": "7d58a66d-f129-4f9a-bf9a-4f2c6d0c3e4d",
  "name": "Nebula Sans",
  "ttf_url": "https://static.mixfont.com/uploads/generated/7d58a66d-f129-4f9a-bf9a-4f2c6d0c3e4d/font.ttf",
  "status": "succeeded",
  "input_type": "text",
  "glyph_set": "standard",
  "progress_percent": 100,
  "created_at": "2026-06-02T21:12:42.000Z"
}
```

The JavaScript client returns camel-case response properties. The Python client returns the raw API response dictionary with snake-case keys.

| REST and Python field | JavaScript field  |
| --------------------- | ----------------- |
| `input_type`          | `inputType`       |
| `glyph_set`           | `glyphSet`        |
| `progress_percent`    | `progressPercent` |
| `ttf_url`             | `ttfUrl`          |
| `created_at`          | `createdAt`       |
| `poll_url`            | `pollUrl`         |

<Note>
  Generated TTF URLs are temporary and will be deleted after 24 hours. Download
  each generated TTF file and save it separately if you need to preserve it.
</Note>

###

<CardGroup cols={3}>
  <Card title="Generate from Image" icon="image" href="/docs/api-reference/font-generations/create-from-image">
    Review the image generation endpoint.
  </Card>

  <Card title="Generate from Prompt" icon="keyboard" href="/docs/api-reference/font-generations/create-from-text">
    Review the prompt generation endpoint.
  </Card>

  <Card title="Generation Status" icon="list-check" href="/docs/api-reference/font-generations/get-status">
    Review the polling endpoint.
  </Card>
</CardGroup>
