跳到主要内容

OpenThai 2.0 Legal ThaiLLM

免费至 2026-08-24
现在:0 IC——持任意 iApp API 密钥即可免费使用(注册免费)免费期后:0.01 / 0.02 IC / 1K 输入/输出 token (与 Thanoy Legal AI 相同)
v2.0 可用 POST /v3/llm/openthai2p0-legal/chat/completions

OpenThai 2.0 Legaliapp/openthai2.0-legal-thaillm-nemotron-3-nano-30b-a3b)是由 OpenThai 团队(AIEAT / iApp Technology)基于 NVIDIA Nemotron-3-Nano-30B-A3B 打造的开放权重泰语法律大模型。托管 API 内置 RAG:每个请求都会对覆盖 39 部泰国法律、6,300+ 条文的语料库做混合检索(BM25 + Qwen3 向量检索 + 重排器),使回答以现行法条原文为依据,并返回所用条文供展示与审计。

在线试用

⚖️

在线试用 OpenThai 2.0 Legal

免费 API · 1 个月

使用你的 iApp API 密钥即可免费调用,至 2026 年 8 月 24 日。

📚
已连接 RAG — 回答基于真实法条原文

本 API 从覆盖 39 部泰国法律、6,300+ 条文的语料库中混合检索(BM25 + 向量检索 + 重排器),使回答以现行法条原文为依据。系统选中的条文会显示在每个回答下方。切换到"闭卷"模式(API 中 rag: false)可与裸模型对比。

成篇的法律分析,行文中引用条文——以自动检索的现行法条原文为依据。

试试示例:
🧑‍💻 开发者视图——本演示背后的 API 调用

下面的 curl 命令会随你在上方修改问题、模式与选项而实时更新。复制到终端、换上你的 API 密钥即可运行——与本页面发送的请求完全一致。

请求(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
  }
}'

输出仅为决策辅助,并非法律意见;请对照现行法律核验每处引用。持 iApp API 密钥免费使用至 2026-08-24,之后按标准价 0.01/0.02 IC / 1K 输入/输出 token 计费(与 Thanoy Legal AI 相同)。

快速开始

  1. 准备

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

    Base URLhttps://api.iapp.co.th/v3/llm/openthai2p0-legal
    端点POST /chat/completions(兼容 OpenAI)
    模型openthai2.0-legal
    认证apikey: <key> Authorization: Bearer <key>(OpenAI SDK 开箱即用)
    频率限制每 IP 每分钟 30 次(免费档)
  3. RAG 参数(本 API 在 OpenAI 标准之上的扩展)

    字段默认含义
    ragtrue服务端检索泰国法条并以其为依据作答;false = 裸模型(闭卷)
    rag_top_k8(最大 20)注入提示词的条文数量(rag_inject: "system" 时默认 6)
    rag_inject"user""user" = 模型训练所用的 Provided context 模板,适合 JSON 引用回答;"system" = 作为参考资料附于系统提示词,适合论述/长文分析

    每个使用 RAG 的回答都带有顶层 retrieved_documents 数组——每条 {law, section, text, score}。流式输出时随第一个 SSE chunk 返回。

如何获取 API 密钥?

请访问 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} # 裸模型(闭卷)
# extra_body={"rag_inject": "system"} # 论述/长文分析
)
print(r.choices[0].message.content)
print(r.model_extra.get("retrieved_documents")) # 回答依据的法条

流式输出(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("依据条文:", [(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 模式)

需要机器可读的回答时,使用模型强化学习训练所用的系统提示词——模型只会引用检索上下文中出现的条文:

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 部泰国法律的现行文本(刑法典、民商法典、民事/刑事诉讼法典、税法典等),2560 年修订后的罚金数额已核验。
  • 可核验引用——精确的法律名 + 条文(มาตรา),支持散文或固定 JSON 格式;retrieved_documents 让每个回答可审计。
  • 推理模式——加 "chat_template_kwargs": {"enable_thinking": true} 查看 <think>...</think> 中的逐步法律推理。
  • 开放权重——同一模型可下载并在单张 24 GB GPU(NVFP4)上自托管。

应用场景

  • 法律聊天机器人与检索工具——回答附带可核验的条文依据。
  • 起草与审阅助手——JSON 引用契约可直接接入自动化流程。
  • 法律科技产品——展示 retrieved_documents 面板,让用户看到回答的依据。

推荐生成参数

任务temperature推理模式rag_inject
条文引用(JSON)0.0user(默认)
法律论述/分析0.0system
日常对话0.7可选user(默认)
决策辅助,并非法律意见

输出在使用前必须由专业人士对照现行法律核验。检索质量直接决定回答质量——retrieved_documents 字段正是为逐条审计而设。