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.
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>
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".
Once you have a
version identified, get authenticated with your API key.
ModzyClient modzyClient = new ModzyClient(API_URL, API_KEY);
API_URL with the base URL of your instance of Modzy and add "/api" at the end, such as
API_KEY with a valid API key string, such as
"q0CsemRk8Xb9ev5CPck2.5SUav09fKPX0o1IX1xqG" Here's how to download an API Key from Modzy
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();
Errors may arise for different reasons. Fetch errors to know what is their cause and how to fix them.
Wrapper for different exceptions, check the message and the stacktrace.
Currently, the Java SDK supports the following API routes:
Function or Method
Retrieve all the models
Retrieve some models
Retrieve model details by identifier
Retrieve model details by name
Retrieve the list of related models
Retrieve the versions of a model by identifier
Retrieve the version details
Retrieve the raw JSON input sample of a model and version
Retrieve the output sample of a model and version
List the job history
Submit a job
Submit a job using text as inputs
Submit a job using bytes as inputs
Submit a job using files as inputs
Submit a job using aws s3 files as inputs
Submits a job using a SQL query with JDBC access params
Retrieve the job information from Modzy
Send a request to cancel the job processing
Retrieve the results of a job
Updated about 1 month ago