decthings

Model / createModel


Create a new model.

Request parameters

{
    /** The model's name. */
    name: string,
    /** A description of the model. */
    description: string,
    /** If true, all Decthings users can find and use this model. Defaults to false. */
    publicAccess?: boolean,
    /** Required configuration for this model, such as model type, language to use, etc. */
    options: {
        type: 'code',
        /** Tags are used to specify things like model type (image classifier, etc.) and other metadata. */
        tags?: {
            tag: string,
            value: string
        }[],
        parameterDefinitions?: ParameterDefinitions,
        language: 'go' | 'javascript' | 'typescript' | 'python' | 'rust',
        /** At the time of writing, presets "none", "empty", "tensorflowjs", "pytorch" and "tensorflow" are available. */
        preset?: string,
        wasm?: boolean
    } | {
        type: 'upload',
        /** Tags are used to specify things like model type (image classifier, etc.) and other metadata. */
        tags?: {
            tag: string,
            value: string
        }[],
        parameterDefinitions?: ParameterDefinitions,
        /** At the time of writing, formats "tflite" and "onnx" are available. */
        format: string,
        data: Buffer
    } | {
        type: 'basedOnModelSnapshot',
        /** Tags are used to specify things like model type (image classifier, etc.) and other metadata. */
        tags?: {
            tag: string,
            value: string
        }[],
        modelId: string,
        snapshotId: string,
        initialState: {
            method: 'copy'
        } | {
            method: 'create',
            name: string,
            params: DecthingsParameterProvider[],
            launcherSpec: LauncherSpec
        } | {
            method: 'upload',
            name: string,
            data: {
                key: string,
                data: Buffer
            }[]
        }
    } | {
        type: 'fromExisting',
        /** Tags are used to specify things like model type (image classifier, etc.) and other metadata. */
        tags?: {
            tag: string,
            value: string
        }[],
        modelId: string,
        snapshotId?: string
    }
}

Where "ParameterDefinitions" and "DecthingsParameterProvider" are defined as:

export type ParameterDefinitions = {
    createState: DecthingsParameterDefinition,
    train: DecthingsParameterDefinition,
    evaluateInput: DecthingsParameterDefinition,
    evaluateOutput: DecthingsParameterDefinition
}

export type DecthingsParameterProvider = {
    name: string,
    data: {
        type: 'dataset',
        datasetId: string,
        datasetKey: string
    } | {
        type: 'data',
        data: DecthingsTensor[]
    }
}

Response

{
    /** If successful. One of "result" and "error" will be present. */
    result?: {
        /** A unique identifier which you should use in subsequent API calls. */
        modelId: string,
        /**
         * Will be true if an initial state is being create, which means the model is being created until the operation is
         * finished.
         */
        isNowCreating: boolean
    },

    /** If failed */
    error?: {
        code: 'name_already_used' | 'organization_not_found' | 'access_denied' | 'model_not_found' | 'snapshot_not_found' | 'quota_exceeded' | 'server_overloaded' | 'invalid_executable_file' | 'read_executable_file_failed' | 'bad_credentials' | 'too_many_requests' | 'payment_required' | 'unknown'
    } | {
        code: 'dataset_not_found',
        datasetId: string
    } | {
        code: 'dataset_key_not_found',
        datasetId: string,
        datasetKey: string
    } | {
        code: 'invalid_parameter',
        parameterName: string,
        reason: string
    }
}

Example

Following the installation guide to setup the Decthings API for TypeScript. Add your parameters to the following code and run it in Node.js, or in a browser by using a bundler.

The code reads your API key from file. Create an API key and save it to the file "auth.txt". Keep your key safe!

import * as fs from 'fs'
import { DecthingsClient } from '@decthings/api-client'

let apiKey = fs.readFileSync('./auth.txt').toString().trim()
let client = new DecthingsClient({ apiKey })

async function main() {
    try {
        let response = await client.model.createModel({
            name: /* Add name here */,
            description: /* Add description here */,
            options: /* Add options here */
        })
        if (result.error) {
            // Decthings sent us an error
            console.log(response.error)
        } else {
            // Success!
            console.log(response.result)
        }
    }
    catch (e) {
        // Client throws an error on connection issues. The function may or may not have succeded
        console.log(e)
    }
}
main()

Product

  • Documentation
  • Pricing
  • API reference
  • Guides

Company

  • Support

Get going!

Sign up
  • Terms and conditions
  • Privacy policy
  • Cookie policy
  • GitHub
  • LinkedIn

This website uses cookies to enhance the experience.

Learn more