メインコンテンツへスキップ
学習ガイドの章 すべてのドキュメント

Training API リファレンス

登録済みエンドポイント、リクエスト本文、レスポンス、所有権の境界、エラー処理を説明します。

どの言語版でもコマンドとコードは英語のままです。大文字のプレースホルダーは、ご自身のアカウントと有料ジョブの値に置き換えてください。共有ノートブックやログに実際のキーを貼り付けないでください。

API リソースのライフサイクル

見積もり、有料ジョブ、学習セッションはそれぞれ別のリソースです。
  1. 見積もり 設定と現行価格を検証
  2. ジョブ ジョブを作成して承認済みの支払いを完了
  3. セッション 実行環境と付属する参照モデルを選択
  4. 準備 検証済みデータセットのマニフェストを作成
  5. レポート 実際の学習と成果物のメタデータを記録

見積もり: 設定と現行価格を検証. ジョブ: ジョブを作成して承認済みの支払いを完了. セッション: 実行環境と付属する参照モデルを選択. 準備: 検証済みデータセットのマニフェストを作成. レポート: 実際の学習と成果物のメタデータを記録

認証とリクエストのルール

HTTPS を使用し、ai:training を持つアカウント API キーを Authorization: Bearer で送信します。Accept: application/json を指定し、JSON 本文には Content-Type: application/json も追加します。すべてのリソースはアカウントに紐付いています。このルートグループには毎分30リクエストのレート制限があり、設定に応じて追加の制御も適用されます。例に示す ID はプレースホルダーであり、共有リソースを指すものではありません。

  • 見積もり ID、ジョブ UUID、セッション ID、モデル ID、成果物 ID はそれぞれ異なる識別子です。
  • ネットワーク切断後に書き込みを再実行する前に、現在の状態を読み取ってください。
  • API リクエストで公開ページ向けの文言や料金クエリパラメーターを使わないでください。
例 · bash
export TRAINING_API='https://fusionpointai.com/api/v1/training'
# Set the key securely as shown in Quickstart.
export JOB_UUID='REPLACE_WITH_YOUR_JOB_UUID'
export SESSION_ID='REPLACE_WITH_YOUR_SESSION_ID'
curl --fail-with-body --silent --show-error "$TRAINING_API/jobs" \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" -H 'Accept: application/json'

リクエスト、レスポンス、状態

対象となる設定から見積もりを作成し、その見積もりから標準ジョブを作成します。セッションを開く前に、承認済みの支払い手続きを完了してください。プロジェクト用エンドポイントは既存の有料参照モデル利用権を認可し、請求書の作成や価格の変更をせずにカリキュラムやレッスンを要求します。セッションのレスポンスには設定、選択した参照モデル、データセットマニフェスト、報告済みステップ、レポートが含まれます。準備とレポート送信は別のリクエストです。ジョブとセッションの状態は別々に管理されます。

  • プロジェクトの認可には provider と reference_model_id が必要です。教師リクエストには action と objective も必要です。
  • 教師モデルに送れるのは承認済みの学習素材だけです。検証用と最終テスト用の行はローカルに保管します。
  • 従来の完了レポートには実際のローカル成果物を記載し、完全性と評価のチェックを満たす必要があります。
例 · text
POST /api/v1/training/quotes
reference_model_id     required eligible integer model ID
training_plan_id       required public provider-plan integer ID
mode                   automatic | advanced
objective              required string, 10..4000 characters
language               required string, at most 120 characters
performance_criteria   required string, 10..2000 characters
student_release_slug   optional eligible slug, at most 190 characters
method                 optional eligible method, at most 80 characters
dataset_megabytes      optional integer, 1..1000000
gpu_count              optional integer, 1..128
delivery               optional: artifact | hosted
execution_target       optional: fusionpointai_hosting | customer_datacenter | colab

Availability and approved plan policies can impose narrower constraints.
Do not submit price, fixed_total, currency, price_version_id or model_training.
例 · json
{
  "reference_model_id": 123,
  "training_plan_id": "<INTEGER_FROM_YOUR_PROVIDER_PLAN>",
  "mode": "advanced",
  "objective": "Train a German support-message classifier.",
  "language": "German",
  "performance_criteria": "Evaluate per-class precision and recall on held-out data.",
  "student_release_slug": "<ELIGIBLE_STUDENT_RELEASE_SLUG>",
  "method": "LoRA",
  "dataset_megabytes": 8,
  "gpu_count": 1,
  "delivery": "artifact"
}
例 · bash
# Save the body as quote.json; replace ID placeholders with integers.
# Automatic mode omits student_release_slug and method.
curl --fail-with-body --silent --show-error "$TRAINING_API/quotes" \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" \
  -H 'Accept: application/json' -H 'Content-Type: application/json' \
  --data-binary @quote.json
# Save {"quote":"YOUR_QUOTE_UUID"} as job.json.
# Creates a native job/invoice; this is not payment confirmation.
curl --fail-with-body --silent --show-error "$TRAINING_API/jobs" \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" \
  -H 'Accept: application/json' -H 'Content-Type: application/json' \
  --data-binary @job.json
curl --fail-with-body --silent --show-error "$TRAINING_API/jobs/$JOB_UUID" \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" -H 'Accept: application/json'
例 · text
POST /api/v1/training/quotes: 201
{quote: UUID, currency: ISO_CODE, fixed_total: DECIMAL_STRING, expires_at: ISO_8601}

POST /api/v1/training/jobs: {"quote":"OWNED_QUOTE_UUID"}
201 for a newly created job; 200 when an accepted quote reuses its job.
Job fields:
id                job UUID
status            native job state, such as awaiting_payment
progress_percent  recorded progress, not an independent quality score
invoice_id        owned native invoice ID or null
created_at        ISO 8601 timestamp
completed_at      ISO 8601 timestamp or null
training_session  null or {id, status, step, delivery, verification}

GET /api/v1/training/jobs:
{data: JOB_ARRAY, current_page: INTEGER, last_page: INTEGER, per_page: 50, total: INTEGER}

This is a response-shape reference, not a fabricated live response.
例 · bash
# Save as session.json, using your paid job UUID and optional reference ID:
# {"job":"YOUR_PAID_JOB_UUID","runtime":"customer_datacenter","reference_model_id":123}
curl --fail-with-body --silent --show-error "$TRAINING_API/sessions" \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" \
  -H 'Accept: application/json' -H 'Content-Type: application/json' \
  --data-binary @session.json
curl --fail-with-body --silent --show-error "$TRAINING_API/sessions/$SESSION_ID" \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" -H 'Accept: application/json'
# One preparation batch; inspect progress before another request.
curl --fail-with-body --silent --show-error "$TRAINING_API/sessions/$SESSION_ID/prepare" \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" \
  -H 'Accept: application/json' -H 'Content-Type: application/json' --data '{}'
例 · text
Session response fields (shape reference, not a fabricated live result):
id                  session UUID
job                 owned job UUID
status              preparing | ready | running | evaluating | completed | failed | cancelled
configuration       approved method, student_checkpoint, sdk_training and selected reference
reference_model_id  selected integer reference ID
expires_at          ISO 8601 access expiry
step                last reported integer step
datasets[]          {split, rows, bytes, sha256}
report              current report object; event metrics live under report.last_event.metrics
delivery            runtime_local
verification        runtime_reported
例 · bash
curl --fail-with-body --silent --show-error \
  "$TRAINING_API/sessions/$SESSION_ID/datasets/train" \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" \
  -H 'Accept: application/x-ndjson' --output train.jsonl
# Use /datasets/validation for the other supported split.
sha256sum train.jsonl
# Compare bytes, rows and SHA-256 with the session manifest.
# For published server-side artifacts only, not the local SDK ZIP:
# GET /api/v1/training/jobs/{job}/artifacts/{file}
例 · text
POST /api/v1/training/sessions/{session}/events
Content-Type: application/json

state         required: running | evaluating | failed
step          required integer: 0..2000
total_steps   required integer: 1..2000
metrics       optional; only loss and eval_loss, each 0..1000000
error_code    optional: training_failed | evaluation_failed | runtime_unavailable |
              dataset_invalid | report_failed

Send actual trainer observations, never sample or invented metrics.
例 · bash
# Build the body from a REAL SDK report; requires jq.
jq '{artifact_name:"model-package.zip",report:.completion_report}' \
  customer-model-run-001/training-report.json > completion.json
curl --fail-with-body --silent --show-error "$TRAINING_API/sessions/$SESSION_ID/complete" \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" \
  -H 'Accept: application/json' -H 'Content-Type: application/json' \
  --data-binary @completion.json
# Cancel eligible service state, not the operating-system process:
curl --fail-with-body --silent --show-error "$TRAINING_API/sessions/$SESSION_ID/cancel" \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" \
  -H 'Accept: application/json' -H 'Content-Type: application/json' --data '{}'
