# Tokenify, for coding agents

Tokenify is the image and video API for one-person companies, made to be used
from inside coding agents: an MCP server, and the same models over HTTP, behind
one key and one prepaid balance; text models are on the same key. A user who
pointed you here wants you to make something with it.

## Money

1. Before each call, work out what it will cost from the model's file below,
   and tell the user. Video prices per second are estimates, so round a
   video's cost up, not down.
2. If this task's total could reach $1 or more, or you cannot work out
   what a call will cost, ask the user before making it.
3. If a call is refused with 402 `insufficient_credit`, stop and tell the user to
   top up in the console at https://www.tokenify.dev/app/; do not retry. A 429 with
   `daily_budget_spent` means the key's daily budget is used up: stop too.

## The key

Use the key in the TOKENIFY_API_KEY environment variable. If it is not set,
ask the user to create one in the console at https://www.tokenify.dev/app/, under Keys — one for you
alone, with a daily budget, is the safe choice — and to set it. Do not ask for
the key in the chat.

## Installing

If your client speaks MCP, the Tokenify MCP server at https://api.tokenify.dev/mcp is the easier
way: the user adds it once (Claude Code:
`claude mcp add --transport http tokenify https://api.tokenify.dev/mcp`; Codex:
`codex mcp add tokenify --url https://api.tokenify.dev/mcp`, then `codex mcp login tokenify`)
and signs in through the browser, and its tools price, generate and hand out a
top-up link — see https://www.tokenify.dev/docs/mcp/. Otherwise call the HTTP API directly, as
below; there is nothing to install beyond curl and jq. Each snippet ends with a
failing status when it did not save its result.

## An image

```bash
REPLY=$(curl -sS --max-time 180 https://api.tokenify.dev/v1/images/generations \
  -H "Authorization: Bearer $TOKENIFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bytedance/seedream-5.0-flash",
    "prompt": "A still life of three pears, soft window light",
    "size": "1K"
  }')
SENT=$?
IMAGE=$(echo "$REPLY" | jq -r '.data[0].b64_json // empty' 2>/dev/null)
if [ -n "$IMAGE" ]; then
  echo "$IMAGE" | base64 --decode > image.jpg
elif [ $SENT -ne 0 ]; then
  echo "No reply (curl exit $SENT): the image may have been made and charged." >&2
  echo "Tell the user before sending it again." >&2; false
else
  echo "$REPLY" >&2; false
fi
```

The image comes back inline as base64 by default. A refusal is JSON with an
`error`, printed instead, and the snippet ends with a failing status. Its price is in
https://www.tokenify.dev/models/seedream-5-0-flash.md.

## A video

```bash
SUBMIT=$(curl -sS --max-time 60 https://api.tokenify.dev/contents/generations/tasks \
  -H "Authorization: Bearer $TOKENIFY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "minimax/minimax-h3-economy",
    "resolution": "480p",
    "duration": 4,
    "ratio": "16:9",
    "content": [{"type": "text", "text": "A paper boat on still water, dawn light"}]
  }')
SENT=$?
TASK=$(echo "$SUBMIT" | jq -r '.id // empty' 2>/dev/null)
SAVED=0
if [ -z "$TASK" ] && [ $SENT -ne 0 ]; then
  echo "No reply (curl exit $SENT): the job may have been accepted and will be billed." >&2
  echo "Do not submit it again; tell the user." >&2
elif [ -z "$TASK" ]; then
  echo "$SUBMIT" >&2
else
  echo "Task $TASK submitted."
  # A job not finished in thirty minutes is given up on and refunded.
  for _ in $(seq 360); do
    sleep 5
    REPLY=$(curl -sS --max-time 30 --retry 3 https://api.tokenify.dev/contents/generations/tasks/$TASK \
      -H "Authorization: Bearer $TOKENIFY_API_KEY") || continue
    case $(echo "$REPLY" | jq -r '.status // empty' 2>/dev/null) in
      queued|running) ;;
      succeeded)
        URL=$(echo "$REPLY" | jq -r '.content.video_url // empty')
        [ -n "$URL" ] && curl -fsS --max-time 600 --retry 3 -o video.mp4.part "$URL" &&
          mv video.mp4.part video.mp4 && SAVED=1
        break ;;
      *) echo "$REPLY" >&2; break ;;
    esac
  done
  [ $SAVED = 1 ] || echo "Task $TASK is not saved: poll it again rather than submitting a new job." >&2
fi
[ $SAVED = 1 ]
```

