Skip to main content

OpenThai 2.0 Legal ThaiLLM

ฟรี จนถึง 24 ส.ค. 2026
ตอนนี้: 0 IC — ฟรีพร้อมคีย์ API ของ iApp (ลงทะเบียนฟรี)หลังโปรโมชั่น: 0.01 / 0.02 IC ต่อ 1K โทเค็นอินพุต/เอาต์พุต (เท่ากับ Thanoy Legal AI)
v2.0 ใช้งานอยู่ POST /v3/llm/openthai2p0-legal/chat/completions

OpenThai 2.0 Legal (iapp/openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b) เป็นโมเดล LLM กฎหมายไทยน้ำหนักเปิด (open-weight) ที่สร้างขึ้นบน NVIDIA Nemotron-3-Nano-30B-A3B โดยทีม OpenThai (AIEAT / บริษัท ไอแอพพ์เทคโนโลยี จำกัด) API ที่โฮสต์อยู่นี้ เชื่อมต่อ RAG มาพร้อมใช้งานทันที: ทุกคำขอจะทำการค้นหาแบบผสมผสาน (hybrid-search) ใน คลังข้อมูลกฎหมายไทย 39 ฉบับ จำนวน 6,300 มาตรา (BM25 + การค้นหาด้วย Qwen3 embedding + reranker) และอ้างอิงคำตอบจากข้อความกฎหมายปัจจุบัน — พร้อมส่งคืนมาตราที่ค้นพบเพื่อให้คุณแสดงผลหรือตรวจสอบได้

ทดลองใช้งาน Demo

⚖️

Try OpenThai 2.0 Legal — Live

FREE API · 1 MONTH

Real model, real answers. Free with your iApp API key until 24 Aug 2026.

📚
RAG connected — answers grounded in real statute text

This API retrieves from a 39-law, 6,300-section Thai statute corpus (hybrid BM25 + embedding search + reranker) and grounds every answer in the current law text. The sections it selects are shown below each answer. Switch to Closed-book mode (rag: false in the API) to compare with the bare model.

Full legal analysis in prose, citing มาตรา — grounded in auto-retrieved current statute text.

Try an example:
🧑‍💻 Developer view — the API call behind this demo

This curl command updates live as you change the question, mode and toggles above. Run it in your terminal with your own API key — it is exactly what this page sends.

Request (curl)
curl -s https://api.iapp.co.th/v3/llm/openthai2p0-legal/chat/completions \
  -H "Content-Type: application/json" \
  -H "apikey: YOUR_IAPP_API_KEY" \
  -d '{
  "model": "openthai2.0-legal",
  "rag": true,
  "rag_inject": "system",
  "messages": [
    {
      "role": "system",
      "content": "You are a Thai legal expert. Answer with legal analysis and cite the relevant มาตรา."
    },
    {
      "role": "user",
      "content": "จำเลยขีดฆ่าและฉีกเอกสารหลักฐานแห่งหนี้ แม้ยังอ่านได้ ถือเป็นความผิดสำเร็จหรือเพียงพยายามกระทำผิด"
    }
  ],
  "temperature": 0,
  "top_p": 1,
  "max_tokens": 4096,
  "chat_template_kwargs": {
    "enable_thinking": true
  },
  "stream": true,
  "stream_options": {
    "include_usage": true
  }
}'

Outputs are decision support, not legal advice. Verify every citation against the current law. Free with an iApp API key to 24 Aug 2026; standard pricing afterwards is 0.01/0.02 IC per 1K input/output tokens (same as Thanoy Legal AI).

