GuidesRecipesAPI ReferenceChangelogDiscussions
Log In

client.Models().ListModels()

Retrieve models

client.Models().ListModels(ctx context.Context, input *ListModelsInput) (*ListModelsOutput, error)

Returns a list of models. The list includes each model’s model_id, versions, and latest_version.

Filtering, Paging, and Sorting

These helper functions can be used to filter down the results returned by client.Models().ListModels()

Filtering

Paging

Sorting

FilterTypeDescriptionExample
modzy.ListModelsFilterFieldModelIDstrFilters models by identifier. Separate multiple values with ;.'ed542963de'
modzy.ListModelsFilterFieldAuthorstrFilters models by the organization that created them. Separate multiple values with ;.'Open Source'
modzy.ListModelsFilterFieldCreatedByEmailstrFilters models by creator’s email. Separate multiple values with ;.'[email protected]'
modzy.ListModelsFilterFieldNamestrFilters models by name. Separate multiple values with ;.'Sentiment Analysis'
modzy.ListModelsFilterFieldDescriptionstrFilters models by description.'Sentiment Analysis'
modzy.ListModelsFilterFieldIsActivebooleanFilters models by status.True
modzy.ListModelsFilterFieldIsRecommendedbooleanFilters models recommended by Modzy.False
modzy.ListModelsFilterFieldLastActiveDateTimedatetime
str
Filters models by the latest use date. It requires ISO8601 formated string (YYYY-MM-DDThh:mm:ss.sTZD) or a datetime object (https://docs.python.org/3/library/datetime.html).datetime.now()
'2021-08-13T07:28:03.831'
modzy.ListModelsFilterFieldIsExpireddatetime
str
Filters models by the expiration date. It requires ISO8601 formated string (YYYY-MM-DDThh:mm:ss.sTZD) or a datetime object (https://docs.python.org/3/library/datetime.html).datetime.now()
'2021-08-13T07:28:03.831'
sort_bystrModels can be sorted by modelId, author, submittedByEmail, name, isExpired, isActive, latestVersion, isRecommended, lastActiveDateTime, expirationDateTime.'name'
directionstrOrders the records in ascending (ASC) or descending (DESC) order. It defaults to ASC.'DESC'
pageintThe page number to be returned. Defaults to 0.1
per_pageintThe number of records returned per page. Defaults to 10.15

Returns

A JSON object with a list of any models the meet the criteria specified by the parameters supplied.

[
  {
    "model_id": "string",
    "latest_version": "string",
    "versions": ["string"]
  }
]

Examples

Print a list of first 10 models returned by the List models API route.

package main

import (
	"context"
	"fmt"
	"log"

	modzy "github.com/modzy/sdk-go"
)

func main() {
	ctx := context.TODO()
  modzyURL := "https://trial.app.modzy.com"
	apiKey := API_KEY

	client := modzy.NewClient(modzyURL).WithAPIKey(apiKey)
	listModelsInput := (&modzy.ListModelsInput{}).WithPaging(10, 1)
	out, err := client.Models().ListModels(ctx, listModelsInput)
	if err != nil {
		log.Fatalf("Unexpected error %s", err)
		return
	}
	for _, model := range out.Models {
		fmt.Println("Model ID: ", model.ID)
	}

}

Search for specific models by author

package main

import (
	"context"
	"log"

	modzy "github.com/modzy/sdk-go"
)

func main() {
	ctx := context.TODO()
  modzyURL := "https://trial.app.modzy.com"
	apiKey := API_KEY

	client := modzy.NewClient(modzyURL).WithAPIKey(apiKey)
	listModelsInput = (&modzy.ListModelsInput{}).WithPaging(1000, 0).WithFilterAnd(modzy.ListModelsFilterFieldAuthor, "Open Source")
	out, err = client.Models().ListModels(ctx, listModelsInput)
	if err != nil {
		log.Fatalf("Unexpected error %s", err)
		return
	}
	log.Printf("Open Source models: %d\n", len(out.Models))

}

Search for active models

package main

import (
	"context"
	"log"

	modzy "github.com/modzy/sdk-go"
)

func main() {
	ctx := context.TODO()
  modzyURL := "https://trial.app.modzy.com"
	apiKey := API_KEY

	client := modzy.NewClient(modzyURL).WithAPIKey(apiKey)
	listModelsInput = (&modzy.ListModelsInput{}).WithPaging(1000, 0).WithFilterAnd(modzy.ListModelsFilterFieldIsActive, "true")
	out, err = client.Models().ListModels(ctx, listModelsInput)
	if err != nil {
		log.Fatalf("Unexpected error %s", err)
		return
	}
	log.Printf("Active models: %d\n", len(out.Models))

}

Search by name (and paginate the results)

package main

import (
	"context"
	"log"

	modzy "github.com/modzy/sdk-go"
)

func main() {
	ctx := context.TODO()
  modzyURL := "https://trial.app.modzy.com"
	apiKey := API_KEY

	client := modzy.NewClient(modzyURL).WithAPIKey(apiKey)
	listModelsInput = (&modzy.ListModelsInput{}).WithPaging(5, 0).WithFilterAnd(modzy.ListModelsFilterFieldName, "Image")
	out, err = client.Models().ListModels(ctx, listModelsInput)
	if err != nil {
		log.Fatalf("Unexpected error %s", err)
		return
	}
	log.Printf("Models with name start with 'Image': %d\n", len(out.Models))

}