Rivya AI Docs
หน้า API ของโมเดล

การเชื่อมต่อ API ของ Nano Banana 2

ใช้ Nano Banana 2 ผ่าน Rivya Public API v1 ด้วย model id nano-banana-2, input ที่รองรับ, พารามิเตอร์, กฎ Files API, เครดิต และตัวอย่าง response

พร้อมใช้งานผ่าน APIText หรือ URL พร้อม; โหมด reference ใช้ Files APIรูปภาพ
ID โมเดล API

nano-banana-2

Input

text, file

Files API

จำเป็นสำหรับโหมด reference

เครดิตพื้นฐาน

5

ความสามารถ

รูปภาพ

Billing

FIXED

ขีดจำกัดพรอมต์

20000 อักขระ

contract ของ request

ส่ง model id ที่ระดับบนสุด control เฉพาะโมเดลอยู่ใน params

KeyTypeจำเป็นค่าเริ่มต้นคำอธิบาย
modelstringใช่nano-banana-2ใช้ API model id nano-banana-2
promptstringใช่-สูงสุด 20000 อักขระสำหรับโมเดลนี้
paramsobjectไม่ใช่-object พารามิเตอร์เฉพาะโมเดล ใช้แถวด้านล่างสำหรับ key ที่อนุญาต
client_request_idstringไม่ใช่-client-side id แบบเลือกได้สำหรับ trace คำขอในระบบของคุณ

พารามิเตอร์โมเดล

KeyTypeจำเป็นค่าเริ่มต้นช่วงตัวเลือกคำอธิบาย
aspect_ratioselectไม่ใช่auto-auto, 1:1, 16:9, 9:16, 3:2, 2:3, 4:3, 3:4, 5:4, 4:5, 21:9, 4:1, 1:4, 8:1, 1:8อัตราส่วนภาพ
resolutionselectไม่ใช่1K-1K, 2K, 4Kความละเอียด
output_formatselectไม่ใช่jpg-jpg, pngรูปแบบเอาต์พุต
google_searchselectไม่ใช่false-false, trueค้นหาด้วย Google

policy การอัปโหลด

อัปโหลดไฟล์ reference ก่อน จากนั้นใส่ URL และ duration token ที่ได้กลับมาไว้ใน params.referenceMediaItems

กฎ reference

ภาพอ้างอิง: อัปโหลดไฟล์รูปภาพได้สูงสุด 14 ไฟล์สำหรับโปรเจกต์รูปภาพ

ไฟล์สูงสุด

14

ชนิดไฟล์ที่รับ

image

Duration token

reference วิดีโอและเสียงควรมี durationToken จาก /api/v1/files เมื่อจำเป็นต้องตรวจ duration

kindขนาดสูงสุดMIME type
image30 MBimage/jpeg, image/png, image/webp

request ขั้นต่ำ

{
  "model": "nano-banana-2",
  "prompt": "A clean editorial product image on a soft studio background",
  "params": {
    "aspect_ratio": "auto",
    "resolution": "1K",
    "output_format": "jpg",
    "google_search": "false"
  }
}

request แบบไฟล์ reference

{
  "model": "nano-banana-2",
  "prompt": "A clean editorial product image on a soft studio background",
  "params": {
    "aspect_ratio": "auto",
    "resolution": "1K",
    "output_format": "jpg",
    "google_search": "false",
    "referenceMediaItems": [
      {
        "url": "https://cdn.example.com/reference-image.png",
        "kind": "image",
        "name": "reference-image.png",
        "mimeType": "image/png"
      }
    ]
  }
}

response จากการสร้าง

endpoint create ส่ง public task id กลับมา poll endpoint สถานะจนกว่างานจะสำเร็จหรือล้มเหลว

{
  "id": "task_nano_banana_2_example",
  "status": "queued",
  "model": "nano-banana-2",
  "reserved_credits": 5,
  "final_credits": 0,
  "created_at": "2026-05-11T00:00:00.000Z",
  "updated_at": "2026-05-11T00:00:00.000Z",
  "result": null,
  "error": null
}

error ทั่วไป

validation_failed, insufficient_credits, idempotency_conflict, rate_limited, not_found

บางโหมดต้องใช้การอัปโหลด reference ผ่าน Files API