เริ่มต้นใช้งาน

  1. สิ่งที่ต้องมี

    • คีย์ API ฟรีของ iApp — ลงทะเบียนAPI KeysCreate New API Key
    • คำถามเกี่ยวกับกฎหมายไทย
  2. Endpoint

    Base URLhttps://api.iapp.co.th/v3/llm/openthai2p0-legal
    EndpointPOST /chat/completions (เข้ากันได้กับ OpenAI)
    Modelopenthai2.0-legal
    Authapikey: <key> header หรือ Authorization: Bearer <key> (OpenAI SDK ใช้งานได้ทันที)
    Rate limit30 คำขอ/นาที ต่อ IP (ฟรี)
  3. พารามิเตอร์ RAG (ส่วนเสริมของ API นี้ นอกเหนือจาก schema ของ OpenAI)

    FieldDefaultความหมาย
    ragtrueค้นหาส่วนของกฎหมายไทยบนเซิร์ฟเวอร์และอ้างอิงคำตอบ false = โมเดลเปล่า (closed-book)
    rag_top_k8 (สูงสุด 20)จำนวนส่วนที่ค้นพบที่จะแทรกใน prompt (6 เมื่อ rag_inject: "system")
    rag_inject"user""user" = โครงสร้าง Provided context ที่โมเดลถูกฝึกมา เหมาะสำหรับคำตอบที่มีการอ้างอิง JSON "system" = การอ้างอิงเป็นคำแนะนำใน system prompt เหมาะสำหรับบทความ/การวิเคราะห์แบบยาว

    ทุกการตอบสนองจาก RAG จะมีอาร์เรย์ retrieved_documents ระดับบนสุด — {law, section, text, score} สำหรับแต่ละมาตราที่ใช้ในการตอบสนอง เมื่อใช้งานแบบสตรีมมิ่ง (streaming) จะปรากฏใน SSE chunk แรก

วิธีรับ API Key?

กรุณาไปที่หน้า API Key Management เพื่อดูคีย์ API ที่มีอยู่ของคุณ หรือขอคีย์ใหม่

ตัวอย่างโค้ด

cURL — RAG ทำงาน (ค่าเริ่มต้น)

curl -X POST 'https://api.iapp.co.th/v3/llm/openthai2p0-legal/chat/completions' \
-H 'apikey: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "openthai2.0-legal",
"messages": [
{"role": "user", "content": "ลักทรัพย์ในเวลากลางคืน ผิดมาตราใด"}
],
"max_tokens": 1024
}'

ผลลัพธ์ (ตัดทอน)

{
"id": "chatcmpl-...",
"model": "openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b",
"choices": [
{"message": {"role": "assistant", "content": "ลักทรัพย์ในเวลากลางคืน เป็นการกระทำความผิดตามมาตรา ๓๓๕ (๑) แห่งประมวลกฎหมายอาญา ..."}}
],
"usage": {"prompt_tokens": 2874, "completion_tokens": 17},
"rag": true,
"retrieved_documents": [
{"law": "ประมวลกฎหมายอาญา", "section": "335", "text": "ผู้ใดลักทรัพย์ (๑) ในเวลากลางคืน ...", "score": 0.9989},
{"law": "ประมวลกฎหมายอาญา", "section": "334", "text": "ผู้ใดเอาทรัพย์ของผู้อื่น ...", "score": 0.9936}
]
}

Python — OpenAI SDK (ใช้งานได้ทันที, Bearer auth)

from openai import OpenAI

client = OpenAI(
base_url="https://api.iapp.co.th/v3/llm/openthai2p0-legal",
api_key="YOUR_API_KEY",
)

r = client.chat.completions.create(
model="openthai2.0-legal",
messages=[{"role": "user", "content": "ลักทรัพย์ในเวลากลางคืน ผิดมาตราใด"}],
max_tokens=1024,
# extra_body={"rag": False} # โมเดลเปล่า (closed-book)
# extra_body={"rag_inject": "system"} # บทความ / การวิเคราะห์แบบยาว
)
print(r.choices[0].message.content)
print(r.model_extra.get("retrieved_documents")) # มาตรากฎหมายที่คำตอบใช้อ้างอิง

Streaming (SSE) — มาตราที่ค้นพบจะมาใน chunk แรก

stream = client.chat.completions.create(
model="openthai2.0-legal",
messages=[{"role": "user", "content": "อธิบายความผิดฐานลักทรัพย์โดยละเอียด"}],
max_tokens=2048,
stream=True,
)
for chunk in stream:
docs = chunk.model_extra.get("retrieved_documents")
if docs:
print("Grounded in:", [(d["law"], d["section"]) for d in docs])
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)

JSON citation contract (โหมด RAG ที่โมเดลถูกฝึกมา)

