Skip to main content

Driver License OCR

Extract driver license information from an image, including license number, name, date of birth, and expiry date.

API Version

Extract driver license information from an image or PDF (up to 20 pages). Returns OCR text values, bounding boxes, and confidence scores for each field. Supports optional field censoring on the returned image.

Extracted Fields

KeyDescription
license_typeLicense type in Thai (e.g. รถยนต์ส่วนบุคคลชั่วคราว)
license_numberLicense number
nameHolder full name in Thai
birth_dateDate of birth (Thai locale)
ID_noThai national ID number
provinceIssuing province in Thai
issue_dateIssue date (Thai locale)
expired_dateExpiry date (Thai locale)
license_type_enLicense type in English
license_number_enLicense number in English transcription
name_enHolder full name in English
birth_date_enDate of birth (English locale)
ID_no_enThai national ID number in English transcription
province_enIssuing province in English
issue_date_enIssue date (English locale)
expired_date_enExpiry date (English locale)

Response Definition

HTTP StatusCodeMessageDescription
200--All pages were processed successfully.
206partial_contentPartial contentSome pages were processed successfully, but at least one page failed. Returned only for multi-page input, typically PDF.
400bad_requestBad RequestNo page could be processed successfully, or the request content is invalid for this API.
422validation_errorValidation ErrorRequest schema is invalid, such as missing image.
500internal_server_errorInternal Server ErrorAn unexpected server-side error occurred while processing one or more pages.

Extract Driver License Information

POST https://api.aigen.online/aiscript/driver-license/v2

Request Body

NameTypeDescription
image*StringBase64-encoded image or PDF (UTF-8). PDFs are processed up to 20 pages.
optionObjectOptional configuration object.
option.censor_fieldListList of field keys to censor in the returned image. Must match the keys in Extracted Fields.

Response Schema

Top-level

KeyTypeDescription
statusstringProcessing status: success or error.
request_idstringRequest identifier derived from the upstream gateway client id.
errorlist[ErrorObject]Page-level or request-level errors. Empty when all pages succeed.
datalist[PageResult]Extracted results, one item per processed page. Empty list on 400.

ErrorObject

KeyTypeDescription
objectstringAlways error.
codestringError code (e.g. partial_content, bad_request).
messagestringHuman-readable error description.

PageResult

Each page is a dictionary keyed by the field names in Extracted Fields. A field is returned as {} when no value is extracted on that page.

KeyTypeDescription
<field_name>FieldResult | {}Extracted value for the corresponding driver license field.
optionOptionResult | {}Present when option.censor_field is requested.

FieldResult

KeyTypeDescription
valuestring | nullExtracted text value.
bboxeslist[list[list[int]]] | nullFour-point bounding boxes in original image coordinates.
bboxes_normlist[list[list[float]]] | nullFour-point bounding boxes normalized to [0.0, 1.0].
confidencefloat | nullConfidence score of the OCR result.

OptionResult

KeyTypeDescription
censored_imageobject | nullReturned when censoring is requested and succeeds.
censored_image.image_base64stringBase64-encoded censored image.

API Response Examples

View Response
{
"status": "success",
"request_id": "4799c6e2-1433-422a-b3cb-69156fef1ac7",
"error": [],
"data": [
{
"license_type": {
"value": "รถยนต์ส่วนบุคคลชั่วคราว",
"bboxes": [
[
[91, 165],
[373, 165],
[373, 201],
[91, 201]
]
],
"bboxes_norm": [
[
[0.065, 0.114],
[0.267, 0.114],
[0.267, 0.139],
[0.065, 0.139]
]
],
"confidence": 0.98
},
"license_number": {
"value": "12345678",
"bboxes": [
[
[733, 167],
[949, 167],
[949, 209],
[733, 209]
]
],
"bboxes_norm": [
[
[0.525, 0.115],
[0.68, 0.115],
[0.68, 0.144],
[0.525, 0.144]
]
],
"confidence": 0.99
},
"name": {
"value": "นาย ตัวอย่าง ใจดี",
"bboxes": [
[
[370, 322],
[945, 322],
[945, 364],
[370, 364]
]
],
"bboxes_norm": [
[
[0.265, 0.222],
[0.677, 0.222],
[0.677, 0.251],
[0.265, 0.251]
]
],
"confidence": 0.97
},
"birth_date": {},
"ID_no": {},
"province": {},
"issue_date": {},
"expired_date": {},
"license_type_en": {},
"license_number_en": {},
"name_en": {},
"birth_date_en": {},
"ID_no_en": {},
"province_en": {},
"issue_date_en": {},
"expired_date_en": {},
"option": {}
}
]
}

API Request Examples

import requests

api = "https://api.aigen.online/aiscript/driver-license/v2"
headers = {
"x-aigen-key": "<aigen-key>",
"content-type": "application/json",
}
data = {
"image": "<base64_string>",
"option": {
"censor_field": ["name", "license_number"]
}
}

res = requests.post(api, json=data, headers=headers)
print(res.status_code)
print(res.json())