本文へスキップ

POST /api/qr/ai/generate

/api/qr/generate と同じレンダラーですが、欲しいものを文で説明すると、エンジンが形状、色、ファインダーの目を選びます。

AIエンドポイントには3つのバリエーションがあります。使用する認証方式に合ったものを選んでください。

マーケットプレイス — LLMキーは各自で用意

POST https://api.qr-branding.com/api/qr/ai/generate

curl -X POST https://api.qr-branding.com/api/qr/ai/generate \
  -H "Content-Type: application/json" \
  -H "X-RapidAPI-Proxy-Secret: <secret>" \
  -d '{
    "content": "https://yourbrand.com",
    "prompt": "art deco gold leaf, geometric chevrons, ivory background",
    "llmProvider": "openai",
    "llmApiKey": "sk-...",
    "creativity": 0.6,
    "strictScannability": true,
    "stylePreset": "luxury"
  }'

LLMの認証情報はあなたが用意します。エンジンは生成された設定を検証し、スキャン保証のチェックを実行して、QRをレンダリングします。

マーケットプレイス — マネージドAI(LLMキー不要)

curl -X POST https://api.qr-branding.com/api/qr/ai/generate-managed \
  -H "Content-Type: application/json" \
  -H "X-RapidAPI-Proxy-Secret: <secret>" \
  -d '{
    "content": "https://yourbrand.com",
    "prompt": "art deco gold leaf, geometric chevrons, ivory background",
    "creativity": 0.6,
    "strictScannability": true,
    "stylePreset": "luxury"
  }'

llmProvider / llmApiKey は不要です。サーバーは独自のモデルを、Groq → Gemini → OpenAI のフォールバックチェーンで使用します。レスポンスには "managed": true が含まれ、呼び出しはプランのマネージドAIクォータに計上されます。

コンシューマー — サーバー側のLLMキー

POST https://qr-branding.com/api/qr/ai/generate/server

curl -X POST https://qr-branding.com/api/qr/ai/generate/server \
  -H "Content-Type: application/json" \
  -d '{
    "content": "https://yourbrand.com",
    "prompt": "art deco gold leaf, geometric chevrons, ivory background",
    "stylePreset": "luxury",
    "creativity": 0.6
  }'

llmProvider / llmApiKey は不要です。サーバーはGroq(gpt-oss-120b、次にgpt-oss-20b)→ OpenAI → Geminiの順に試します。成功すると残高からAIクレジットが1つ差し引かれ、失敗した場合はクレジットを消費しません。

コードサンプル

リクエストボディ

フィールド型デフォルト備考
contentstring必須エンコードする内容(URL / テキスト)。
promptstring必須自然な言葉による説明。10000文字以内。
stylePresetstringluxuryminimal artistic corporate playful luxury tech nature のいずれか。
creativitynumber0.50–1。LLMのtemperatureと、デザインの選択の大胆さに影響します。
strictScannabilitybooleantrueオンのとき、エンジンは読み取り可能性の問題を自動修正します。オフのときは警告します。
logoUrlstring—中央に埋め込み、その下のモジュールを消去し、ECCをHに引き上げます。
logoBase64string—上と同じですが、インラインのbase64で渡します。
backgroundImageUrlstring—控えめな背景画像(QRの背後にブレンド)。
centerTextobject—{ text, color?, backgroundColor?, fontSize? }。QRを横切るバナー。
ctaTextstring—下部のキャプション。
fileFormatstringpngpng jpg svg pdf webp。
outputWidthnumber800ピクセル。
responseTypestringbase64base64 または binary。

マーケットプレイスのエンドポイントでは、さらに次が必要です。

フィールド型備考
llmProviderstringopenai anthropic google mistral cohere groq xai deepseek qwen local
llmApiKeystringプロバイダーのキー
llmModelstring任意 — 省略時はそのプロバイダーのデフォルトモデル(/api/qr/ai/providers を参照)。プロバイダーが提供する任意のモデルIDを指定できます

レスポンス

{
  "success": true,
  "qrBase64": "iVBORw0KGgo…",
  "format": "png",
  "contentType": "image/png",
  "sizeBytes": 38291,
  "generatedConfig": { "moduleShape": "diamond", "finderOuterShape": "octagon", "...": "..." },
  "aiExplanation": "Diamond modules and octagonal finders for the geometric art deco feel; gold-on-ivory keeps contrast at 6.4:1.",
  "llmProviderUsed": "openai",
  "llmModelUsed": "gpt-6-luna"
}

generatedConfig はAIが生成したQrConfigの全体です。その設定を手動モードに持ち込んで手で調整したいときに便利です。

関連項目