Skip to main content
Use the JavaScript client in Node.js 18 or newer, or in server-side runtimes that provide fetch.

Install

npm install mixfont
View the package on npm.

Generate a font

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);

Create from an image

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

Methods

MethodDescription
mixfont.generations.create(options)Starts a new generation and returns immediately.
mixfont.generations.get(id)Fetches the current generation status.
mixfont.generations.wait(id, options)Polls until the generation succeeds, fails, is cancelled, or times out.

Create options

Provide exactly one of prompt or imageUrl.
OptionTypeDescription
promptstringText prompt for the generated font.
imageUrlstringPublic HTTPS URL for a reference image.
glyphSet"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 JavaScript client maps API response fields to camel case.
PropertyTypeDescription
idstringGeneration id.
namestringGenerated font display name.
ttfUrlstring or nullGenerated TTF download URL. null until the generation succeeds.
statusstringpreparing, queued, running, succeeded, cancelled, or failed.
inputTypestringtext or image.
glyphSetstringSelected glyph set: standard or extended.
progressPercentnumberApproximate progress from 0 to 100.
pollUrlstringPresent on create responses.
errorstringPresent only when a generation fails and an error message is available.
createdAtstringISO timestamp for when the generation was created.

Wait options

OptionTypeDescription
intervalMsnumberPolling interval. Defaults to 5000.
timeoutMsnumberMaximum wait time. Defaults to 600000.
signalAbortSignalOptional abort signal.