Open weights
OpenThai 2.0 Legal
A Thai legal model that knows the statutes and cites the section it used.
- Parameters30B3B active
- Self-hosts from24GB VRAM
- Citation F1, law in prompt0.99
- Context256Ktokens
Download the weightsCall the hosted API
Released 24 July 2026. The hosted API costs 0.01 / 0.02 IC per 1K input / output tokens.
What it does
- Cites the sectionAnswers in Thai with the law name and มาตรา it relied on, as JSON your code can check.
- Knows the statutesWith no law in the prompt, roughly four times the recall of Qwen3.6-35B on the Civil and Commercial Code.
- Writes legal analysisAhead of Qwen3.6-35B on citations, holding, coverage and fluency, graded on Thai Supreme Court cases.
- Runs on your hardwareOne 24 GB GPU with the 4-bit weights, so case files stay inside your network.
Try it
Ask in Thai. Answers draw on 39 Thai laws, about 6,300 sections, and list the sections they used.
Full legal analysis in prose, citing มาตรา — grounded in auto-retrieved current statute text.
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.
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
}
}'Decision support, not legal advice. Verify every citation against the current law.
Measured
- Scoreboard
- Table

| Test (score 0 to 1) | OpenThai 2.0 Legal | Qwen3.6-35B | Base model |
|---|---|---|---|
| Civil and Commercial Code, law in the prompt (n=3,729) | 0.99 | 0.99 | 0.98 |
| Civil and Commercial Code, from memory (n=3,729) | 0.07 | 0.02 | 0.001 |
| Revenue Code, applicable sections among distractors (n=50) | 0.69 | 0.64 | 0.45 |
| Supreme Court essays, correct citations (n=72) | 0.25 | 0.09 | 0.02 |
| Supreme Court essays, correct holding (n=72) | 0.57 | 0.50 | 0.31 |
Citation rows use the NitiBench citation-F1 scorer (single pass, temperature 0, thinking off); holding, coverage and fluency in the essays are judged by an LLM. Every model was re-run under one protocol; the scoreboard shows every axis.
Run it
- Hosted API
- curl
- vLLM
- NVIDIA NIM
Call it with an iApp API key (register, then API Keys) at 0.01 / 0.02 IC per 1K input / output tokens and 30 requests per minute. Retrieval is on by default and the sections used come back in retrieved_documents. The API reference lists every parameter.
from openai import OpenAI
client = OpenAI(base_url="https://api.iapp.co.th/v3/llm/openthai2p0-legal", api_key="YOUR_IAPP_API_KEY")
r = client.chat.completions.create(
model="openthai2.0-legal",
messages=[{"role": "user", "content": "ลักทรัพย์ในเวลากลางคืน ผิดมาตราใด"}],
max_tokens=1024,
# extra_body={"rag": False} # uncomment to call the bare model (closed-book)
)
print(r.choices[0].message.content)
print(r.model_extra.get("retrieved_documents")) # the law sections the answer used
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","messages":[{"role":"user","content":"ลักทรัพย์ในเวลากลางคืน ผิดมาตราใด"}],"max_tokens":1024}'
Tested on vLLM 0.19.1 with two H100 (80 GB) GPUs. On one GPU, serve the NVFP4 (4-bit) weights on a card with at least 24 GB.
vllm serve iapp/openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b \
--tensor-parallel-size 2 --trust-remote-code \
--max-model-len 32768 --enforce-eager
Take the current container tag from the NVIDIA NIM for LLMs catalog. NIM serves the same OpenAI-compatible API as vLLM.
docker run --rm --gpus all --shm-size=16g \
-v <path-to-model>:/model \
-e NIM_MODEL_NAME=/model \
-e NIM_SERVED_MODEL_NAME=openthai2.0-legal \
-p 8000:8000 \
nvcr.io/nim/nvidia/llm-nim:latest
Settings that matter
| Answer | Sampling | Max tokens |
|---|---|---|
| Citation, as JSON | temperature 0.0, thinking off | 1,024 |
| Legal essay | temperature 0.7, top_p 0.9 | 2,048 to 4,096 |
"chat_template_kwargs": {"enable_thinking": true} returns the reasoning inside <think>...</think>. Serve with --max-model-len at 32768 or more: real Revenue Code contexts overflow smaller windows.
Prompts for JSON citation and essay answers
With the law in the prompt (the RAG setting), against a self-hosted server:
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8000/v1", api_key="none")
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>"}]}.')
USER = """Provided context:
<law law_name="ประมวลกฎหมายแพ่งและพาณิชย์" section="420">
ผู้ใดจงใจหรือประมาทเลินเล่อ ทำต่อบุคคลอื่นโดยผิดกฎหมายให้เขาเสียหาย ... จำต้องใช้ค่าสินไหมทดแทนเพื่อการนั้น
</law>
Question (ตอบเป็นภาษาไทย):
นาย ก. ขับรถโดยประมาทชนรถของนาย ข. เสียหาย นาย ก. ต้องรับผิดตามกฎหมายใด"""
r = client.chat.completions.create(
model="openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b",
messages=[{"role": "system", "content": SYSTEM}, {"role": "user", "content": USER}],
temperature=0.0, max_tokens=1024,
extra_body={"chat_template_kwargs": {"enable_thinking": False}})
print(r.choices[0].message.content)
The model's actual output:
{"answer": "นาย ก. ต้องรับผิดตามประมวลกฎหมายแพ่งและพาณิชย์ มาตรา 420",
"citations": [{"law": "ประมวลกฎหมายแพ่งและพาณิชย์", "section": "420"}]}
From memory, with no law in the prompt, send this system prompt and the question alone:
SYSTEM = ("You are an expert on Thai law. You are given ONLY a legal question, with NO reference "
"material provided. Using your OWN knowledge of Thai statutes, answer in Thai and cite the "
"specific sections that apply (law name + bare section number, มาตรา). "
'Output ONLY a JSON object: {"answer":"<Thai answer>","citations":[{"law":"<law name>",'
'"section":"<bare section number e.g. 40 or 77/1>"}]}.')
For an essay, send this short system prompt with the question; the model cites มาตรา in prose rather than JSON:
SYSTEM = "You are a Thai legal expert. Answer the question with legal analysis and cite the relevant มาตรา."
To add your own retrieval, follow the Open WebUI and OpenThaiRAG tutorial and chunk the statutes one มาตรา per chunk with law_name and section metadata. To deploy it in your organisation or tune it to your own corpus, write to sale@iapp.co.th or call 02-124-4041.
Limits
- Decision support, not legal advice: a qualified professional checks every citation against the current law.
- The answer follows the sections it is given, so wrong retrieval gives a wrong answer. With the law in the prompt, choosing the applicable section among close alternatives is the lowest-scoring test for every model.
- Trained on Thai statutes (Revenue Code, Civil and Commercial Code, related acts) and Revenue Department rulings; niche areas and recent amendments are thinner.
Licence
NVIDIA Open Model Agreement. Trained from the text core of NVIDIA Nemotron-3-Nano-Omni-30B-A3B-Reasoning: continued pretraining on 360,985 statute drills, fine-tuning on 16,436 exam answers and essays, then reinforcement learning on 8,568 graded questions with citation F1 as the reward. The launch story has the detail.
Some essay training data derives from Thai bar examination materials; confirm redistribution terms for your use. Evaluated on NitiBench (VISAI-AI, MIT); fine-tuning data built from WangchanX-Legal-ThaiCCL (VISTEC, MIT). Built by the OpenThai team (AIEAT and iApp Technology) with the Big Data Institute, the ThaiLLM initiative and NVIDIA.