Generate your clients

Generate your client from Swagger json

In this tutorial, you'll learn how to generate your client library using an Open API configuration. We're going to generate a python client but you can use the same library to generate your client in many languages.

Code generation


First you will need to download the latest swagger-codegen-cli version from maven central :

Make sure to have java installed in your computer by running the following command :

[email protected]:~$ java -version

openjdk version "" 2020-11-04
OpenJDK Runtime Environment (build
OpenJDK 64-Bit Server VM (build, mixed mode, sharing)

Download the open_api.json file from the documentation page of your Mindee project (in your project click the "Documentation" tab:

Run this command to generate the code by replacing openapi.json with the name of the JSON file you just downloaded.

[email protected]:~$ java -jar swagger-codegen-cli-version.jar generate -i openapi.json -l python -o your_api_client

You can now install your python sdk client :

Create a virtual env :

[email protected]:~$ python3 -m venv python_sdk_client_venv
[email protected]:~$ source python_sdk_client_venv/bin/activate

You can ignore this step if you are already using your own python3 virtual env.

Install your python sdk client via setuptools:

(python_sdk_client_venv) [email protected]:~$ cd your_api_client/
(python_sdk_client_venv) [email protected]:~$ python install

You are all set and ready to use your Python SDK client.

Python Usage

Create your api key from the API Keys page of your Mindee project: 

Using the predict endpoint

import swagger_client
from import ApiException
# replace XXX by your public api name in camel-case/ 
# for example, if your api is named api_name, replace XXXApi() by ApiNameApi()
api_instance = swagger_client.XXXApi()
authorization = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # your api key
version = "v1" # choose your version
file = "path/to/your/file"
feedback = "true"

    api_response = api_instance.upload_file(
        authorization, version, file, feedback=feedback
except ApiException as e:
    raise e
  • api_response is an object of type swagger_client.models.api_predict_response.ApiPredictResponse.
api_response.input_uuid # if you set feedback to 'true'
  • api_response.pages.features is a list containing all the candidates the API found for each field. Each item of the list corresponds to a page:
  'pages': {
    'candidates': [
        'feature_1': [
            'content': 'xxxx',
            'key': 'f0311d47',
            'segmentation': {
              'bounding_box': [
        'feature_2': ....


  • api_response.predictions is a dict: containing the model's predictions for each feature. Note that if you're using the v0 version of your API, this object will be set to None as there is no trained model yet.

    'feature_1': [
                    {'content': 'xxx',
                     'key': 'c5d1daf7',
                     'page_id': 0,
                     'relative_vertices': [[0.0898, 0.0693],
                                           [0.2708, 0.0635],
                                           [0.2734, 0.1035],
                                           [0.0924, 0.1094]]
                    }, ....
    'feature_2': ....




Slack Logo IconSlack Logo Icon  Join our Slack

Did this page help you?