JavaScript

Installation

CodeMaker AI JavaScript SDK can be added to NPM package using npm or yarn command.

npm install codemaker-sdk --save

Usage

Next in code instantiate API Client and pass the API Key:

const client = new Client(() => "<API_KEY>");

To trigger the code generation process invoke the CreateProcess API:

const task = await client.createProcess({
    process: {
        mode: Mode.code,
        language: Language.java,
        input: {
            source: source,
        },
        options: {
            // optional code generation options
        },
    }
});

This will create a new code generation task. The return response contains a unique task id, which can be used for checking the task status and retrieving the generated output. The status of the task can be checked afterward using GetProcessStatus API.

const status = await client.getProcessStatus({
    id: task.data.id,
});

Once the task will be COMPLETED the generated result can be retrieved using GetProcessOutput API.

const output = await client.getProcessOutput({
    id: task.data.id,
});

Last updated