---
title: "Chat"
method: POST
path: "/api/chat"
tags: ["chat"]
---

# Chat

`POST /api/chat`

## Request

- Base URL: `https://fojin.app` (the document declares no server; this is the origin it was published from)
- URL: `https://fojin.app/api/chat`
- Auth: HTTP bearer

Send a message and receive an AI answer grounded in Buddhist texts (RAG). Supports BYOK and anonymous access.

发送消息并获取基于经文的 AI 回答（支持自带 API Key 及匿名访问）。

## Request body

- ChatRequest
  - `message` string, required
  - `session_id` integer, nullable
  - `master_id` string, nullable
  - `text_id` integer, nullable
  - `juan_num` integer, nullable
  - `selected_text` string, nullable
  - `page_content` string, nullable
  - `hot_question_id` integer, nullable
  - `regenerate` boolean
  - `model_id` string, nullable
  - `attachment_ids` integer[], nullable

## Response `200`

Successful Response

- ChatResponse
  - `session_id` integer, required
  - `message` string, required
  - `sources` ChatSource[], required
    - `text_id` integer, required
    - `juan_num` integer, required
    - `chunk_index` integer
    - `chunk_text` string, required
    - `score` number, required
    - `title_zh` string
    - `lang` string
    - `source_id` integer, nullable
    - `parallel_chunks` ParallelChunk[]
      - `text_id` integer, required
      - `juan_num` integer, required
      - `chunk_index` integer, required
      - `chunk_text` string, required
      - `lang` string, required
      - `title` string
      - `confidence` number
      - `urn` string, nullable
    - `urn` string, nullable
    - `located` boolean
    - `located_window` string, nullable
    - `located_texts` integer, nullable
  - `trust_status` ChatTrustStatus
    - `state` 'verified' | 'citation_corrected' | 'quote_relaxed' | 'quote_unverified' | 'sources_available' | 'no_sources', required
    - `citation_count` integer
    - `source_count` integer
    - `citation_mutation_count` integer
    - `quote_mutation_count` integer
    - `quote_checked_count` integer, nullable
    - `checked_quotes` ChatCheckedQuote[], nullable
      - `title` string, required
      - `juan` integer, nullable
      - `quote` string, required
    - `max_source_score` number, nullable
    - `min_source_score` number, nullable

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/fojin/apis/fojin-api-buddhist-digital-text-platform.md) · [All operations](https://skmtc.dev/fojin/apis/fojin-api-buddhist-digital-text-platform/llms.txt) · [OpenAPI document](https://skmtc.dev/fojin/apis/fojin-api-buddhist-digital-text-platform/revisions/969714238c61?raw)
