Skip to main content
Version: 0.1.22
Last Verified: 2025-01-27
Package: @hopx-ai/sdk on npm

Overview

The Template class provides a fluent API for building custom sandbox templates.

Import

import { Template } from '@hopx-ai/sdk';

Methods

Base Image Methods

  • template.fromUbuntuImage(version: string): Template
  • template.fromPythonImage(version: string): Template
  • template.fromNodeImage(version: string): Template
  • template.fromImage(image: string, auth?: AuthConfig): Template

Configuration Methods

  • template.copy(src: string, dest: string): Template
  • template.run(command: string): Template
  • template.env(key: string, value: string): Template
  • template.expose(port: number): Template
  • template.workdir(path: string): Template
  • template.readyCheck(check: ReadyCheck): Template
  • template.startCmd(command: string): Template

Building

async template.build(options?: BuildOptions): Promise<BuildResult>
Example:
const template = new Template()
    .fromPythonImage('3.11')
    .run('pip install flask')
    .expose(5000)
    .startCmd('python app.py');

const result = await template.build();
console.log(`Template ID: ${result.templateId}`);

  • Ready Checks - Ready check utilities
  • Sandbox - Use templates with Sandbox.create({ template: ... })

See Also

Next Steps

Now that you understand template building, explore: