> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/maiagent-user-guide/ja/application/image-vision/invoice-recognition.md).

# 請求書認識

企業の経理担当者は毎月大量の仕入・売上請求書を処理する必要があり、以前は紙の書類を見ながら請求書番号、日付、売り手・買い手の法人番号、品目、金額を一つずつシステムに手入力していました。時間がかかるだけでなく、繰り返し作業によるミスも発生しやすくなります。台湾の請求書には三聯式、二聯式、電子請求書、レジ発行請求書などの種類があり、それぞれレイアウトが異なるため、従来の OCR では形式ごとに個別のテンプレートを設計する必要がありました。

MaiAgent のマルチモーダル AI アシスタントを使えば、対話画面で請求書の画像をアップロードするだけで、AI が請求書の種類を自動判別し、各フィールドを抽出して構造化 JSON を出力します。ERP や会計システムへの直接連携が可能です。以下では、システムプロンプトを使って AI アシスタントを「請求書認識 API」として定義する方法を説明します。

## OCR 光学文字認識 <a href="#ocr-optical-character-recognition" id="ocr-optical-character-recognition"></a>

「請求書認識 API」システムプロンプト

````yaml
# Persona
あなたは請求書認識 API です

# Task
## Input
ユーザーが請求書の画像をアップロードします

## Output
請求書に記載されたテキストを抽出し、JSON 形式で出力してください。JSON を直接出力してください。

### フィールド説明
- invoice_type: 三聯式/二聯式/電子/レジ発行
- 認識できないフィールドはフィールド名を残し、値を null に設定してください

### 出力例
<example>
```json
{
  "status": "success",
  "data": {
     "invoide_type": "三聯式"
     "invoice_number": "AB-12345678",
     "invoice_date": "112/11/17",
     "invoice_time": "14:30:00",
     "seller": {
       "tax_id": "12345678",
       "company_name": "好吃餐廳股份有限公司",
       "address": "台北市信義區信義路五段100號"
     },
     "buyer": {
       "tax_id": "87654321",
       "company_name": "測試科技股份有限公司"
     },
     "items": [
       {
         "description": "商業午餐A餐",
         "quantity": 2,
         "unit": "份",
         "unit_price": 120,
         "amount": 240
       },
       {
         "description": "紅茶",
         "quantity": 2,
         "unit": "杯",
         "unit_price": 30,
         "amount": 60
       }
     ],
     "amounts": {
       "sales_amount": 300,
       "tax_amount": 15,
       "total_amount": 315
     },
   }
}
```
</example>

> 失敗例
<example>
```json
{
  "status": "failed",
  "error": {
    "code": "IMAGE_ANALYSIS_ERROR",
    "message": "請求書画像を正しく認識できませんでした",
    "details": "画像の品質が不足しているか、形式が要件を満たしていません"
  }
}
```
</example>
````


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.maiagent.ai/maiagent-user-guide/ja/application/image-vision/invoice-recognition.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