Submit once. If a submission gets no reply, do not send it again — it may
have been accepted, and a second submission is a second job, billed — but tell
the user. The task id is printed as soon as there is one: a job that finished
and failed to download is fetched by polling it again, not by resubmitting. A project
whose credited top-ups, less any refunded, come to less than $5 is refused with
402 `video_needs_topup`: tell the user, with the link in the reply. Its price
is in https://www.tokenify.dev/models/minimax-h3-economy.md.

## Save what comes back

Write every result into the project. Decode an image that comes back inline,
and download anything returned as a link: a link expires 7 days after the
result was made.

## Choosing a model, and its price

- [MiniMax H3 Economy](https://www.tokenify.dev/models/minimax-h3-economy.md) — `minimax/minimax-h3-economy`, from about $0.0150 a second
- [Seedance 2.0 Mini](https://www.tokenify.dev/models/seedance-2-0-mini.md) — `bytedance/seedance-2.0-mini`, from about $0.0205 a second
- [MiniMax H3 Lite](https://www.tokenify.dev/models/minimax-h3-lite.md) — `minimax/minimax-h3-lite`, from about $0.0213 a second
- [MiniMax H3 Max Turbo](https://www.tokenify.dev/models/minimax-h3-max-turbo.md) — `minimax/minimax-h3-max-turbo`, from about $0.0213 a second
- [MiniMax H3 Economy Fast](https://www.tokenify.dev/models/minimax-h3-economy-fast.md) — `minimax/minimax-h3-economy-fast`, from about $0.0240 a second
- [Seedance 2.0 Fast](https://www.tokenify.dev/models/seedance-2-0-fast.md) — `bytedance/seedance-2.0-fast`, from about $0.0327 a second
- [MiniMax H3 Highspeed](https://www.tokenify.dev/models/minimax-h3-highspeed.md) — `minimax/minimax-h3-highspeed`, from about $0.0340 a second
- [MiniMax H3 Max](https://www.tokenify.dev/models/minimax-h3-max.md) — `minimax/minimax-h3-max`, from about $0.0425 a second
- [MiniMax H3](https://www.tokenify.dev/models/minimax-h3.md) — `minimax/minimax-h3`, from about $0.0680 a second
- [MiniMax H3 Economy Max](https://www.tokenify.dev/models/minimax-h3-economy-max.md) — `minimax/minimax-h3-economy-max`, from about $0.0680 a second
- [Seedance 2.0](https://www.tokenify.dev/models/seedance-2-0.md) — `bytedance/seedance-2.0`, from about $0.0681 a second
- [Seedance 2.5 Flash](https://www.tokenify.dev/models/seedance-2-5-flash.md) — `bytedance/seedance-2.5-flash`, from about $0.0681 a second
- [Seedance 2.5](https://www.tokenify.dev/models/seedance-2-5.md) — `bytedance/seedance-2.5`, from about $0.1041 a second
- [Seedream 5.0 Flash](https://www.tokenify.dev/models/seedream-5-0-flash.md) — `bytedance/seedream-5.0-flash`, from $0.018 an image
- [Seedream 5.0 Lite](https://www.tokenify.dev/models/seedream-5-0-lite.md) — `bytedance/seedream-5.0-lite`, from $0.028 an image
- [Seedream 5.0 Pro](https://www.tokenify.dev/models/seedream-5-0-pro.md) — `bytedance/seedream-5.0-pro`, from $0.036 an image
- [DeepSeek V4.1 Flash](https://www.tokenify.dev/models/deepseek-v4-1-flash.md) — `deepseek/deepseek-v4.1-flash`, $0.15 in / $0.60 out per 1M tokens at peak
- [GLM 5.3 Flash](https://www.tokenify.dev/models/glm-5-3-flash.md) — `z-ai/glm-5.3-flash`, $0.15 in / $0.50 out per 1M tokens at peak
- [DeepSeek V4 Flash](https://www.tokenify.dev/models/deepseek-v4-flash.md) — `deepseek/deepseek-v4-flash`, $0.22 in / $0.66 out per 1M tokens at peak
- [DeepSeek V4 Pro](https://www.tokenify.dev/models/deepseek-v4-pro.md) — `deepseek/deepseek-v4-pro`, $0.66 in / $1.98 out per 1M tokens at peak
- [GLM 5.2](https://www.tokenify.dev/models/glm-5-2.md) — `z-ai/glm-5.2`, $0.70 in / $2.20 out per 1M tokens at peak

Everything else — every endpoint and dialect, errors, limits — is in
https://www.tokenify.dev/llms.txt and https://www.tokenify.dev/llms-full.txt.
