V1 Client

class Client(api_key='', http_client=None)

Mindee API Client.

See: https://docs.mindee.com/

Parameters:
  • api_key (str)

  • http_client (Client | None)

close()

Close the HTTP client.

create_endpoint(endpoint_name, account_name='mindee', version=None)

Add a custom endpoint, created using the Mindee API Builder.

Return type:

Endpoint

Parameters:
  • endpoint_name (str) – The “API name” field in the “Settings” page of the API

  • account_name (str)

  • version (str | None)

Builder :type account_name: str, default: 'mindee' :param account_name: Your organization’s username on the API Builder :type version: str | None, default: None :param version: If set, locks the version of the model to use.

If not set, use the latest version of the model.

enqueue(product_class, input_source, include_words=False, close_file=True, page_options=None, cropper=False, endpoint=None, full_text=False, workflow_id=None, rag=False)

Enqueues a document to an asynchronous endpoint.

Parameters:
  • product_class (type[Inference]) – The document class to use. The response object will be instantiated based on this parameter.

  • input_source (LocalInputSource | URLInputSource) – The document/source file to use. Has to be created beforehand.

  • include_words (bool, default: False) – Whether to include the full text for each page. This performs a full OCR operation on the server and will increase response time.

  • close_file (bool, default: True) – Whether to close() the file after parsing it. Set to False if you need to access the file after this operation.

  • page_options (PageOptions | None, default: None) – If set, remove pages from the document as specified. This is done before sending the file to the server. It is useful to avoid page limitations.

  • cropper (bool, default: False) – Whether to include cropper results for each page. This performs a cropping operation on the server and will increase response time.

  • endpoint (Endpoint | None, default: None) – For custom endpoints, an endpoint has to be given.

  • full_text (bool, default: False) – Whether to include the full OCR text response in

  • workflow_id (str | None)

  • rag (bool)

Return type:

AsyncPredictResponse

compatible APIs.

Parameters:
  • workflow_id (str | None, default: None) – Workflow ID.

  • rag (bool, default: False) – If set, will enable Retrieval-Augmented Generation. Only works if a valid workflow_id is set.

  • product_class (type[Inference])

  • input_source (LocalInputSource | URLInputSource)

  • include_words (bool)

  • close_file (bool)

  • page_options (PageOptions | None)

  • cropper (bool)

  • endpoint (Endpoint | None)

  • full_text (bool)

Return type:

AsyncPredictResponse

enqueue_and_parse(product_class, input_source, include_words=False, close_file=True, page_options=None, cropper=False, endpoint=None, initial_delay_sec=2, delay_sec=1.5, max_retries=80, full_text=False, workflow_id=None, rag=False)

Enqueues to an asynchronous endpoint and automatically polls for a response.

Parameters:
  • product_class (type[Inference]) – The document class to use. The response object will be instantiated based on this parameter.

  • input_source (LocalInputSource | URLInputSource) – The document/source file to use. Has to be created beforehand.

  • include_words (bool, default: False) – Whether to include the full text for each page. This performs a full OCR operation on the server and will increase response time.

  • close_file (bool, default: True) – Whether to close() the file after parsing it. Set to False if you need to access the file after this operation.

  • page_options (PageOptions | None, default: None) – If set, remove pages from the document as specified. This is done before sending the file to the server. It is useful to avoid page limitations.

  • cropper (bool, default: False) – Whether to include cropper results for each page. This performs a cropping operation on the server and will increase response time.

  • endpoint (Endpoint | None, default: None) – For custom endpoints, an endpoint has to be given.

  • initial_delay_sec (float, default: 2) – Delay between each polling attempts. This should not be shorter than 1 second.

  • delay_sec (float, default: 1.5) – Delay between each polling attempts. This should not be shorter than 1 second.

  • max_retries (int, default: 80) – Total amount of polling attempts.

  • full_text (bool, default: False) – Whether to include the full OCR text response in

  • workflow_id (str | None)

  • rag (bool)

Return type:

AsyncPredictResponse

compatible APIs.

Parameters:
  • workflow_id (str | None, default: None) – Workflow ID.

  • rag (bool, default: False) – If set, will enable Retrieval-Augmented Generation. Only works if a valid workflow_id is set.

  • product_class (type[Inference])

  • input_source (LocalInputSource | URLInputSource)

  • include_words (bool)

  • close_file (bool)

  • page_options (PageOptions | None)

  • cropper (bool)

  • endpoint (Endpoint | None)

  • initial_delay_sec (float)

  • delay_sec (float)

  • max_retries (int)

  • full_text (bool)

Return type:

AsyncPredictResponse

execute_workflow(input_source, workflow_id, options=None, page_options=None)

Send the document to a workflow execution.

Parameters:
  • input_source (LocalInputSource | URLInputSource) – The document/source file to use. Has to be created beforehand.

  • workflow_id (str) – ID of the workflow.

  • page_options (PageOptions | None, default: None) – If set, remove pages from the document as specified. This is done before sending the file to the server. It is useful to avoid page limitations.

  • options (WorkflowOptions | None, default: None) – Options for the workflow.

Return type:

WorkflowResponse

Returns:

load_prediction(product_class, local_response)

Load a prediction.

Parameters:
  • product_class (type[Inference]) – Class of the product to use.

  • local_response (LocalResponse) – Local response to load.

Return type:

AsyncPredictResponse | PredictResponse

Returns:

A valid prediction.

parse(product_class, input_source, include_words=False, close_file=True, page_options=None, cropper=False, endpoint=None, full_text=False)

Call prediction API on the document and parse the results.

Parameters:
  • product_class (type[Inference]) – The document class to use. The response object will be instantiated based on this parameter.

  • input_source (LocalInputSource | URLInputSource) – The document/source file to use. Has to be created beforehand.

  • include_words (bool, default: False) – Whether to include the full text for each page. This performs a full OCR operation on the server and will increase response time. Only available on financial document APIs.

  • close_file (bool, default: True) – Whether to close() the file after parsing it. Set to False if you need to access the file after this operation.

  • page_options (PageOptions | None, default: None) – If set, remove pages from the document as specified. This is done before sending the file to the server. It is useful to avoid page limitations.

  • cropper (bool, default: False) – Whether to include cropper results for each page. This performs a cropping operation on the server and will increase response time.

  • endpoint (Endpoint | None, default: None) – For custom endpoints, an endpoint has to be given.

  • full_text (bool, default: False) – Whether to include the full OCR text response in

Return type:

PredictResponse

compatible APIs.

parse_queued(product_class, queue_id, endpoint=None)

Parses a queued document.

Parameters:
  • product_class (type[Inference]) – The document class to use. The response object will be instantiated based on this parameter.

  • queue_id (str) – queue_id received from the API.

  • endpoint (Endpoint | None, default: None) – For custom endpoints, an endpoint has to be given.

Return type:

AsyncPredictResponse

send_feedback(product_class, document_id, feedback, endpoint=None)

Send a feedback for a document.

Parameters:
  • product_class (type[Inference]) – The document class to use. The response object will be instantiated based on this parameter.

  • document_id (str) – The id of the document to send feedback to.

  • feedback (dict[str, Any]) – Feedback to send.

  • endpoint (Endpoint | None, default: None) – For custom endpoints, an endpoint has to be given.

Return type:

FeedbackResponse

api_key: str

API key for all endpoints.

http_client: Client | None

HTTP client for making requests.

get_bound_classname(type_var)

Get the name of the bound class.

Return type:

str