Skip to main content

OpenThai 2.0 Legal ThaiLLM

FREE until 24 Aug 2026
Now: 0 IC — free with any iApp API key (registration free)After promo: 0.01 / 0.02 IC per 1K input/output tokens (same as Thanoy Legal AI)
v2.0 Active POST /v3/llm/openthai2p0-legal/chat/completions

OpenThai 2.0 Legal (iapp/openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b) is an open-weight Thai legal LLM built on NVIDIA Nemotron-3-Nano-30B-A3B by the OpenThai team (AIEAT / iApp Technology). The hosted API is RAG-connected out of the box: every request hybrid-searches a 39-law, 6,300-section Thai statute corpus (BM25 + Qwen3 embedding search + reranker) and grounds the answer in the current law text — returning the retrieved sections so you can display or audit them.

Try 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).

Getting Started

  1. Prerequisites

    • A free iApp API key — registerAPI KeysCreate New API Key
    • A Thai legal question
  2. Endpoint

    Base URLhttps://api.iapp.co.th/v3/llm/openthai2p0-legal
    EndpointPOST /chat/completions (OpenAI-compatible)
    Modelopenthai2.0-legal
    Authapikey: <key> header or Authorization: Bearer <key> (OpenAI SDK works as-is)
    Rate limit30 requests/minute per IP (free tier)
  3. RAG parameters (this API's extras on top of the OpenAI schema)

    FieldDefaultMeaning
    ragtrueRetrieve Thai law sections server-side and ground the answer. false = bare model (closed-book).
    rag_top_k8 (max 20)Number of retrieved sections injected into the prompt (6 when rag_inject: "system").
    rag_inject"user""user" = the trained Provided context scaffold, best for JSON citation answers. "system" = advisory reference in the system prompt, best for essay/long-form analysis.

    Every RAG response carries a top-level retrieved_documents array — {law, section, text, score} for each section the answer was grounded in. When streaming, it rides on the first SSE chunk.

How to get API Key?

Please visit API Key Management page to view your existing API key or request a new one.

Code Examples

cURL — RAG on (default)

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
}'

Response (truncated)

{
"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 (works as-is, 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} # bare model (closed-book)
# extra_body={"rag_inject": "system"} # essay / long-form analysis
)
print(r.choices[0].message.content)
print(r.model_extra.get("retrieved_documents")) # the law sections the answer used

Streaming (SSE) — retrieved sections arrive on the first 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 (the trained RAG mode)

For machine-readable answers, use the system prompt the model was RL-trained on — it cites only sections present in the retrieved context:

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"}]}

Features & Capabilities

Core Features

  • Server-side RAG built in — hybrid BM25 + embedding retrieval with reranking over the current text of 39 Thai laws (ประมวลกฎหมายอาญา, ป.พ.พ., วิ.แพ่ง, วิ.อาญา, ประมวลรัษฎากร and 34 more); post-2560 penalty amounts verified.
  • Verifiable citations — exact law name + มาตรา, either in prose or as a fixed JSON contract; retrieved_documents lets you audit every answer.
  • Reasoning mode — add "chat_template_kwargs": {"enable_thinking": true} for step-by-step legal reasoning wrapped in <think>...</think>.
  • Open weights — the same model is downloadable and self-hostable on a single 24 GB GPU (NVFP4).

Use Cases

  • Legal chatbots and research tools — grounded answers with sections your users can verify.
  • Drafting and review assistants — the JSON citation contract drops straight into automation.
  • Legal-tech products — display the retrieved_documents panel to show why the model answered as it did.
Tasktemperaturethinkingrag_inject
Citation answering (JSON)0.0offuser (default)
Legal essay / analysis0.0onsystem
Conversational0.7optionaluser (default)
Decision support, not legal advice

Outputs must be verified against the current law by a qualified professional before being relied upon. Retrieval quality drives results — the retrieved_documents array exists precisely so every answer can be audited.