跳到主要内容

OpenThai 2.0 法律 ThaiLLM

截至 2026 年 8 月 24 日免费
现在: 0 IC — 免费使用任何 iApp API 密钥(注册免费)促销后: 每 1K 输入/输出 token 0.01 / 0.02 IC (与 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) 是一个由 OpenThai 团队 (AIEAT / iApp Technology) 基于 NVIDIA Nemotron-3-Nano-30B-A3B 构建的开权重泰国法律 LLM。其托管 API 开箱即用 RAG 连接:每次请求都会对一个包含 39 项法律、6,300 条的泰国法规语料库(BM25 + Qwen3 嵌入搜索 + reranker)进行混合搜索,并根据当前法律文本来生成答案——返回检索到的条款,以便您进行显示或审计。

试用演示

⚖️

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. 先决条件

    • 免费的 iApp API 密钥 — 注册API KeysCreate New API Key
    • 一个泰国法律问题
  2. 端点

    基础 URLhttps://api.iapp.co.th/v3/llm/openthai2p0-legal
    端点POST /chat/completions (兼容 OpenAI)
    模型openthai2.0-legal
    认证apikey: <key> header Authorization: Bearer <key> (OpenAI SDK 可直接使用)
    速率限制每个 IP 30 次请求/分钟 (免费套餐)
  3. RAG 参数 (此 API 在 OpenAI schema 之上的额外功能)

    字段默认值含义
    ragtrue在服务器端检索泰国法律条款并依据其生成答案。false = 仅使用模型(闭卷)。
    rag_top_k8 (最多 20)注入到提示中的检索条款数量(当 rag_inject: "system" 时为 6)。
    rag_inject"user""user" = 训练过的 提供的上下文 框架,最适合 JSON 引用式回答。"system" = 系统提示中的建议性参考,最适合散文/长篇分析。

    每个 RAG 响应都带有一个顶级的 retrieved_documents 数组 — 每个答案所依据的条款 {law, section, text, score}。流式传输时,它会附加在 第一个 SSE 块上。

如何获取 API 密钥?

请访问 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 认证)

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

流式传输 (SSE) — 检索到的条款将在第一个块中到达

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 引用合同 (训练过的 RAG 模式)

为了获得机器可读的答案,请使用模型进行 RL 训练的系统提示 — 它仅引用检索到的上下文中存在的条款:

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 — 混合 BM25 + 嵌入检索,并对 39 项泰国法律(ประมวลกฎหมายอาญา、ป.พ.พ.、วิ.แพ่ง、วิ.อาญา、ประมวลรัษฎากร 及其他 34 项)的当前文本进行重排序;已验证 2560 年后的罚款金额。
  • 可验证的引用 — 精确的法律名称 + มาตรา,可在文本中引用,也可作为固定的 JSON 合同;retrieved_documents 让您可以审计每个答案。
  • 推理模式 — 添加 "chat_template_kwargs": {"enable_thinking": true} 以获得以 <think>...</think> 包裹的逐步法律推理。
  • 开权重 — 同一个模型可下载并在单个 24 GB GPU (NVFP4) 上进行自托管。

用例

  • 法律聊天机器人和研究工具 — 提供有依据的答案,附带用户可以验证的法律条款。
  • 起草和审查助手 — JSON 引用合同可以直接用于自动化。
  • 法律科技产品 — 显示 retrieved_documents 面板,说明模型为何给出该答案。

推荐的生成设置

任务temperaturethinkingrag_inject
引用回答 (JSON)0.0关闭user (默认)
法律论文/分析0.0开启system
对话式0.7可选user (默认)
仅供决策支持,非法律建议

在依赖输出之前,必须由合格的专业人士根据现行法律进行核实。检索质量决定结果 — retrieved_documents 数组正是为了让每个答案都可以被审计。