Skip to main content
Retrieve detailed information about a specific template, including full configuration, resources, features, and build information.

Overview

Getting template details helps you:
  • View complete template configuration
  • Check resource specifications (min/max/default)
  • Review available features and capabilities
  • Access build information and status
  • Verify template availability before use
Template details include more information than the list view, including full configuration, build steps, and organization-specific details.

Get Template by Name

Get detailed information about a specific template:
  • Python
  • JavaScript
from hopx_ai import Sandbox

# Get template details
template = Sandbox.get_template("code-interpreter")

print(f"Template: {template.display_name}")
print(f"Name: {template.name}")
print(f"Description: {template.description}")
print(f"Category: {template.category}")
print(f"Language: {template.language}")
print(f"Status: {template.status}")

Resource Specifications

View resource specifications (default, min, max):
  • Python
  • JavaScript
from hopx_ai import Sandbox

template = Sandbox.get_template("code-interpreter")

# Default resources
if template.default_resources:
    res = template.default_resources
    print(f"Default Resources:")
    print(f"  vCPU: {res.vcpu}")
    print(f"  Memory: {res.memory_mb}MB")
    print(f"  Disk: {res.disk_gb}GB")

# Minimum resources
if template.min_resources:
    min_res = template.min_resources
    print(f"\nMinimum Resources:")
    print(f"  vCPU: {min_res.vcpu}")
    print(f"  Memory: {min_res.memory_mb}MB")
    print(f"  Disk: {min_res.disk_gb}GB")

# Maximum resources
if template.max_resources:
    max_res = template.max_resources
    print(f"\nMaximum Resources:")
    print(f"  vCPU: {max_res.vcpu}")
    print(f"  Memory: {max_res.memory_mb}MB")
    print(f"  Disk: {max_res.disk_gb}GB")

Features and Tags

View template features and tags:
  • Python
  • JavaScript
from hopx_ai import Sandbox

template = Sandbox.get_template("code-interpreter")

# Features
if template.features:
    print("Features:")
    for feature in template.features:
        print(f"  β€’ {feature}")

# Tags
if template.tags:
    print("\nTags:")
    for tag in template.tags:
        print(f"  β€’ {tag}")

# Popularity
if template.popularity_score:
    print(f"\nPopularity Score: {template.popularity_score}")

Template Status and Availability

Check template status and availability:
  • Python
  • JavaScript
from hopx_ai import Sandbox
from hopx_ai.errors import NotFoundError

try:
    template = Sandbox.get_template("code-interpreter")
    
    print(f"Status: {template.status}")
    print(f"Active: {template.is_active}")
    print(f"Public: {template.is_public}")
    
    if template.status == "active":
        print("βœ… Template is available for use")
    elif template.status == "building":
        print("⏳ Template is currently being built")
    elif template.status == "failed":
        print("❌ Template build failed")
    else:
        print(f"⚠️ Template status: {template.status}")
        
except NotFoundError:
    print("❌ Template not found")

Organization-Specific Templates

Check if template is organization-specific:
  • Python
  • JavaScript
from hopx_ai import Sandbox

template = Sandbox.get_template("my-custom-template")

if template.organization_id:
    print(f"Organization Template: {template.organization_id}")
    print("This is a custom template for your organization")
else:
    print("Public Template")
    print("Available to all users")

Complete Example

Here’s a complete example showing template details:
  • Python
  • JavaScript
from hopx_ai import Sandbox
from hopx_ai.errors import NotFoundError

def show_template_details(template_name: str):
    try:
        template = Sandbox.get_template(template_name)
        
        print(f"πŸ“‹ {template.display_name}")
        print(f"   Name: {template.name}")
        print(f"   ID: {template.id}")
        print()
        
        if template.description:
            print(f"πŸ“ Description:")
            print(f"   {template.description}")
            print()
        
        print(f"🏷️  Metadata:")
        print(f"   Category: {template.category or 'N/A'}")
        print(f"   Language: {template.language or 'N/A'}")
        print(f"   Status: {template.status}")
        print(f"   Active: {template.is_active}")
        print(f"   Public: {template.is_public}")
        print()
        
        if template.default_resources:
            res = template.default_resources
            print(f"πŸ’» Default Resources:")
            print(f"   vCPU: {res.vcpu}")
            print(f"   Memory: {res.memory_mb}MB")
            print(f"   Disk: {res.disk_gb}GB")
            print()
        
        if template.min_resources or template.max_resources:
            print(f"πŸ“Š Resource Limits:")
            if template.min_resources:
                min_res = template.min_resources
                print(f"   Min: {min_res.vcpu}vCPU, {min_res.memory_mb}MB RAM")
            if template.max_resources:
                max_res = template.max_resources
                print(f"   Max: {max_res.vcpu}vCPU, {max_res.memory_mb}MB RAM")
            print()
        
        if template.features:
            print(f"✨ Features:")
            for feature in template.features:
                print(f"   β€’ {feature}")
            print()
        
        if template.tags:
            print(f"🏷️  Tags:")
            for tag in template.tags:
                print(f"   β€’ {tag}")
            print()
        
        if template.docs_url:
            print(f"πŸ“š Documentation: {template.docs_url}")
            print()
        
        if template.organization_id:
            print(f"🏒 Organization: {template.organization_id}")
            print("   (Custom template)")
        
    except NotFoundError:
        print(f"❌ Template '{template_name}' not found")

# Show details for a template
show_template_details("code-interpreter")

Best Practices

1

1. Get Details Before Use

Always get template details to verify resources and features before creating sandboxes.
2

2. Check Status

Verify template status is β€œactive” before using it to create sandboxes.
3

3. Review Resources

Check default, min, and max resources to ensure they meet your requirements.
4

4. Verify Features

Review features list to confirm template has capabilities you need.
5

5. Handle Not Found

Always handle NotFoundError when getting template details.

Next Steps