KosmoKrator

data

Mindee Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Mindee KosmoKrator integration.

Lua Namespace

Agents call this integration through app.integrations.mindee.*. Use lua_read_doc("integrations.mindee") inside KosmoKrator to discover the same reference at runtime.

Call Lua from the Headless CLI

Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic Mindee workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.mindee.predict_document({account = "example_account", api_name = "example_api_name", api_version = "example_api_version", document = "example_document", file_name = "example_file_name", options = "example_options"}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("mindee"))' --json
kosmo integrations:lua --eval 'print(docs.read("mindee.predict_document"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local mindee = app.integrations.mindee
local result = mindee.predict_document({account = "example_account", api_name = "example_api_name", api_version = "example_api_version", document = "example_document", file_name = "example_file_name", options = "example_options"})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.mindee, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.mindee.default.* or app.integrations.mindee.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Mindee, use the narrower mcp:lua command.

MCP Lua command
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Mindee Lua Reference

Namespace: mindee

Mindee tools return the raw Mindee JSON response. Prediction data is normally under document.inference.prediction; asynchronous enqueue responses include a job object.

Generic Prediction

Use generic prediction for any off-the-shelf or custom Mindee API.

local result = app.integrations.mindee.predict_document({
  account = "mindee",
  api_name = "expense_receipts",
  api_version = "v5",
  document = "/tmp/receipt.jpg",
})

Parameters:

NameTypeRequiredDescription
accountstringyesAccount name. Use mindee for off-the-shelf APIs.
api_namestringyesAPI name such as invoices or expense_receipts.
api_versionstringyesAPI version such as v4, v5, or v1.
documentstringyesFile path, URL, or base64 document content.
file_namestringnoFilename for multipart or base64 uploads.
optionsobjectnoAdditional endpoint query parameters.

Async Prediction

local queued = app.integrations.mindee.predict_document_async({
  account = "mindee",
  api_name = "invoices",
  api_version = "v4",
  document = "/tmp/invoice.pdf",
})

local status = app.integrations.mindee.get_async_prediction({
  account = "mindee",
  api_name = "invoices",
  api_version = "v4",
  job_id = queued.job.id,
})

When a job is complete, Mindee may return a redirect to the completed document. The tool reports redirect responses as { status = 302, location = "..." }.

Convenience Tools

local invoice = app.integrations.mindee.parse_invoice({
  document = "/tmp/invoice.pdf",
})

local receipt = app.integrations.mindee.parse_receipt({
  document = "/tmp/receipt.jpg",
})

local passport = app.integrations.mindee.parse_passport({
  document = "/tmp/passport.png",
})

local custom = app.integrations.mindee.parse_custom({
  endpoint_id = "acme/purchase_orders/v1",
  document = "/tmp/purchase_order.pdf",
})

Convenience tools accept document, optional file_name, and optional options.

Input Notes

Local file paths are sent as multipart document uploads. URL and base64 inputs are sent as JSON with a document field. Use fake or non-sensitive documents in tests and examples.

Multi-Account Usage

app.integrations.mindee.default.parse_receipt({ document = "/tmp/receipt.jpg" })
app.integrations.mindee.production.predict_document({
  account = "mindee",
  api_name = "invoices",
  api_version = "v4",
  document = "/tmp/invoice.pdf",
})
Raw agent markdown
# Mindee Lua Reference

Namespace: `mindee`

Mindee tools return the raw Mindee JSON response. Prediction data is normally
under `document.inference.prediction`; asynchronous enqueue responses include a
`job` object.

## Generic Prediction

Use generic prediction for any off-the-shelf or custom Mindee API.

```lua
local result = app.integrations.mindee.predict_document({
  account = "mindee",
  api_name = "expense_receipts",
  api_version = "v5",
  document = "/tmp/receipt.jpg",
})
```

Parameters:

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `account` | string | yes | Account name. Use `mindee` for off-the-shelf APIs. |
| `api_name` | string | yes | API name such as `invoices` or `expense_receipts`. |
| `api_version` | string | yes | API version such as `v4`, `v5`, or `v1`. |
| `document` | string | yes | File path, URL, or base64 document content. |
| `file_name` | string | no | Filename for multipart or base64 uploads. |
| `options` | object | no | Additional endpoint query parameters. |

## Async Prediction

```lua
local queued = app.integrations.mindee.predict_document_async({
  account = "mindee",
  api_name = "invoices",
  api_version = "v4",
  document = "/tmp/invoice.pdf",
})

local status = app.integrations.mindee.get_async_prediction({
  account = "mindee",
  api_name = "invoices",
  api_version = "v4",
  job_id = queued.job.id,
})
```

When a job is complete, Mindee may return a redirect to the completed document.
The tool reports redirect responses as `{ status = 302, location = "..." }`.

## Convenience Tools