例 · bash
curl --fail-with-body --silent --show-error \
  'https://fusionpointai.com/api/v1/training/projects/authorize' \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" \
  -H 'Accept: application/json' -H 'Content-Type: application/json' \
  --data '{"provider":"openai","reference_model_id":123}'
# The response identifies the owned paid job/grant and access expiry.
例 · bash
curl --fail-with-body --silent --show-error \
  'https://fusionpointai.com/api/v1/training/projects/teacher' \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" \
  -H 'Accept: application/json' -H 'Content-Type: application/json' \
  --data '{"provider":"openai","reference_model_id":123,"action":"lessons","objective":"Classify support messages into agreed categories.","topic":"ambiguous_requests","count":2,"approved_examples":["A reviewed support training example."]}'
# Send only explicitly approved training examples. Never send held-out rows.
# Curriculum action returns topics; lessons action returns text/topic examples.
例 · python
import os
from fusionpointai_training import TrainingClient

client = TrainingClient(api_key=os.environ["FUSIONPOINTAI_API_KEY"])
session = client.get_session(os.environ["FUSIONPOINTAI_SESSION_ID"])
print("Session:", session["id"])
print("Status:", session["status"])
print("Last reported step:", session["step"])
# Inspection is read-only; status and step are server-reported state.
例 · python
import os
from fusionpointai_training import TrainingClient

client = TrainingClient(api_key=os.environ["FUSIONPOINTAI_API_KEY"])
session = client.get_session(os.environ["FUSIONPOINTAI_SESSION_ID"])
for manifest in session["datasets"]:
    print(
        manifest["split"],
        "rows:", manifest["rows"],
        "bytes:", manifest["bytes"],
        "sha256:", manifest["sha256"],
    )
# These are server-provided manifest values, not a local integrity pass.
例 · python
import os
from fusionpointai_training import TrainingClient

client = TrainingClient(api_key=os.environ["FUSIONPOINTAI_API_KEY"])
session = client.get_session(os.environ["FUSIONPOINTAI_SESSION_ID"])
server_report = session.get("report")
runtime_report = server_report.get("runtime") if isinstance(server_report, dict) else None
if (
    session.get("status") == "completed"
    and isinstance(runtime_report, dict)
    and runtime_report.get("artifact_sha256") == os.environ["LOCAL_ARTIFACT_SHA256"]
    and server_report.get("delivery") == "runtime_local"
    and server_report.get("verification") == "runtime_reported"
):
    print("Server report matches the local artifact digest.")
else:
    print("Completion is not confirmed for this local artifact.")
# Reconcile by reading state; do not repeat training or invent a result.

エラーと安全な連携

すべてのエラーが一時的なものと決めつけず、HTTP ステータスと返された入力検証の詳細に基づいて処理します。未認証は 401、アクセス拒否は 403、リソースが存在しない、または所有していない場合は 404、状態の不整合は 409、無効な入力は 422、レート制限は 429 です。プロバイダーや実行環境の障害では、その他のエラーが返る場合があります。SDK は APIError を公開し、秘密情報を含む上流の生出力は返しません。

  • イベントで指定できる状態は running、evaluating、failed です。メトリクスのキーは loss と eval_loss です。
  • step と total_steps の上限は 2000 であり、total_steps は正の値である必要があります。
  • complete の本文には artifact_name と、例に示すすべてのレポート項目が必要です。
例 · text
401  Authentication missing or invalid
403  Account/key scope or access denied
404  Resource missing, non-owned or intentionally hidden
409  Invalid session transition, runtime, paid-access or model configuration
410  Writable session expired
422  Invalid request fields or completion criteria not met
429  Request rate limited
502  Upstream reference data malformed or preparation failed

Do not retry a write blindly. Read session state and inspect the response.
Keep error_code distinct from the HTTP status. Never log authorization.
例 · text
POST /api/v1/training/sessions/{session}/complete
artifact_name                 safe filename ending in .zip, max 160 characters
report.training_steps         integer 1..2000
report.weights_before_sha256  lowercase SHA-256 of actual pre-training weights
report.weights_after_sha256   lowercase SHA-256 of actual changed weights
report.artifact_sha256        lowercase SHA-256 of the real local ZIP
report.artifact_bytes         integer 1..107374182400
report.eval_loss_before       finite number >0 and <=1000000
report.eval_loss_after        finite number >=0 and <=1000000
report.base_repository        pinned student repository, max 255 characters
report.base_revision          lowercase immutable 40-character revision
report.method                 SFT | LoRA | QLoRA

