Lompat ke isi

Output JSON

Minta jawaban berupa JSON dengan response_format. Bentuk json_schema diteruskan ke model yang mendukungnya.

Contoh

Terminal
curl https://rumahaicloud.my.id/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-flash",
    "messages": [{"role": "user", "content": "Ekstrak nama dan kota: Budi tinggal di Surabaya."}],
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "name": "orang",
        "schema": {
          "type": "object",
          "properties": {"nama": {"type": "string"}, "kota": {"type": "string"}},
          "required": ["nama", "kota"]
        }
      }
    }
  }'

Tetap periksa hasilnya dengan json.loads atau JSON.parse sebelum dipakai. Bila model tidak mendukung skema, pakai {"type": "json_object"} dan tulis bentuk JSON yang diminta di pesan.

Masih bingung? Lihat status layanan atau hubungi kami. Belum punya kunci? Buat akun.
Hak cipta 2026 RumahAI Cloud. Semua harga dalam Rupiah. [email protected]