```lua
local invoice = app.integrations.mindee.parse_invoice({
  document = "/tmp/invoice.pdf",
})

local receipt = app.integrations.mindee.parse_receipt({
  document = "/tmp/receipt.jpg",
})

local passport = app.integrations.mindee.parse_passport({
  document = "/tmp/passport.png",
})

local custom = app.integrations.mindee.parse_custom({
  endpoint_id = "acme/purchase_orders/v1",
  document = "/tmp/purchase_order.pdf",
})
```

Convenience tools accept `document`, optional `file_name`, and optional
`options`.

## Input Notes

Local file paths are sent as multipart `document` uploads. URL and base64 inputs
are sent as JSON with a `document` field. Use fake or non-sensitive documents in
tests and examples.

## Multi-Account Usage

```lua
app.integrations.mindee.default.parse_receipt({ document = "/tmp/receipt.jpg" })
app.integrations.mindee.production.predict_document({
  account = "mindee",
  api_name = "invoices",
  api_version = "v4",
  document = "/tmp/invoice.pdf",
})
```
Metadata-derived Lua example
local result = app.integrations.mindee.predict_document({account = "example_account", api_name = "example_api_name", api_version = "example_api_version", document = "example_document", file_name = "example_file_name", options = "example_options"})
print(result)

Functions

predict_document Write

Parse a document synchronously with any Mindee product endpoint using account, api_name, and api_version.

Lua path
app.integrations.mindee.predict_document
Full name
mindee.mindee_predict_document
ParameterTypeRequiredDescription
account string yes Mindee account name, usually "mindee" for off-the-shelf APIs.
api_name string yes Mindee API name such as invoices or expense_receipts.
api_version string yes Mindee API version such as v4, v5, or v1.
document string yes File path, URL, or base64-encoded document content.
file_name string no Optional filename for multipart or base64 uploads.
options object no Additional query parameters for the Mindee endpoint.
predict_document_async Write

Send a document to a Mindee asynchronous prediction endpoint and return the queued job response.

Lua path
app.integrations.mindee.predict_document_async
Full name
mindee.mindee_predict_document_async
ParameterTypeRequiredDescription
account string yes Mindee account name.
api_name string yes Mindee API name.
api_version string yes Mindee API version.
document string yes File path, URL, or base64-encoded document content.
file_name string no Optional filename for multipart or base64 uploads.
options object no Additional query parameters for the Mindee endpoint.
get_async_prediction Read

Retrieve a Mindee asynchronous prediction job status, or the completed document redirect when the job has finished.

Lua path
app.integrations.mindee.get_async_prediction
Full name
mindee.mindee_get_async_prediction
ParameterTypeRequiredDescription
account string yes Mindee account name.
api_name string yes Mindee API name.
api_version string yes Mindee API version.
job_id string yes Mindee asynchronous job ID.
parse_invoice Write

Parse an invoice document (PDF or image) and extract structured data including supplier, line items, totals, dates, and tax details.

Lua path
app.integrations.mindee.parse_invoice
Full name
mindee.mindee_parse_invoice
ParameterTypeRequiredDescription
document string yes The document to parse — either a file path or a base64-encoded string of the file content.
file_name string no Optional filename for the document (used when providing base64 content).
options object no Additional query parameters for the Mindee endpoint.
parse_receipt Write

Parse an expense receipt (PDF or image) and extract structured data including merchant, line items, totals, dates, and category.

Lua path
app.integrations.mindee.parse_receipt
Full name
mindee.mindee_parse_receipt
ParameterTypeRequiredDescription
document string yes The receipt document to parse — either a file path or a base64-encoded string of the file content.
file_name string no Optional filename for the document (used when providing base64 content).
options object no Additional query parameters for the Mindee endpoint.
parse_passport Write

Parse a passport document (PDF or image) and extract structured data including full name, date of birth, nationality, passport number, and expiry date.

Lua path
app.integrations.mindee.parse_passport
Full name
mindee.mindee_parse_passport
ParameterTypeRequiredDescription
document string yes The passport document to parse — either a file path or a base64-encoded string of the file content.
file_name string no Optional filename for the document (used when providing base64 content).
options object no Additional query parameters for the Mindee endpoint.
parse_custom_document Write

Parse a document using a custom Mindee API endpoint. Requires an endpoint_id from your custom model trained in the Mindee API builder.

Lua path
app.integrations.mindee.parse_custom_document
Full name
mindee.mindee_parse_custom
ParameterTypeRequiredDescription
endpoint_id string yes The custom endpoint ID from your Mindee dashboard (e.g., "username/endpoint_name/v1").
document string yes The document to parse — either a file path or a base64-encoded string of the file content.
file_name string no Optional filename for the document (used when providing base64 content).
options object no Additional query parameters for the Mindee endpoint.