Values must match the approved session and actual local training.
Additional report keys are rejected. This body does not upload the ZIP.
例 · python
import os
from fusionpointai_training import TrainingClient
from fusionpointai_training.errors import APIError

client = TrainingClient(
    api_key=os.environ["FUSIONPOINTAI_API_KEY"],
    timeout=30.0,
    max_get_retries=2,
)
try:
    session = client.get_session(os.environ["FUSIONPOINTAI_SESSION_ID"])
except APIError:
    # GET retries are bounded. Do not blindly retry a write after an error.
    print("Session inspection failed; check access and current server state.")
else:
    print("Status:", session["status"])
# Never print the API key, authorization headers, or response secrets.

API リファレンス

エンドポイント目的と動作
POST /api/v1/training/quotes Authorization: Bearer ai:training 利用可能な参照モデル、プラン、設定を検証し、見積もり UUID、通貨、fixed_total、expires_at を返します。任意のクライアント価格ではなく、承認済みプランと条件を満たす生徒モデル設定を使用してください。
GET /api/v1/training/jobs Authorization: Bearer ai:training 認証済み顧客のジョブ一覧を返します。数値 ID を推測せず、返されたコレクションとリソース ID を確認してください。
POST /api/v1/training/jobs Authorization: Bearer ai:training 有効な見積もり UUID からアカウント所有のジョブを作成します。レスポンスにはジョブ ID、ステータス、請求書 ID、タイムスタンプが含まれます。ジョブの作成は支払いの証明ではありません。
GET /api/v1/training/jobs/{job} Authorization: Bearer ai:training ジョブ UUID を指定して、自分が所有する1件のジョブを読み取り、最新の進捗と提供状況を確認します。
GET /api/v1/training/jobs/{job}/artifacts/{file} Authorization: Bearer ai:training この所有ジョブに属する公開済みファイルをダウンロードします。ローカルの SDK ZIP は自動でアップロードされないため、このルートから取得できるとは限りません。
POST /api/v1/training/sessions Authorization: Bearer ai:training 本文:ジョブ UUID、runtime、任意の正の整数 reference_model_id。新規または再利用されたセッションを返します。参照モデルを変更できるのは準備開始前のみです。
GET /api/v1/training/sessions/{session} Authorization: Bearer ai:training 所有するセッションと、その設定、データセット、レポート、状態を読み取ります。状態を読み取っても学習は開始されません。
POST /api/v1/training/sessions/{session}/prepare Authorization: Bearer ai:training 空の JSON オブジェクトを送り、回数を制限した準備バッチを要求します。進展がある間は、リクエスト予算内で準備完了まで繰り返します。
GET /api/v1/training/sessions/{session}/datasets/{split} Authorization: Bearer ai:training train または validation を application/x-ndjson 形式でダウンロードします。そのセッションのマニフェストに照らしてバイト列、SHA-256、行数を検証してください。
POST /api/v1/training/sessions/{session}/events Authorization: Bearer ai:training 実際の状態、step、total_steps、および任意の loss/eval_loss メトリクスを報告します。サポートされている状態とエラーコードのみを使用してください。
POST /api/v1/training/sessions/{session}/complete Authorization: Bearer ai:training artifact_name と実際の学習結果を記載した完全なレポートを送信します。サービスは方式、ベースリビジョン、重みの変更、成果物のダイジェスト、評価基準を検証します。
POST /api/v1/training/sessions/{session}/cancel Authorization: Bearer ai:training 空の JSON オブジェクトを送り、対象となるサービス状態をキャンセルします。必要に応じて GPU プロセスは別途停止してください。一時停止や再開とは異なります。
POST /api/v1/training/projects/authorize Authorization: Bearer ai:training provider と正の整数 reference_model_id を指定して /api/v1/training/projects/authorize に POST します。認証済みアカウントが有料の学習用参照モデルにアクセスできることを再確認し、そのアカウントが所有する job、grant、provider、参照モデル、有効期限を返します。請求書の作成や支払いの変更は行いません。
POST /api/v1/training/projects/teacher Authorization: Bearer ai:training provider、reference_model_id、action(curriculum または lessons)、objective と、任意の topic、count(1~4)、最大8件の approved_examples(各2,000文字以内)を指定して /api/v1/training/projects/teacher に POST します。トピックまたはレッスンのテキスト/トピック行を返します。承認済みの学習素材だけを送り、検証データや最終テストデータは送らないでください。