ReWords.AI API

クイックスタート

ReWords.AI API で最初の画像の文字を置き換えます。OCR、編集の送信、結果の取得を 3 つの curl リクエストで。

API キーが必要です。API パックを購入し、 API キーのページでキーを作成してください(認証を参照)。 シェルに設定します:

export REWORDS_API_KEY=rw_live_your_key

1. 文字を見つける

curl https://api.rewords.ai/v1/ocr \
  -H "Authorization: Bearer $REWORDS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image_url": "https://example.com/banner.png", "language": "en"}'
{
  "image_id": "img_abc123",
  "width": 1080,
  "height": 1350,
  "texts": [
    { "id": "t1", "text": "SALE", "box": [120, 80, 300, 60] },
    { "id": "t2", "text": "50% OFF", "box": [140, 160, 260, 50] }
  ],
  "charged_ocr": 1
}

ボックスは [x, y, 幅, 高さ] で、画像に対する 0–1000 のスケールです。そのため画像のピクセルサイズには依存しません。 image_id は 24 時間再利用できるので、画像を再アップロードする必要はありません。 language には画像内のテキストの言語を指定します(韓国語は ko、日本語は ja など)。言語は自動では判定されず、 指定しないと OCR が正しく読めるのは中国語と英語だけです(FAQ を参照)。

2. 編集を送信する

OCR 結果の box を送るか、from と to だけを送れば、こちらで文字の位置を探します。

curl https://api.rewords.ai/v1/edits \
  -H "Authorization: Bearer $REWORDS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "image_id": "img_abc123",
    "replacements": [
      { "from": "SALE", "to": "HOT DEAL", "box": [120, 80, 300, 60] },
      { "from": "50% OFF", "to": "70% OFF" }
    ]
  }'
{
  "id": "edit_9f8e7d",
  "status": "queued",
  "queue_position": 0,
  "estimated_seconds": 120,
  "replacements": [
    { "from": "SALE", "to": "HOT DEAL", "box": [120, 80, 300, 60] },
    { "from": "50% OFF", "to": "70% OFF", "box": [140, 160, 260, 50] }
  ],
  "balance": 4,
  "created_at": "2026-11-04T13:55:33.240Z"
}

replacements には 50% OFF について見つかったボックスが表示され、balance ではすでに 1 回分の編集が確保されています。 新しいジョブごとに新しい Idempotency-Key を使い、同じキーはそのジョブを再送するときだけ使ってください。再利用したキーは 新しい編集ではなく、以前のジョブを返します。

3. 結果を受け取る

status が succeeded か failed になるまでポーリングします。processing の間、または queued で queue_position が 0 の間は 5 秒ごと、 それより後ろに並んでいる間は 30 秒ごとに問い合わせます。 キューと制限を参照してください。代わりに callback_url を渡して Webhook を受け取ることもできます。

curl https://api.rewords.ai/v1/edits/edit_9f8e7d \
  -H "Authorization: Bearer $REWORDS_API_KEY"
{
  "id": "edit_9f8e7d",
  "status": "succeeded",
  "results": {
    "A": { "status": "succeeded", "url": "https://img.rewords.ai/api/edit_9f8e7d_a.jpg" },
    "B": { "status": "succeeded", "url": "https://img.rewords.ai/api/edit_9f8e7d_b.jpg" },
    "C": { "status": "succeeded", "url": "https://img.rewords.ai/api/edit_9f8e7d_c.jpg" }
  },
  "replacements": [
    { "from": "SALE", "to": "HOT DEAL", "box": [120, 80, 300, 60] },
    { "from": "50% OFF", "to": "70% OFF", "box": [140, 160, 260, 50] }
  ],
  "charged": 1,
  "balance": 4,
  "created_at": "2026-11-04T13:55:33.240Z",
  "completed_at": "2026-11-04T13:56:21.808Z"
}

完全な Node.js と Python のクライアント、その他のすべてのレスポンスはサンプルをご覧ください。

必要な画像はダウンロードしてください。結果は JPEG ファイルで、公開リンクは少なくとも 7 日間保持されます。 A、B、C が何かは結果と返金、URL ではなくローカルファイルをアップロードする方法は画像をご覧ください。

このページの内容