Modzy's Java SDK provides a convenient wrapper around many of Modzy's most popular API routes. SDK functions include querying models, submitting inference jobs, and returning results directly to your IDE or program.

Installation

Clone the repository

$ git clone https://github.com/modzy/sdk-java.git

Use maven to install the SDK

$ ./mvnw install -DskipTests=true

Add the dependency in your pom.xml file

<dependency>
    <groupId>com.modzy</groupId>
    <artifactId>modzy-sdk</artifactId>
    <version>0.0.1</version>
</dependency>

Usage

Get your API key

API keys are security credentials required to perform API requests to Modzy. Our API keys are composed of an ID that is split by a dot into two parts: a public and private part.

The public part is the API keys' visible part only used to identify the key and by itself, it’s unable to perform API requests.

The private part is the public part's complement and it’s required to perform API requests. Since it’s not stored on Modzy’s servers, it cannot be recovered. Make sure to save it securely. If lost, you can replace the API key.

Find your API key in your user profile. To get your full API key click on "Get key".

Initialize

Once you have a model and version identified, get authenticated with your API key.

ModzyClient modzyClient = new ModzyClient(API_URL, API_KEY);

Replace API_URL with the base URL of your instance of Modzy and add "/api" at the end, such as "https://app.modzy.com/api"

Replace API_KEY with a valid API key string, such as "q0CsemRk8Xb9ev5CPck2.5SUav09fKPX0o1IX1xqG" Here's how to download an API Key from Modzy

Basic usage

Submit a job providing the model, version, and input file:

Job job = modzyClient.submitJobText("ed542963de", "0.0.27", "Modzy is great!");

Hold until the inference is complete and results become available:

Job job = modzyClient.blockUntilComplete(job, 20000);

Get the output results:

JobOutput<JsonNode> jobResult = modzyClient.getResult(job);
Map<String,Map<String,JsonNode>> results = jobResult.getResults();

Fetch Errors

Errors may arise for different reasons. Fetch errors to know what is their cause and how to fix them.

Error

Description

ApiException

Wrapper for different exceptions, check the message and the stacktrace.

Functions & Methods

Currently, the Java SDK supports the following API routes:

Function or Method

Description

modzyClient.getAllModels

Retrieve all the models

modzyClient.getModels

Retrieve some models

modzyClient.getModel

Retrieve model details by identifier

modzyClient.getModelByName

Retrieve model details by name

modzyClient.getRelatedModels

Retrieve the list of related models

modzyClient.getModelVersions

Retrieve the versions of a model by identifier

modzyClient.getModelVersion

Retrieve the version details

modzyClient.getModelVersionInputSample

Retrieve the raw JSON input sample of a model and version

modzyClient.getModelVersionOutputSample

Retrieve the output sample of a model and version

modzyClient.getJobClient().getJobHistory

List the job history

modzyClient.getJobClient().submitJob

Submit a job

modzyClient.submitJobText

Submit a job using text as inputs

modzyClient.submitJobEmbedded

Submit a job using bytes as inputs

modzyClient.submitJobFile

Submit a job using files as inputs

modzyClient.submitAWSS3

Submit a job using aws s3 files as inputs

modzyClient.submitJobJDBC

Submits a job using a SQL query with JDBC access params

modzyClient.getJob

Retrieve the job information from Modzy

modzyClient.getJobClient().cancelJob

Send a request to cancel the job processing

modzyClient.getResult

Retrieve the results of a job


Did this page help you?