สำหรับคำตอบที่เครื่องสามารถอ่านได้ ให้ใช้ system prompt ที่โมเดลถูก RL-trained มา — โดยจะอ้างอิงเฉพาะมาตราที่อยู่ในบริบทที่ค้นพบเท่านั้น:

SYSTEM = (
"You are OpenThaiGPT-Legal, an expert assistant on Thai law. You are given a legal "
"question and the exact statutory sections needed to answer it. Reason step by step in "
"English, then give the final answer in Thai. Cite ONLY sections present in the provided "
"context, using each section's exact law_name and bare section number (e.g. 132, 77/1). "
'Output the final answer as JSON: {"answer": "<Thai answer>", '
'"citations": [{"law": "<law_name>", "section": "<bare id>"}]}.'
)

r = client.chat.completions.create(
model="openthai2.0-legal",
messages=[
{"role": "system", "content": SYSTEM},
{"role": "user", "content": "หมิ่นประมาทโดยการโฆษณา มีความผิดตามมาตราใด"},
],
temperature=0.0, max_tokens=1024,
extra_body={"chat_template_kwargs": {"enable_thinking": False}},
)
# -> {"answer": "...มาตรา 328", "citations": [{"law": "ประมวลกฎหมายอาญา", "section": "328"}]}

คุณสมบัติและความสามารถ

คุณสมบัติหลัก

  • RAG ฝั่งเซิร์ฟเวอร์ในตัว — การค้นหาแบบผสมผสาน (hybrid BM25 + embedding) พร้อม reranking บนข้อความปัจจุบันของกฎหมายไทย 39 ฉบับ (ประมวลกฎหมายอาญา, ป.พ.พ., วิ.แพ่ง, วิ.อาญา, ประมวลรัษฎากร และอีก 34 ฉบับ); อัตราโทษหลังปี 2560 ได้รับการตรวจสอบแล้ว
  • การอ้างอิงมาตราที่ตรวจสอบได้ — ชื่อกฎหมายที่ถูกต้อง + มาตรา, ทั้งแบบข้อความทั่วไปหรือเป็นสัญญา JSON ที่แน่นอน; retrieved_documents ช่วยให้คุณตรวจสอบทุกคำตอบได้
  • โหมดการใช้เหตุผล — เพิ่ม "chat_template_kwargs": {"enable_thinking": true} เพื่อให้แสดงเหตุผลทางกฎหมายแบบทีละขั้นตอนที่ถูกห่อหุ้มด้วย <think>...</think>
  • น้ำหนักเปิด (Open weights) — สามารถดาวน์โหลดและโฮสต์โมเดลเดียวกันได้เองบน GPU เพียง 24 GB (NVFP4)

กรณีการใช้งาน

  • แชทบอทและเครื่องมือค้นคว้าทางกฎหมาย — คำตอบที่อ้างอิงพร้อมมาตราที่ผู้ใช้สามารถตรวจสอบได้
  • ผู้ช่วยร่างและทบทวนเอกสาร — สัญญา JSON citation สามารถนำไปใช้กับระบบอัตโนมัติได้โดยตรง
  • ผลิตภัณฑ์ Legal-tech — แสดงแผง retrieved_documents เพื่อแสดง เหตุผล ที่โมเดลตอบเช่นนั้น

การตั้งค่าการสร้างที่แนะนำ

Tasktemperaturethinkingrag_inject
การตอบคำถามอ้างอิง (JSON)0.0ปิดuser (ค่าเริ่มต้น)
บทความ / การวิเคราะห์ทางกฎหมาย0.0เปิดsystem
การสนทนา0.7เลือกได้user (ค่าเริ่มต้น)
การสนับสนุนการตัดสินใจ, ไม่ใช่คำแนะนำทางกฎหมาย

ผลลัพธ์จะต้องได้รับการตรวจสอบกับกฎหมายปัจจุบันโดยผู้เชี่ยวชาญที่ผ่านการรับรองก่อนนำไปใช้ คุณภาพของการค้นหาเป็นตัวขับเคลื่อนผลลัพธ์ — อาร์เรย์ retrieved_documents มีไว้เพื่อให้สามารถตรวจสอบทุกคำตอบได้