APIキー

不正利用を防ぐため、APIキーを安全に保管してください

APIキーの使い方 詳細を表示 詳細を隠す

キーはサーバーに保管し、Bearer トークンとして送信します。以下はコピー&ペーストで試せるクイックスタートです。

  1. キーを作成し、サーバーのシークレットストアに保存します。下の一覧からいつでも再コピーできます。
  2. キーを Bearer トークンとして、画像を multipart フィールドに入れて /api/plant/identify に POST します。
  3. JSON レスポンスを読み取ります。植物情報は最上位に、加えて credit_transaction と new_balance が返ります。

リクエスト

フィールド 必須 型 説明
image 必須 file JPEG、PNG、WebP、GIF。最大 10 MB。
lang 任意 string 出力言語: en、zh、es、ja、fr、de、pt、ko、it。既定値は en、不明な値は en になります。最大 12 文字。
context 任意 string 被写体のヒントで精度が上がります: plant、succulent、leaf、houseplant、poison_ivy。既定値は plant。最大 32 文字。

リクエスト例

curl -X POST https://api.plantidentify.org/api/plant/identify \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "image=@/path/to/plant.jpg;type=image/jpeg" \
  -F "lang=ja" \
  -F "context=houseplant"
import requests

with open("plant.jpg", "rb") as f:
    r = requests.post(
        "https://api.plantidentify.org/api/plant/identify",
        headers={"Authorization": "Bearer YOUR_API_KEY"},
        files={"image": ("plant.jpg", f, "image/jpeg")},
        data={"lang": "ja", "context": "houseplant"},
        timeout=90,
    )
print(r.status_code, r.json())
import { readFile } from "node:fs/promises";

const form = new FormData();
form.append("image", new Blob([await readFile("plant.jpg")], { type: "image/jpeg" }), "plant.jpg");
form.append("lang", "ja");
form.append("context", "houseplant");

const res = await fetch("https://api.plantidentify.org/api/plant/identify", {
  method: "POST",
  headers: { Authorization: "Bearer YOUR_API_KEY" },
  body: form,
});
console.log(res.status, await res.json());

レスポンス例

HTTP 200。モデルが確信できない場合は一部のフィールドが欠けることがあります。すべて任意として扱ってください。 care_level はローカライズされた表示用ラベルで、固定の enum ではありません。

{
  "success": true,
  "common_name": "モンステラ",
  "scientific_name": "Monstera deliciosa",
  "family": "Araceae",
  "care_level": "簡単",
  "light": "明るい間接光",
  "watering": "土の表面が乾いたら水やり",
  "pet_safety": "誤食するとペットに有毒",
  "description": "大きく裂けた葉を持つ熱帯性のつる植物です。",
  "identification_notes": "裂けた葉の縁と気根が見られます。",
  "lookalikes": "ヒメモンステラ(Monstera adansonii)",
  "next_step": "生育を均一にするため週に一度鉢を回します。",
  "confidence": 0.92,
  "credit_transaction": "PI2026110600001",
  "new_balance": 18
}

エラーレスポンス

400 missing_image リクエストに image フィールドがありません。
400 invalid_file_type 画像が JPEG、PNG、WebP、GIF のいずれでもありません。
400 file_too_large 画像が 10 MB を超えています。
401 authentication_required API キーが無い、無効、無効化済み、または削除済みです。
402 insufficient_credits クレジットが不足しています。課金は行われません。
500 identification_failed プロバイダーエラーです。課金されたクレジットは自動返金されます。

課金と安全性

識別が成功するたびに 2 クレジットを消費します。失敗したリクエストは自動返金されます。
API キーをブラウザの JavaScript やモバイルアプリのバンドルに埋め込まないでください。漏えいの可能性があればすぐに無効化または削除してください。
読み込み中…