tufty.aitufty.ai CLI
CLI

出力モード

JSONエンベロープ、URLのみの出力、ローカルへの保存、--dry-runによる見積もり。

標準出力と標準エラー出力

tuftyは2種類の出力を厳密に分けています。

  • 標準出力:JSONエンベロープが1つだけ出力されます(--format urlの場合はURLの一覧)。そのままパーサーに渡せます。
  • 標準エラー出力:進行状況、クレジットの見積もり、保存したファイルのパス、ヒントが出力されます。対話型のターミナルで待機している間はドットも表示されますが、エージェントやパイプでは表示されません。

成功時

{
  "ok": true,
  "result": {
    "tool": "pet-dressup",
    "runId": "3f6c2a1e-8b4d-4e7a-9c55-0d2b7e1f4a90",
    "status": "completed",
    "outputs": [
      { "type": "image", "url": "https://static.tufty.ai/.../result.png" }
    ]
  }
}
フィールド説明
toolツールID
runId実行ID。tufty statusで使えます
statuscompleted--no-waitの場合はrunning
outputs[].typeimageまたはvideo
outputs[].url生成物のURL。static.tufty.aiでホストされます
outputs[].path--saveを使った場合の、ローカルファイルの絶対パス

その他のコマンドのresult

コマンドresult
tufty tools list{ tool: "tools.list", data: { locale, tools: [{ id, kind, name, description, command }] } }
tufty tools describe <id>{ tool: "tools.describe", data: マニフェスト内のツールのエントリ }
tufty upload <file>{ tool: "upload", data: { url } }
tufty auth set <apiKey>{ tool: "auth.set", data: { source: "config", saved: true } }
tufty auth get{ tool: "auth.get", data: { source, apiKey } }
tufty login{ tool: "login", data: { saved: true } }
tufty logout{ tool: "logout", data: { removed } }

失敗時

{
  "ok": false,
  "code": "insufficient_balance",
  "message": "Not enough credits (this step needs 75).",
  "details": { "status": 402, "required": 75 }
}

messageはそのまま人に表示できる文言です。プログラムで分岐する場合はcodeを使ってください。すべてのコードはエラーコードに一覧があります。終了コードもあわせて参照してください。

--format url

tufty pet-dressup --product ./sweater.jpg --model ./corgi.jpg --format url

標準出力に生成物のURLが1行に1つずつ出力されます。

https://static.tufty.ai/.../result.png

結果に実際にURLが含まれる場合にのみ有効です。tufty tools list--no-waitのようにURLを含まない結果では、通常どおりエンベロープ全体が出力されます。失敗時も同様です。tufty uploadtufty status--format urlに対応しています。

--save <dir>

tufty image-to-video --still ./corgi-sweater.png --duration 5 --save ./out

実行が完了すると、CLIは各生成物を指定したディレクトリに<runId>-<n><拡張子>という名前でダウンロードします(ディレクトリがなければ作成します)。ダウンロードはいったん.partialファイルに書き込み、完了後に名前を変更します。失敗した場合は最大3回まで試行します。絶対パスはoutputs[].pathに追加されます。

--saveは結果を待機している場合にのみ有効です。--no-waitと組み合わせた場合は何もダウンロードされません。

--dry-run

tufty pet-dressup --product ./sweater.jpg --model ./corgi.jpg ./shiba.jpg --quality medium --count 2 --dry-run

入力を検証し、リクエストのペイロードとクレジットの見積もりを表示します。アップロードも課金も行われず、ログインも不要です。

{
  "ok": true,
  "result": {
    "tool": "pet-dressup",
    "dryRun": true,
    "payload": {
      "tool": "pet-dressup",
      "products": ["./sweater.jpg"],
      "models": ["./corgi.jpg", "./shiba.jpg"],
      "count": 2,
      "quality": "medium"
    },
    "estimatedCredits": 75,
    "creditBreakdown": { "generation": 72, "cutout": 3 }
  }
}

payloadに入るのはアップロード後のURLではなくローカルのパスです。CLIがアップロードするのは本番実行のときだけです。見積もりの計算方法はクレジットを参照してください。

On this page