Quick Start
Quickest way to get started using the client libraries.
Installation Instructions
Requires Python ≥ 3.9. Python ≥ 3.10 is highly recommended.
Simply install the PyPi package using pip:
pip install mindee>=4.27.1
Don't see support for your favorite language or framework? Make a feature request!
Send a File and Poll
Make a note of your model's ID for use in the API.
When getting started, we recommend using the polling method which will be quickest (unless you happen to already have access to a public-facing Web server).
Here are basic code examples, these are self-contained and can be run as-is:
Requires Python ≥ 3.9. Python ≥ 3.10 is highly recommended. Requires the Mindee Python client library version 4.27.1 or greater.
from mindee import ClientV2, InferenceParameters
input_path = "/path/to/the/file.ext"
api_key = "MY_API_KEY"
model_id = "MY_MODEL_ID"
# Init a new client
mindee_client = ClientV2(api_key)
# Set inference parameters
params = InferenceParameters(
# ID of the model, required.
model_id=model_id,
# If set to `True`, will enable Retrieval-Augmented Generation.
rag=False,
)
# Load a file from disk
input_source = mindee_client.source_from_path(input_path)
# Send for processing using polling
response = mindee_client.enqueue_and_get_inference(
input_source, params
)
# Print a brief summary of the parsed data
print(response.inference)
Details on Sending
For details on available options and advanced usage, check the following sections:
Processing the Results
Once you've sent the file and retrieved the results, you can start extracting the JSON payload.
The model's fields will be in the fields
object in the returned JSON, in the response
variable returned from the above step.
Each key in the fields
object corresponds to the field's name
in your model configuration.
You'll want to adapt your processing depending on the type of field, for example looping over lists.
Accessing a simple value, where my_simple_field
is the name of the field in the Model.
my_simple_field = response.inference.result.fields["my_simple_field"]
field_value = my_simple_field.value
Accessing a list of values, where my_list_field
is the name of the field in the Model.
my_list_field = response.inference.result.fields["my_list_field"]
# access a value at a given position
field_first_value = my_list_field.items[0].value
# loop over all values in the list
for list_item in my_list_field:
item_value = list_item.value
Accessing an object field, where my_object_field
is the name of the field in the Model.
In this hypothetical case, the object has a sub-field named sub_field
.
object_field = response.inference.result.fields["my_object_field"]
sub_field_value = object_field.fields["sub_field"].value
Accessing a list of objects, where my_object_list_field
is the name of the field in the Model.
object_list_field = response.inference.result.fields["my_object_list_field"]
# access an object at a given position
object_item_0 = object_list_field.items[0]
sub_field_0_value = object_item_0["sub_field"].value
# loop over object lists
for object_item in object_list_field.items:
sub_field_value = object_item.fields["sub_field"].value
Details on Processing
For details on available options and advanced usage, check the following sections:
Last updated
Was this helpful?