最初の科学図を生成する
必要なのは API キーと 2 つのリクエストフィールドだけです。図を送信し、進行状況を確認し、結果をダウンロードする手順に従ってください。
API キーを保存
コンソールのキーで fl_live_... を置き換えてください。環境変数にするとコードに含めずに済みます。
export FIGURELABS_API_KEY="fl_live_..."
生成リクエストを送信
この最小リクエストは、テキストから新しい図を作成するよう FigureLabs に依頼します。
curl -X POST https://api.figurelabs.ai/v1/images/generations \ -H "Authorization: Bearer $FIGURELABS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt":"Create a clean scientific figure of the PI3K-AKT signaling pathway", "mode":"generations" }'
prompt必須作りたい図を説明します。英語のプロンプトはラベルと科学的詳細が最も安定しやすいです。
mode任意一般的な画像ワークフローでは generations を使います。mode を省略した場合のデフォルトでもあります。
タスク ID を保存
生成はバックグラウンドで実行されます。最初のレスポンスはタスク受理の確認であり、最終画像はまだ含まれません。
{
"task_id": "tsk_01JZ9F7KQ2",
"status": "processing",
"estimated_price": 80,
"currency": "USD"
}
結果を確認
返された task_id を使います。ステータスが最終状態になるまで 2〜5 秒ごとに確認してください。
curl https://api.figurelabs.ai/v1/tasks/tsk_01JZ9F7KQ2 \ -H "Authorization: Bearer $FIGURELABS_API_KEY"
図をダウンロード
タスクが成功したら output_url からファイルを保存します。署名付き結果 URL は 7 日間利用できます。
"status": "succeeded",
"output_url": "https://files.figurelabs.ai/presigned/...",
"output_type": "image/png",
"actual_price": 80
}
生成機能
一般的な画像生成・編集タスクはすべて POST /v1/images/generations を使います。generations モードでは、プロンプト、ソースファイル、パレット、目標比率からユーザー意図を推論します。
公開 mode 値
| mode | 使用タイミング | 必須入力 |
|---|---|---|
generations | Text generation, sketch conversion, reference generation, enhancement, recoloring, and aspect-ratio editing. This is the default when mode is omitted. | Prompt and/or source files, depending on the task. |
region_redraw | Force the regional-redraw processing path. | Prompt, original image, and one mask. |
white_background | Force the white-background processing path. | Image or sessionId; prompt is optional. |
generations 内で推論される機能
Text to FigurePrompt only; creates a new scientific figure.自動ルーティングSketch to FigurePrompt plus a rough sketch image.自動ルーティングReference to FigurePrompt plus a visual or layout reference.自動ルーティングEnhanceExisting image plus an enhancement instruction.自動ルーティングRecolorExisting image, recolor instruction, and optional colorPalette.自動ルーティングAspect RatioExisting image and optional targetRatio. If omitted, FigureLabs selects a suitable ratio for the task.自動ルーティング例
{
"mode": "generations",
"prompt": "Recolor this pathway using a restrained blue and green palette",
"files": ["file_image123"],
"colorPalette": "#2563EB,#14B8A6"
}ファイルのアップロードとストレージ
ローカルの画像またはドキュメントをアップロードして file_id を受け取り、その ID を生成またはフローチャートリクエストに渡します。アップロードされたファイルは一時的な API 入力であり、永続クラウドストレージではありません。
セルフサーブストレージ階層
A new self-serve account starts with 0 storage until its first successful wallet top-up. A successful top-up moves the account to the matching storage tier. The achieved quota does not decrease when API usage later reduces the wallet balance. All API keys under the same account share this limit.
| チャージ後のウォレット合計 | ファイルストレージ |
|---|---|
| $0 before first top-up | 0 GB |
| More than $0 and up to $10 | 1 GB |
| More than $10 and up to $50 | 2 GB |
| More than $50 and below $200 | 5 GB |
| $200 or more | 20 GB |
エンタープライズアカウント
Enterprise storage allowance is defined in the enterprise agreement and is not calculated from wallet balance. If the agreement does not specify a custom allowance, the default is 50 GB. Contact enterprise support to confirm or change the contracted allowance.
ファイルの有効期間と削除
Uploaded files are valid for 7 days. After 7 days, a file can no longer be used through the external API by file_id and is not counted toward file storage.
- Deleting a file makes its file ID unavailable immediately and removes it from the storage calculation.
- The console shows metadata and a Delete action only. It does not preview, open, or download uploaded file content.
ローカルファイルをアップロードして使用
curl -X POST https://api.figurelabs.ai/v1/files \ -H "Authorization: Bearer $FIGURELABS_API_KEY" \ -F "file=@./reference.png" \ -F "purpose=image_generation"
{
"mode": "generations",
"prompt": "Redraw this as a clean publication figure",
"files": ["file_abc123"]
}モデル、速度、アスペクト比
任意の model フィールドでモデルを固定できます。省略すると、API キーで許可されワークフローと比率に適合する推奨モデルを FigureLabs が選びます。
| モデル値 | 表示名 | 目安時間 | 対応する targetRatio 値 |
|---|---|---|---|
gemini-3-pro-image-preview | Nano Banana Pro | ~30 sec | 16:9, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 21:9 |
nano-banana-2 | Nano Banana 2 | ~30 sec | 16:9, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 21:9 |
gpt-image-2 | GPT Image 2 | ~90 sec | 16:9, 1:1, 2:3, 3:2, 4:5, 5:4, 9:16 |
nano-banana | Nano Banana | ~15 sec | 16:9, 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 21:9 |
gpt-image-1 | GPT Image 1.5 | ~90 sec | 3:2, 1:1, 2:3 |
seedream-5-0-260128 | Seedream 5.0 Lite | ~120 sec | 16:9, 1:1, 2:3, 3:4, 9:16, 3:2, 4:3, 21:9 |
seedream-4-5-251128 | Seedream 4.5 | ~30 sec | 16:9, 1:1, 2:3, 3:4, 9:16, 3:2, 4:3, 21:9 |
flux-kontext-max | Flux.2 Max | ~15 sec | 4:3, 1:1, 16:9, 9:16, 21:9, 2:3, 5:1, 3:2, 3:7, 7:3 |
sora-image | Sora | ~90 sec | 3:2, 1:1, 2:3 |
比率選択の仕組み
Image generation uses targetRatio; Flowcharts uses ratio. Use colon notation such as 16:9, not pixels or a display label.
- If a model is specified, choose one of its supported ratios.
- If no targetRatio is sent, FigureLabs determines a suitable output ratio from the prompt, source files, and generation task.
- If no model is sent, FigureLabs selects a compatible model using the prompt, input type, requested targetRatio, and available models for the API key.
生成出力を制御
基本的な生成にはプロンプトとワークフローが必要です。モデル、比率、スタイル、パレット、形式、セッションのフィールドは、より細かく制御したいときだけ追加します。
prompt条件付きMaximum 2,000 characters. Required for generation and edit modes that need instructions.
mode任意Defaults to generations. Public values are generations, region_redraw, and white_background.
model任意Lock a model. Omit it to use the recommended compatible model.
targetRatio条件付きOptional. Send a supported ratio to force the output shape; omit it to let FigureLabs choose a suitable ratio from the generation task.
style任意Flat, 3D, 2.5D, hand_drawn, or line_art. Default: Flat.
format任意png by default. vector generates then vectorizes to SVG.
quality任意V1 supports only high. It is the default and does not change price.
sessionId任意Continue an existing conversation. Omit it to create a new session.
colorPalette任意Pass 1–8 comma-separated colors in #RRGGBB format. The palette guides the model, especially for recolor, but does not strictly limit every output color. Omit it or pass an empty string to let the model choose.
例
{
"model": "nano-banana",
"prompt": "Create a publication-ready mitochondrial pathway figure",
"mode": "generations",
"style": "Flat",
"targetRatio": "16:9",
"colorPalette": "#0F172A,#2563EB,#14B8A6",
"format": "png"
}画像の生成と編集
テキスト生成、スケッチと参照ワークフロー、強化、領域再描画、再着色、白背景、アスペクト比編集に 1 つのエンドポイントを使います。
リクエストパラメータ
| フィールド | 型 | 必須? | 説明 |
|---|---|---|---|
model | string | 任意 | Model value from Models & ratios. Omit for recommended routing. |
prompt | string | Conditional | Maximum 2,000 characters. Required for generation and instruction-driven edits. |
sessionId | string | 任意 | Continue an existing session; a new session is created when omitted. |
mode | string | 任意 | Routing mode. Default: generations. Other values: region_redraw and white_background. |
style | string | 任意 | Flat, 3D, 2.5D, hand_drawn, or line_art. Default: Flat. |
colorPalette | string | 任意 | 1–8 comma-separated #RRGGBB colors used as visual guidance. |
imageUrl | string / object / array | 任意 | Legacy-compatible reference input: URL, Data URI, file object, file ID, or array. |
files | string / object / array | 任意 | Image or document inputs. Merged with imageUrl. |
mask | string / object | Conditional | One image; required and only valid for region_redraw. |
targetRatio | string | Conditional | Optional ratio such as 16:9. Omit it to let FigureLabs choose a suitable ratio for the generation task. |
format | string | 任意 | png (default) or vector. Vector runs generation plus SVG conversion. |
quality | string | 任意 | V1 supports only high; default high; no price change. |
quoteMessageId | number | 任意 | Message to edit. Requires sessionId; otherwise ignored. |
safetyIdentifier | string | 任意 | Your non-sensitive end-user reference for safety auditing. |
ルーティングモード
| mode | 動作 | 入力要件 |
|---|---|---|
generations | Agent automatically identifies text, sketch, reference, enhance, recolor, or aspect-ratio intent. | Prompt and/or source files. Default when omitted. |
region_redraw | Fixed regional-redraw processing. | Prompt, original image, and one mask. |
white_background | Fixed white-background processing. | Image or sessionId; prompt optional. |
リクエスト例
Text to figure
{
"model": "gpt-image-2",
"prompt": "A publication-ready mitochondrial metabolism pathway",
"mode": "generations",
"style": "Flat",
"colorPalette": "#111111,#2F80ED,#27AE60",
"targetRatio": "16:9",
"format": "png"
}Reference image
{
"model": "nano-banana",
"prompt": "Redraw this as a clean Nature-style schematic",
"mode": "generations",
"imageUrl": "https://example.com/input/figure.png",
"targetRatio": "4:3"
}Regional redraw with mask
{
"prompt": "Redraw the masked area as a microscope panel",
"mode": "region_redraw",
"files": ["file_image123"],
"mask": "file_mask123"
}作成レスポンス
| フィールド | 型 | 意味 |
|---|---|---|
task_id | string | Save this ID and query Tasks. |
session_id | string | Use it to continue the same session. |
status | string | Usually processing. |
estimated_price | number | Estimated hold in USD cents. |
currency | string | USD in V1. |
画像をアップスケール
1 枚のラスター画像を 2K、4K、または 8K ターゲットに拡大します。成功時の出力は PNG です。
リクエストパラメータ
| フィールド | 型 | 必須? | 説明 |
|---|---|---|---|
image_url | string / object / array | 必須 | URL, Data URI, file object, or file ID. If an array is sent, the first valid image is used. |
target_size | string | 任意 | 2k, 4k, 8k, or width x height such as 4096x2048. Default: 2K tier. |
safety_identifier | string | 任意 | Your non-sensitive end-user reference. |
ターゲット階層と価格
| 値 | 長辺の目標 | 標準価格 |
|---|---|---|
2k or omitted | Approximately 2,048 px | $0.02 |
4k | Approximately 4,096 px | $0.04 |
8k | Approximately 8,192 px | $0.08 |
4096x2048 | Larger dimension selects the tier | $0.04 |
例
{
"image_url": "https://example.com/input/source.png",
"target_size": "4k",
"safety_identifier": "user_12345"
}画像をベクトル化
1 枚のラスター画像をスケーラブルな SVG に変換します。V1 はタスクあたり 1 画像を処理します。
リクエストパラメータ
| フィールド | 型 | 必須? | 説明 |
|---|---|---|---|
image_url | string / object | 必須 | One bitmap URL, Data URI, file object, or file ID. |
safety_identifier | string | 任意 | Your non-sensitive end-user reference. |
例
{
"image_url": "https://example.com/input/chart.png"
}フローチャートを生成
プロンプトと任意の画像またはドキュメント入力から SVG の研究ワークフローを作成します。
リクエストパラメータ
| フィールド | 型 | 必須? | 説明 |
|---|---|---|---|
prompt | string | 必須 | Non-empty flowchart instruction. |
session_id | string | 任意 | Continue an existing session; creates a new session when omitted. |
ratio | string | 任意 | Output ratio such as 16:9 or 1:1. |
file_url | string / object / array | 任意 | Legacy single-file field; also accepts file object, file ID, or array. |
files | string / object / array | 任意 | URL, Data URI, file object, or file ID array. Merged with file_url. |
例
{
"prompt": "Draw a single-cell RNA-seq workflow from tissue dissociation to marker annotation",
"ratio": "16:9"
}ソースファイルあり
{
"prompt": "Convert this rough process sketch into a polished SVG flowchart",
"ratio": "4:3",
"files": ["file_sketch123"]
}ファイル
一時的なタスク入力をアップロードし、開発者コンソールからアップロードファイルのメタデータを管理します。
アップロード要件
Uploads must pass authentication, file-type, file-size, and account storage-limit checks. Rejected uploads are not stored or counted toward account usage.
フォームフィールド
| フィールド | 型 | 必須? | 説明 |
|---|---|---|---|
file | file | 必須 | Image or document. Video and audio are not supported. |
purpose | string | 任意 | general, image_generation, flowchart, or mask. Default: general. |
レスポンスフィールド
| フィールド | 説明 |
|---|---|
id | File ID to pass to a task request. |
file_name, mime_type, size | Uploaded-file metadata. |
created_at, expires_at | UTC upload time and the 7-day external expiry time. |
アップロード例
curl -X POST https://api.figurelabs.ai/v1/files \ -H "Authorization: Bearer $FIGURELABS_API_KEY" \ -F "file=@./reference.pdf" \ -F "purpose=image_generation"
{
"id": "file_abc123",
"file_name": "reference.pdf",
"mime_type": "application/pdf",
"size": 204800,
"created_at": "2026-08-04T10:22:00Z",
"expires_at": "2026-08-11T10:22:00Z"
}ファイルの管理と削除
Open Developer console → Files to review uploaded-file metadata or delete a file. Deletion requires confirmation.
After deletion, the file_id becomes unavailable immediately and the file no longer counts toward file storage. Already-submitted tasks continue. Data retention follows the FigureLabs privacy policy.
ストレージ上限エラー
| HTTP | errorCode | 意味 |
|---|---|---|
| 413 | STORAGE_QUOTA_EXCEEDED | The new file would exceed the account's file storage limit. |
タスク結果を照会
Generate、Upscale、Vectorize、Flowchart タスクには共有タスクエンドポイントを使います。キーは自アカウント所有のタスクのみ照会できます。
パスパラメータ
| パラメータ | 型 | 必須? | 説明 |
|---|---|---|---|
task_id | string | 必須 | ID returned by a task creation endpoint; usually starts with tsk_. |
レスポンスフィールド
| フィールド | 型 | 説明 |
|---|---|---|
task_id | string | Task ID. |
session_id | string | Session ID for follow-up generation. |
status | string | pending, processing, succeeded, failed, rejected, or canceled. |
output_url | string / null | Seven-day signed result URL after success. |
output_type | string / null | For example image/png, image/svg+xml, png, or svg. |
error | object / null | Error details for failed or rejected tasks. |
error.code | string | Public task error code. |
error.message | string | Human-readable task error. |
actual_price | number / null | Final charge in USD cents after success. |
estimated_price | number / null | Estimated hold in USD cents. |
currency | string / null | USD in V1. |
created_at | string / null | UTC RFC 3339 time, ending in Z. |
finished_at | string / null | Completion time; null until finished. |
ポーリングの推奨
- Poll every 2–5 seconds.
- Use a longer interval for slower models such as gpt-image-2 and seedream-5-0-260128.
- Stop when status is succeeded, failed, rejected, or canceled.
- Persist task_id so a network interruption does not lose the result lookup.
成功結果
{
"task_id": "tsk_01JZ9F7KQ2",
"status": "succeeded",
"output_url": "https://files.figurelabs.ai/presigned/...",
"output_type": "image/png",
"error": null,
"actual_price": 80,
"estimated_price": 80,
"currency": "USD",
"created_at": "2026-07-31T10:20:30Z",
"finished_at": "2026-07-31T10:21:02Z"
}失敗または拒否されたタスク
actual_price is null and the estimated hold is released. Use UPSTREAM_FAILED for processing failure and UPSTREAM_SAFETY_REJECTED for a safety refusal.
エラー処理
FigureLabs がタスクを作成したかどうかに応じて、エラー処理を分けてください。
HTTP errorAuthentication, balance, permission, or validation failed before task creation. Read the top-level error response.
Task errorA task exists but finishes as failed or rejected. Query Tasks and read its error object. It is not charged.
HTTP エラー形式
{
"code": 401000,
"errorCode": "INVALID_API_KEY",
"message": "Invalid API key.",
"requestId": "req_abc123"
}よくある HTTP エラー
| HTTP | errorCode | 意味 | 推奨アクション |
|---|---|---|---|
| 401 | INVALID_API_KEY | Key missing, malformed, or unknown. | Check the Authorization header. |
| 401 | API_KEY_REVOKED | The key was permanently revoked. | Create and use a new key. |
| 403 | API_KEY_DISABLED | The key is disabled. | Enable it or use another key. |
| 403 | CUSTOMER_DISABLED | The customer account cannot make calls. | Contact account support. |
| 403 | MODEL_NOT_ALLOWED | The key cannot use the selected model. | Change model or allowed-model settings. |
| 402 | INSUFFICIENT_BALANCE | The wallet cannot cover the task. | Add funds and submit again. |
| 402 | BILLING_FAILED | The billing hold or charge failed. | Retry later or contact support. |
| 409 | IDEMPOTENCY_KEY_CONFLICT | The same key was reused with a different body. | Use a new Idempotency-Key. |
| 429 | RATE_LIMITED | Request rate exceeded. | Wait and retry with backoff. |
| 429 | CONCURRENT_TASK_LIMIT_EXCEEDED | Too many tasks are running. | Wait for active tasks to finish. |
| 422 | INVALID_PROMPT | Prompt or required field validation failed. | Review required fields and limits. |
| 422 | MODEL_MODE_NOT_SUPPORTED | The model cannot perform this workflow. | Omit model or choose another model. |
| 400 / 422 | 1001011026 | File, target size, or task parameter is invalid. | Review request fields and values. |
| 400 / 422 | 1001011051 | The file ID does not exist. | Upload again or use a valid file ID. |
| 403 | 1001011052 | The file belongs to another account. | Use a file uploaded by this account. |
| 400 / 422 | 1001011053 | Unsupported file type. | Use an accepted image or document. |
| 400 / 422 | 1001011054 | More than five ordinary input files. | Reduce the number of inputs. |
| 400 / 422 | 1001011055 | Decoded file size exceeds the limit. | Compress or resize the file. |
| 500 | 1001011056 | File upload or reading failed. | Retry the upload. |
| 404 | 1001011019 | Task missing or owned by another account. | Check task_id and API key account. |
| 500 | INTERNAL_ERROR | FigureLabs platform error. | Retry with backoff; contact support if persistent. |
タスク終端エラー
| タスクステータス | error.code | 意味 | 課金? |
|---|---|---|---|
failed | UPSTREAM_FAILED | Generation or processing failed. | No |
rejected | UPSTREAM_SAFETY_REJECTED | The safety policy refused the request. | No |
レート制限レスポンスヘッダー
| ヘッダー | 意味 |
|---|---|
X-RateLimit-Limit | Current rate limit. |
X-RateLimit-Remaining | Requests remaining in the current window. |
X-RateLimit-Reset | Suggested wait in seconds. |
Retry-After | How long to wait before retrying. |
ファイルストレージエラー
| HTTP | errorCode | 推奨アクション |
|---|---|---|
| 413 | STORAGE_QUOTA_EXCEEDED | Delete files from the console, wait for expiry, or increase the account quota. |
モデルポリシー
FigureLabs と選択したモデルプロバイダーは、プロンプトとアップロード内容に安全チェックを適用します。
リクエストが拒否された場合
The task returns status=rejected with a concise reason. Show that reason to your user, let them revise the input, and do not retry the same content automatically.
エンドユーザー向けアプリケーションの場合
Pass a non-sensitive user reference in safetyIdentifier. Do not send names, email addresses, or other personal data.
llms.txt
コーディングエージェントに、対応エンドポイント、認証、タスクポーリング、エラー処理の簡潔な索引を提供します。
場所
エージェントで使う
Read https://developer.figurelabs.ai/llms.txt and build a server-side integration that generates a scientific figure, polls the task, and handles rejected requests.