### Setup Script for Local Development Environment Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/ai-machine-learning/openvoice-tts-voice-cloning.mdx This bash script automates the setup of the development environment for the Open Voice project. It creates a virtual environment, installs dependencies from requirements.txt, installs specific PyTorch versions, and downloads/unpacks the necessary model checkpoints. Run this script to prepare your local machine for development. ```bash #! /bin/bash set -e echo "setup the curent environment" CURRENT_DIRECTORY="$( dirname "${BASH_SOURCE[0]}" )" cd "${CURRENT_DIRECTORY}" echo "current directory: $( pwd )" echo "setup development environment for inference" OPENVOICE_DIR="$( cd .. && pwd )" echo "dev directory set to: ${OPENVOICE_DIR}" echo "remove old virtual environment" rm -rf "${OPENVOICE_DIR}/.venv" echo "create new virtual environment" python3.9 -m venv "${OPENVOICE_DIR}/.venv" echo "activate virtual environment" source "${OPENVOICE_DIR}/.venv/bin/activate" echo "installing dependencies ..." (cd "${OPENVOICE_DIR}" && pip install --upgrade pip && pip install -r requirements.txt) pip install torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 # download the latest model wget -P ${OPENVOICE_DIR} https://myshell-public-repo-hosting.s3.amazonaws.com/checkpoints_1226.zip unzip ${OPENVOICE_DIR}/checkpoints_1226.zip -d ${OPENVOICE_DIR} rm -r ${OPENVOICE_DIR}/checkpoints_1226.zip ``` -------------------------------- ### Run Setup Script Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/ai-machine-learning/yolov8-batch-processing.mdx Command to execute the bash script for setting up the development environment and installing dependencies. ```bash bash dev/setup ``` -------------------------------- ### Main Application Setup and Run Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/ai-machine-learning/metavoice-tts-voice-cloning.mdx Initializes global state, configures logging, sets up CORS middleware, and starts the uvicorn server. Uses tyro for CLI argument parsing. ```python if __name__ == "__main__": for name in logging.root.manager.loggerDict: logger = logging.getLogger(name) logger.setLevel(logging.INFO) logging.root.setLevel(logging.INFO) GlobalState.config = tyro.cli(ServingConfig) GlobalState.tts = TTS(seed=GlobalState.config.seed, quantisation_mode=GlobalState.config.quantisation_mode) app.add_middleware( fastapi.middleware.cors.CORSMiddleware, allow_origins=["*", f"http://localhost:{GlobalState.config.port}", "http://localhost:3000"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) uvicorn.run( app, host="0.0.0.0", port=GlobalState.config.port, log_level="info", ) ``` -------------------------------- ### Complete Dockerfile Configuration Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/machine-learning/run-triton-server.mdx Full Dockerfile setup including dependency installation, file copying, and entrypoint configuration. ```dockerfile # Use the Triton server image as the base FROM nvcr.io/nvidia/tritonserver:23.09-py3 RUN apt-get update && apt-get install -y socat # Copy the local tmp/triton_repo directory to /models in the image COPY tmp/triton_repo /models # Copy the start_services script into the image COPY start_services.sh /start_services.sh # Make the script executable RUN chmod +x /start_services.sh EXPOSE 80 CMD ["/start_services.sh"] ``` -------------------------------- ### Install OpenCode via curl Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/agentic-tools/use-opencode-with-saladcloud.mdx Install OpenCode using the official curl installation script. This is a quick way to get the agent set up. ```bash curl -fsSL https://opencode.ai/install | bash ``` -------------------------------- ### Install OpenClaw with Docker Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/openclaw/openclaw-ollama-salad-hosted-telegram.mdx Clone the OpenClaw repository and run the Docker setup script for a containerized local installation. ```bash git clone https://github.com/openclaw/openclaw cd openclaw ./docker-setup.sh ``` -------------------------------- ### Initialize Project and Install SDK Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/ai-machine-learning/deploy-video-generation-comfy.mdx Commands to set up the environment and install necessary dependencies. ```bash npm init -y npm install @saladtechnologies-oss/salad-cloud-sdk npm install --save-dev typescript @types/node ``` -------------------------------- ### Initialize Development Environment Setup Script Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/computer-vision/yolov8-deployment-tutorial.mdx A bash script to clean and recreate a Python virtual environment, including specific dependency installation sequences to resolve module conflicts. ```bash #! /bin/bash set -e echo "setup the current environment" CURRENT_DIRECTORY="$( dirname "${BASH_SOURCE[0]}" )" cd "${CURRENT_DIRECTORY}" echo "current directory: $( pwd )" echo "setup development environment for inference" YOLOv8_SRC_API_DIR="$( cd .. && pwd )" echo "dev directory set to: ${YOLOv8_SRC_API_DIR}" echo "remove old virtual environment" rm -rf "${YOLOv8_SRC_API_DIR}/.venv" echo "create new virtual environment" python3.9 -m venv "${YOLOv8_SRC_API_DIR}/.venv" echo "activate virtual environment" source "${YOLOv8_SRC_API_DIR}/.venv/bin/activate" echo "installing dependencies ..." (cd "${YOLOv8_SRC_API_DIR}" && \ python -m pip install pip==21.1.1 && \ pip install numpy && \ pip install --upgrade --force-reinstall "git+https://github.com/ytdl-org/youtube-dl.git" && \ pip install lap==0.4.0 && \ pip install --upgrade pip && \ pip install -r requirements.txt) ``` -------------------------------- ### Bash Script for Environment Setup Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/ai-machine-learning/yolov8-batch-processing.mdx This script sets up a Python virtual environment, installs specific versions of pip, numpy, youtube-dl, and lap, and then installs project dependencies from requirements.txt. It ensures a clean and reproducible development environment. ```bash #! /bin/bash set -e echo "setup the curent environment" CURRENT_DIRECTORY="$( dirname "${BASH_SOURCE[0]}" )" cd "${CURRENT_DIRECTORY}" echo "current directory: $( pwd )" echo "setup development environment for inference" YOLOv8_SRC_BATCH_DIR="$( cd .. && pwd )" echo "dev directory set to: ${YOLOv8_SRC_BATCH_DIR}" echo "remove old virtual environment" rm -rf "${YOLOv8_SRC_BATCH_DIR}/.venv" echo "create new virtual environment" python3.9 -m venv "${YOLOv8_SRC_BATCH_DIR}/.venv" echo "activate virtual environment" source "${YOLOv8_SRC_BATCH_DIR}/.venv/bin/activate" echo "installing dependencies ..." (cd "${YOLOv8_SRC_BATCH_DIR}" && python -m pip install pip==21.1.1) (cd "${YOLOv8_SRC_BATCH_DIR}" && pip install numpy) (cd "${YOLOv8_SRC_BATCH_DIR}" && pip install --upgrade --force-reinstall "git+https://github.com/ytdl-org/youtube-dl.git") (cd "${YOLOv8_SRC_BATCH_DIR}" && pip install lap==0.4.0) (cd "${YOLOv8_SRC_BATCH_DIR}" && pip install --upgrade pip && pip install -r requirements.txt) ``` -------------------------------- ### Python Application Setup with R2 and RabbitMQ Clients Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/job-processing/rabbitmq.mdx Initialize R2 S3 client and retrieve RabbitMQ connection details from environment variables. Ensure necessary libraries like boto3 and pika are installed. ```python import os import boto3 import pika import json import time import threading import functools # Get the environment variables r2_aws_region = "auto" r2_aws_access_key_id = os.getenv('R2_AWS_ACCESS_KEY_ID') r2_aws_secret_access_key = os.getenv('R2_AWS_SECRET_ACCESS_KEY') r2_s3_endpoint_url = os.getenv('R2_S3_ENDPOINT_URL') r2_bucket_name = os.getenv('R2_BUCKET_NAME') amqp_url = os.getenv('AMQP_URL') job_queue = os.getenv('JOB_QUEUE') machine_id = os.getenv('SALAD_MACHINE_ID') # Create the R2 client r2 = boto3.client('s3', aws_access_key_id=r2_aws_access_key_id, aws_secret_access_key=r2_aws_secret_access_key, region_name=r2_aws_region, endpoint_url=r2_s3_endpoint_url) ``` -------------------------------- ### Install psutil Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/performance/performance-monitoring.mdx Install the psutil library using pip. This is a prerequisite for using the performance monitoring functions. ```bash pip install psutil ``` -------------------------------- ### Install Aider Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/agentic-tools/use-aider-with-saladcloud.mdx Install the Aider chat client using pip. Verify the installation by checking the version. ```bash pip install aider-chat ``` ```bash aider --version ``` -------------------------------- ### Install Required Libraries Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/transcription/how-to-guides/platform-integrations/transcribe-youtube.mdx Use this command to install yt-dlp and requests for handling YouTube downloads and HTTP requests. ```bash pip install yt-dlp requests ``` -------------------------------- ### Install SaladCloud SDK Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/migration/migrate-from-aws-batch.mdx Commands to install the SaladCloud SDK for Python and Node.js environments. ```bash # Python pip install salad-cloud-sdk # Node.js npm install @saladtechnologies/salad-cloud-sdk ``` -------------------------------- ### Install Uvicorn Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/ai-machine-learning/metavoice-tts-voice-cloning.mdx Command to install the Uvicorn ASGI server. ```bash pip install uvicorn ``` -------------------------------- ### Install svix for Node.js Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/job-processing/webhook-signature.mdx Install the `svix` library using npm. This is required before validating webhook signatures in Node.js. ```bash npm install svix ``` -------------------------------- ### Install SaladCloud Python SDK Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/migration/migrate-from-vast.mdx Install the official Python SDK for interacting with the SaladCloud API programmatically. ```bash pip install salad-cloud-sdk ``` -------------------------------- ### Start OpenClaw Onboarding Wizard Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/openclaw/openclaw-ollama-salad-hosted-telegram.mdx Run this command to initiate the OpenClaw onboarding process, which includes setting up channels and providers. ```bash openclaw onboard --install-daemon ``` -------------------------------- ### Setup Script for MetaVoice Local Development Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/ai-machine-learning/metavoice-tts-voice-cloning.mdx This bash script sets up the development environment for MetaVoice, including creating a virtual environment, installing dependencies, and setting up FFmpeg. Ensure you have Python 3.10 installed. ```bash set -e echo "setup the curent environment" CURRENT_DIRECTORY="$( dirname "${BASH_SOURCE[0]}" )" cd "${CURRENT_DIRECTORY}" echo "current directory: $( pwd )" echo "setup development environment" METAVOICE="$( cd .. && pwd )" echo "dev directory set to: ${METAVOICE}" echo "remove old virtual environment" rm -rf "${METAVOICE}/.venv" echo "create new virtual environment" python3.10 -m venv "${METAVOICE}/.venv" echo "activate virtual environment" source "${METAVOICE}/.venv/bin/activate" cd "${METAVOICE}" # install ffmpeg echo "installing ffmpeg" wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz.md5 md5sum -c ffmpeg-git-amd64-static.tar.xz.md5 tar xvf ffmpeg-git-amd64-static.tar.xz sudo mv ffmpeg-git-*-static/ffprobe ffmpeg-git-*-static/ffmpeg /usr/local/bin/ rm -rf ffmpeg-git-* ``` -------------------------------- ### Launch and Test OpenCode Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/agentic-tools/use-opencode-with-saladcloud.mdx Navigate to your project directory and start OpenCode using the command line. Test the connection by prompting it to create a 'hello world' script. ```bash cd /path/to/your/project opencode ``` -------------------------------- ### Manifest-Based Dockerfile Configuration Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/ai-machine-learning/deploy-stable-diffusion-comfy.mdx Example manifest.yaml file for specifying custom nodes to be installed at container startup. ```yaml # Custom nodes to install from the Comfy Registry custom_nodes: - comfyui-impact-pack - comfyui-videohelpersuite ``` -------------------------------- ### Quick Start with cURL Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/ai-gateway/explanation/overview.mdx Use this cURL command to make your first request to the Salad AI Gateway. Replace `` with your actual key. ```bash curl https://ai.salad.cloud/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer " \ -d '{ "model": "qwen3.6-35b-a3b", "messages": [ {"role": "user", "content": "Explain distributed GPU computing in one paragraph."} ] }' ``` -------------------------------- ### Python Setup for GCP Pub/Sub and R2 Client Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/job-processing/gcp-pub-sub.mdx Initializes necessary environment variables, creates clients for AWS S3 (R2) and Google Cloud Pub/Sub, and sets up the subscription path. ```python import os import boto3 import json import time import threading from google.cloud import pubsub_v1 # Get the environment variables r2_aws_region = "auto" r2_aws_access_key_id = os.getenv('R2_AWS_ACCESS_KEY_ID') r2_aws_secret_access_key = os.getenv('R2_AWS_SECRET_ACCESS_KEY') r2_s3_endpoint_url = os.getenv('R2_S3_ENDPOINT_URL') r2_bucket_name = os.getenv('R2_BUCKET_NAME') project_id = os.getenv('PROJECT_ID') subscription_id = os.getenv('SUBSCRIPTION_ID') ack_deadline_seconds = int(os.getenv('ACK_DEADLINE_SECONDS')) # Create the R2 client r2 = boto3.client('s3', aws_access_key_id=r2_aws_access_key_id, aws_secret_access_key=r2_aws_secret_access_key, region_name=r2_aws_region, endpoint_url=r2_s3_endpoint_url) # Create the Pub/Sub client subscriber = pubsub_v1.SubscriberClient() subscription_path = subscriber.subscription_path( project_id, subscription_id) ``` -------------------------------- ### Configuring a Dockerfile for Tailscale Integration Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/platform-integrations/tailscale-basic.mdx A Dockerfile setup that installs Tailscale, configures proxychains, and prepares the environment for a containerized application. ```Dockerfile # Select a base image FROM docker.io/pytorch/pytorch:2.6.0-cuda12.4-cudnn9-runtime # Install essential utilities RUN apt-get update && apt-get install -y \ curl \ net-tools \ iputils-ping \ nano # Install Tailscale RUN curl -fsSL https://tailscale.com/install.sh | sh # You can use either environment variables (e.g., ALL_PROXY and http_proxy) or tools like proxychains to manage outbound connections # Optional: Install and configure proxychains4 to use Tailscale's SOCKS5 proxy RUN apt-get install -y proxychains4 RUN sed -i 's/socks4[[:space:]]\+127\.0\.0\.1[[:space:]]\+9050/socks5 127.0.0.1 1055/' /etc/proxychains4.conf # Upgrade pip and install Python packages RUN pip install --upgrade pip RUN pip install flask python-dotenv RUN pip install jupyterlab ipywidgets # Set working directory and copy application files WORKDIR /app COPY hello.py /app COPY start.sh /app RUN chmod +x /app/start.sh # Default startup command CMD ["./start.sh"] ``` -------------------------------- ### Run Hermes Agent Setup Wizard Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/agentic-tools/use-hermes-agent-with-saladcloud.mdx Initiate the interactive setup wizard for Hermes Agent to configure models, memory, tools, and more. Accepts defaults for most settings. ```bash hermes setup ``` -------------------------------- ### Start Aider and Test Connection Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/agentic-tools/use-aider-with-saladcloud.mdx Navigate to your project directory and start Aider, specifying the model with the 'openai/' prefix. Test with a simple coding task. ```bash cd /path/to/your/project aider --model openai/qwen3.6-35b-a3b ``` -------------------------------- ### Generate Text with SaladCloud Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/agentic-tools/use-vercel-ai-sdk-with-saladcloud.mdx Use the `generateText` function with a SaladCloud provider to get a text response. This example uses a self-hosted configuration. ```javascript import { createOpenAICompatible } from '@ai-sdk/openai-compatible' import { generateText } from 'ai' import dotenv from 'dotenv' dotenv.config() const saladcloud = createOpenAICompatible({ name: 'saladcloud', baseURL: process.env.SALAD_BASE_URL, headers: { 'Salad-Api-Key': process.env.SALAD_API_KEY, }, }) const { text } = await generateText({ model: saladcloud('qwen3.6-35b-a3b'), prompt: 'Explain distributed GPU computing in one paragraph.', }) console.log(text) ``` -------------------------------- ### Check Deployment Status with cURL Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/quickstart-api.mdx Example of using cURL to perform a GET request to the container status endpoint with required headers. ```bash curl --request GET \ --url https://api.salad.com/api/public/organizations/{organization_name}/projects/{project_name}/containers/{container_group_name} \ --header 'Salad-Api-Key: {API_KEY}' \ --header 'accept: application/json' ``` -------------------------------- ### Dockerfile Entrypoint Configuration Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/performance/network-bandwidth-checks.mdx Demonstrates how to copy the bandwidth check script into a container image and set it as the entrypoint. Your application command is then passed as arguments to the script. ```dockerfile COPY bandwidth-check.sh /usr/local/bin/bandwidth-check RUN chmod +x /usr/local/bin/bandwidth-check ENTRYPOINT ["/usr/local/bin/bandwidth-check"] CMD ["python", "app.py"] ``` -------------------------------- ### Initialize Project Directory and Git Repository Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/ai-machine-learning/deploy-video-generation-comfy.mdx Create a new directory for your project and initialize it as a Git repository. This is the first step in setting up your video generation API project. ```bash mkdir video-generation-api cd video-generation-api git init ``` -------------------------------- ### ComfyUI API GET /health Endpoint Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/ai-machine-learning/deploy-stable-diffusion-comfy.mdx This endpoint is used for health checks. It returns a 200 status code when the server has started, indicating it is operational. ```json GET /health ``` -------------------------------- ### Python API Inference Setup Script Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/computer-vision/yolov8-deployment-tutorial.mdx This script is used for setting up the local development environment for the YOLOv8 API inference, including installing necessary dependencies. ```python echo "Setting up Python environment..." # Create a virtual environment if it doesn't exist if [ ! -d "venv" ]; then python -m venv venv fi # Activate the virtual environment source venv/bin/activate # Install dependencies from requirements.txt pip install -r requirements.txt echo "Python environment setup complete." ``` -------------------------------- ### Initialize project directory Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/nodejs/create-your-first-hello-world.mdx Create a new directory for the Node.js project and navigate into it. ```shell mkdir nodejs-server cd nodejs-server ``` -------------------------------- ### Dockerfile for GPU-accelerated PyTorch Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/deployment/docker-run.mdx Sets up a container with PyTorch, CUDA, and cuDNN. Installs Flask and copies application scripts. CMD starts inference and I/O worker processes. ```Dockerfile # Select a pre-built base image with GPU support FROM docker.io/pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime RUN apt-get update && apt-get install -y curl net-tools RUN pip install --upgrade pip RUN pip install flask WORKDIR /app COPY inference_server.py /app COPY io_worker.py /app CMD [ "bash", "-c", "python inference_server.py & python io_worker.py" ] ``` -------------------------------- ### Initialize npm Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/nodejs/create-your-first-hello-world.mdx Initialize the project to create a package.json file. ```shell npm init ``` -------------------------------- ### Initiate YOLOv8 Model Training Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/computer-vision/yolov8-model-training.mdx Use this snippet to start the training process for a YOLOv8 model. Ensure you have the YOLO library installed and the dataset configuration file ready. ```python from ultralytics import YOLO # Load the YOLOv8 Nano model model = YOLO('yolov8n.pt') # Start the training process results = model.train( data='yolo8.yaml', imgsz=640, epochs=10, batch=8, name='yolov8n_custom' ) ``` -------------------------------- ### Navigate to application directory Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/getting-started/example-image.mdx Change the current working directory to /app. ```bash cd /app ``` -------------------------------- ### SaladCloud API Helper Functions Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/job-processing/rabbitmq.mdx Provides functions to interact with the SaladCloud API for managing container groups. Use these to get, start, stop, and set replicas for your containers. ```javascript const saladBaseUrl = 'https://api.salad.com/api/public' async function getContainerGroup(org, project, containerGroupName, saladApiKey) { const url = `${saladBaseUrl}/organizations/${org}/projects/${project}/containers/${containerGroupName}` const resp = await fetch(url, { method: 'GET', headers: { 'Salad-Api-Key': saladApiKey, }, }) if (!resp.ok) { throw new Error(`Failed to fetch container group: ${resp.statusText}`) } return resp.json() } async function startContainerGroup(org, project, containerGroupName, saladApiKey) { console.log('Starting container group') const url = `${saladBaseUrl}/organizations/${org}/projects/${project}/containers/${containerGroupName}/start` const resp = await fetch(url, { method: 'POST', headers: { 'Salad-Api-Key': saladApiKey, }, }) if (!resp.ok) { throw new Error(`Failed to start container group: ${resp.statusText}`) } } async function stopContainerGroup(org, project, containerGroupName, saladApiKey) { console.log('Stopping container group') const url = `${saladBaseUrl}/organizations/${org}/projects/${project}/containers/${containerGroupName}/stop` const resp = await fetch(url, { method: 'POST', headers: { 'Salad-Api-Key': saladApiKey, }, }) if (!resp.ok) { throw new Error(`Failed to stop container group: ${resp.statusText}`) } } async function setReplicas(org, project, containerGroupName, replicas, saladApiKey) { console.log(`Setting replicas to ${replicas}`) const url = `${saladBaseUrl}/organizations/${org}/projects/${project}/containers/${containerGroupName}` const resp = await fetch(url, { method: 'PATCH', headers: { 'Salad-Api-Key': saladApiKey, 'Content-Type': 'application/merge-patch+json', }, body: JSON.stringify({ replicas }), }) if (!resp.ok) { throw new Error(`Failed to set replicas: ${resp.statusText}`) } } ``` -------------------------------- ### Initialize SaladCloud SDK Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/ai-machine-learning/deploy-video-generation-comfy.mdx Setup code for importing the SDK and initializing the client with environment variables. ```typescript import { SaladCloudSdk } from '@saladtechnologies-oss/salad-cloud-sdk' import assert from 'assert' import fs from 'fs/promises' // Get some configuration from the environment const { SALAD_API_KEY, SALAD_ORG_NAME, SALAD_PROJECT_NAME, SALAD_QUEUE_NAME } = process.env // Ensure that we have all the required configuration assert(SALAD_API_KEY, 'SALAD_API_KEY is required') const saladApiKey = SALAD_API_KEY as string assert(SALAD_ORG_NAME, 'SALAD_ORG_NAME is required') const saladOrgName = SALAD_ORG_NAME as string assert(SALAD_PROJECT_NAME, 'SALAD_PROJECT_NAME is required') const saladProjectName = SALAD_PROJECT_NAME as string assert(SALAD_QUEUE_NAME, 'SALAD_QUEUE_NAME is required') const saladQueueName = SALAD_QUEUE_NAME as string // Create an instance of the SaladCloud SDK const salad = new SaladCloudSdk({ apiKey: saladApiKey, }) ``` -------------------------------- ### Stream Chat Responses with SaladCloud Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/agentic-tools/use-vercel-ai-sdk-with-saladcloud.mdx Utilize the `streamText` function to receive chat responses incrementally, suitable for real-time chat interfaces. This example assumes a self-hosted SaladCloud setup. ```javascript import { createOpenAICompatible } from '@ai-sdk/openai-compatible' import { streamText } from 'ai' import dotenv from 'dotenv' dotenv.config() const saladcloud = createOpenAICompatible({ name: 'saladcloud', baseURL: process.env.SALAD_BASE_URL, headers: { 'Salad-Api-Key': process.env.SALAD_API_KEY, }, }) const result = streamText({ model: saladcloud('qwen3.6-35b-a3b'), messages: [ { role: 'system', content: 'You are a helpful coding assistant.' }, { role: 'user', content: 'How do I read a file in Python?' }, ], }) for await (const chunk of result.textStream) { process.stdout.write(chunk) } ``` -------------------------------- ### Start Script When Container is Ready Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/imds/container-status-endpoint.mdx This Python script checks the container's 'ready' status from the IMDS response and executes 'exampleScript.sh' if the container is ready. It requires the IMDS SDK and standard Python libraries. ```python import json from subprocess import call from salad_cloud_imds_sdk import SaladCloudImdsSdk, Environment sdk = SaladCloudImdsSdk( base_url=Environment.DEFAULT.value, timeout=10000 ) result = sdk.metadata.get_container_status() #Get the ready status out of the JSON response data = json.loads(result) status = data['ready'] if status == True: subprocess.call("exampleScript.sh") else: print("Not Ready Yet!") ``` -------------------------------- ### Send HTTP GET request to Cog server Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/machine-learning/run-cog.mdx Interact with a Cog prediction server running inside a Docker container using curl. This example fetches basic server information. ```bash root@4abbe2e7c4d9:/src# curl http://[::1]:5000/ {"docs_url":"/docs","openapi_url":"/openapi.json"} ``` -------------------------------- ### Example JSON Command Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/specifying-a-command.mdx This JSON array represents the command and arguments to be executed. The first element is the entrypoint, and subsequent elements are its arguments. ```json ["/bin/test", "arg1", "arg2", "arg3"] ``` -------------------------------- ### RabbitMQ Job Processing Example Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/job-processing/rabbitmq.mdx This JavaScript example shows a complete implementation for a scheduled job that monitors a RabbitMQ queue and adjusts the number of container replicas accordingly. It includes functions to get queue information, fetch container group details, start/stop container groups, and set replica counts. Use this as a template for your own auto-scaling solutions. ```javascript const saladBaseUrl = 'https://api.salad.com/api/public' async function getContainerGroup(org, project, containerGroupName, saladApiKey) { const url = `${saladBaseUrl}/organizations/${org}/projects/${project}/containers/${containerGroupName}` const resp = await fetch(url, { method: 'GET', headers: { 'Salad-Api-Key': saladApiKey, }, }) if (!resp.ok) { throw new Error(`Failed to fetch container group: ${resp.statusText}`) } return resp.json() } async function startContainerGroup(org, project, containerGroupName, saladApiKey) { console.log('Starting container group') const url = `${saladBaseUrl}/organizations/${org}/projects/${project}/containers/${containerGroupName}/start` const resp = await fetch(url, { method: 'POST', headers: { 'Salad-Api-Key': saladApiKey, }, }) if (!resp.ok) { throw new Error(`Failed to start container group: ${resp.statusText}`) } } async function stopContainerGroup(org, project, containerGroupName, saladApiKey) { console.log('Stopping container group') const url = `${saladBaseUrl}/organizations/${org}/projects/${project}/containers/${containerGroupName}/stop` const resp = await fetch(url, { method: 'POST', headers: { 'Salad-Api-Key': saladApiKey, }, }) if (!resp.ok) { throw new Error(`Failed to stop container group: ${resp.statusText}`) } } async function setReplicas(org, project, containerGroupName, replicas, saladApiKey) { console.log(`Setting replicas to ${replicas}`) const url = `${saladBaseUrl}/organizations/${org}/projects/${project}/containers/${containerGroupName}` const resp = await fetch(url, { method: 'PATCH', headers: { 'Salad-Api-Key': saladApiKey, 'Content-Type': 'application/merge-patch+json', }, body: JSON.stringify({ replicas }), }) if (!resp.ok) { throw new Error(`Failed to set replicas: ${resp.statusText}`) } } async function getQueueInfo(baseUrl, username, password, vHost, queueName) { const url = `${baseUrl}/api/queues/${vHost}/${queueName}` const resp = await fetch(url, { method: 'GET', headers: { Authorization: `Basic ${btoa(`${username}:${password}`)}`, }, }) if (!resp.ok) { throw new Error(`Failed to fetch queue info: ${resp.statusText}`) } return resp.json() } export default { async scheduled(event, env, ctx) { const { min_replicas, max_replicas, org, project, container_group_name, salad_api_key, rabbitmq_url, rabbitmq_username, rabbitmq_password, vhost, queue_name, } = env const queueInfo = await getQueueInfo(rabbitmq_url, rabbitmq_username, rabbitmq_password, vhost, queue_name) const numMessages = queueInfo.messages console.log(`Queue ${queue_name} has ${numMessages} messages`) const desiredReplicas = Math.min(Math.max(parseInt(min_replicas), numMessages), parseInt(max_replicas)) const containerGroup = await getContainerGroup(org, project, container_group_name, salad_api_key) const currentReplicas = containerGroup.replicas const currentState = containerGroup.current_state.status console.log( `Current replicas: ${currentReplicas}, current state: ${currentState}, desired replicas: ${desiredReplicas}`, ) if (currentState === 'stopped' && desiredReplicas > 0) { await startContainerGroup(org, project, container_group_name, salad_api_key) } if (currentState === 'running' && desiredReplicas === 0) { await stopContainerGroup(org, project, container_group_name, salad_api_key) } if (currentReplicas !== desiredReplicas) { await setReplicas(org, project, container_group_name, desiredReplicas, salad_api_key) } }, } ``` -------------------------------- ### Dockerfile for PyTorch with CUDA Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/migration/migrate-from-runpod.mdx This Dockerfile demonstrates how to containerize a PyTorch application with CUDA support. It starts from a pre-built image, installs dependencies, copies application code, and sets the startup command with IPv6 support. ```dockerfile # Start with a pre-built PyTorch+CUDA image (no manual CUDA setup!) FROM pytorch/pytorch:2.7.1-cuda12.6-cudnn9-runtime WORKDIR /app # Install additional dependencies (same as pip install on RunPod) COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code (same as uploading your files) COPY . . # Start application with IPv6 support (same as running python app.py) CMD ["uvicorn", "app:app", "--host", "::", "--port", "8000"] ``` -------------------------------- ### Entrypoint Script: Initialize and Update Settings Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/miners/run-miners-on-saladcloud.mdx Bash script to initialize settings.json if it doesn't exist and update it with environment variables. It uses 'jq' for JSON manipulation and redacts the mnemonic in output. ```bash #!/bin/bash set -e SETTINGS_FILE="/root/settings.json" # Function to check if settings.json exists settings_exists() { [ -f "$SETTINGS_FILE" ] } # If settings.json doesn't exist, generate it with auto mode if ! settings_exists; then echo "Generating initial settings.json..." # Run the miner to generate settings.json, it will exit after creating it timeout 20 nocturne-miner --auto --no-menu --optimal || true fi # Update settings.json with environment variables if they are set if settings_exists; then echo "Updating settings.json with environment variables..." # Create a temporary file for jq operations TMP_FILE=$(mktemp) # Update donate_to if DONATE_TO is set and not empty if [ -n "$DONATE_TO" ]; then echo "Setting donate_to to: $DONATE_TO" jq --arg donate "$DONATE_TO" '.donate_to = $donate' "$SETTINGS_FILE" > "$TMP_FILE" && mv "$TMP_FILE" "$SETTINGS_FILE" fi # Update worker_name if WORKER_NAME is set and not empty if [ -n "$WORKER_NAME" ]; then echo "Setting worker_name to: $WORKER_NAME" jq --arg worker "$WORKER_NAME" '.worker_name = $worker' "$SETTINGS_FILE" > "$TMP_FILE" && mv "$TMP_FILE" "$SETTINGS_FILE" fi # Update worker_threads if WORKER_THREADS is set and not 0 if [ -n "$WORKER_THREADS" ]; then echo "Setting worker_threads to: $WORKER_THREADS" jq --argjson threads "$WORKER_THREADS" '.worker_threads = $threads' "$SETTINGS_FILE" > "$TMP_FILE" && mv "$TMP_FILE" "$SETTINGS_FILE" fi # Update gen_end_index if GEN_END_INDEX is set and not empty if [ -n "$GEN_END_INDEX" ]; then echo "Setting gen_end_index to: $GEN_END_INDEX" jq --argjson gen_end "$GEN_END_INDEX" '.gen_end_index = $gen_end' "$SETTINGS_FILE" > "$TMP_FILE" && mv "$TMP_FILE" "$SETTINGS_FILE" fi # Update mnemonic if MNEMONIC is set and not empty if [ -n "$MNEMONIC" ]; then echo "Setting mnemonic to: [REDACTED]" jq --arg mnemonic "$MNEMONIC" '.mnemonic = $mnemonic' "$SETTINGS_FILE" > "$TMP_FILE" && mv "$TMP_FILE" "$SETTINGS_FILE" fi # Update miner_id if MINER_ID is set and not empty if [ -n "$MINER_ID" ]; then echo "Setting miner_id to: $MINER_ID" jq --arg miner_id "$MINER_ID" '.miner_id = $miner_id' "$SETTINGS_FILE" > "$TMP_FILE" && mv "$TMP_FILE" "$SETTINGS_FILE" fi echo "Settings.json updated successfully!" echo "Current settings:" # Display settings with mnemonic redacted jq '.mnemonic = "[REDACTED]"' "$SETTINGS_FILE" else echo "Warning: settings.json was not created!" fi ``` -------------------------------- ### SaladCloud Container Group Management Functions Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/how-to-guides/job-processing/sqs.mdx These Python functions interact with the SaladCloud API to get, start, stop, and set replicas for a container group. They require the `send_request` function and necessary environment variables to be defined. ```python def get_container_group(): response = send_request( method="GET", url=f"{salad_base_url}/organizations/{org}/projects/{project}/containers/{container_group_name}", headers={ "Salad-Api-Key": salad_api_key } ) return response["body"] def start_container_group(): send_request( method="POST", url=f"{salad_base_url}/organizations/{org}/projects/{project}/containers/{container_group_name}/start", headers={ "Content-Type": "application/json", "Salad-Api-Key": salad_api_key } ) def stop_container_group(): send_request( method="POST", url=f"{salad_base_url}/organizations/{org}/projects/{project}/containers/{container_group_name}/stop", headers={ "Content-Type": "application/json", "Salad-Api-Key": salad_api_key } ) def set_replicas(replicas: int): send_request( method="PATCH", url=f"{salad_base_url}/organizations/{org}/projects/{project}/containers/{container_group_name}", body=json.dumps({ "replicas": replicas }), headers={ "Content-Type": "application/merge-patch+json", "Salad-Api-Key": salad_api_key } ) ``` -------------------------------- ### Submit a Kelpie Job via CLI Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/reference/recipes/risc0.mdx Use environment variables to configure the submission script for the RISC Zero hello-world demo. ```bash export SALAD_API_KEY=... export SALAD_ORGANIZATION=your-org export SALAD_PROJECT=your-project export CONTAINER_GROUP_ID= export BUCKET_NAME= python recipes/risc0/submit_kelpie_job.py ``` -------------------------------- ### Example Dockerfile for PyTorch on RTX 50-series GPUs Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/machine-learning/pytorch-rtx5090.mdx This Dockerfile uses a PyTorch image with CUDA 12.8 support, suitable for RTX 5090 and 5080 GPUs. It installs project dependencies and sets the default command to run a training script. ```dockerfile FROM pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . CMD ["python", "train.py"] ``` -------------------------------- ### Dockerfile for Node.js Application Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/nodejs/create-a-container.mdx Defines the instructions to build a Docker image for a Node.js application. It specifies the base image, sets the working directory, installs dependencies, copies application code, exposes the application port, and defines the command to start the application. ```dockerfile FROM node:16.18.0 #Create app directory WORKDIR /app #Install the app dependencies using the npm binary. COPY package*.json $. RUN npm install #Copy the rest of the application to the app directory. COPY . /app #Expose the port and start the application. EXPOSE 5000 CMD [ "npm", "start" ] ``` -------------------------------- ### Connect to Your Sandboxed Assistant Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/agentic-tools/use-nemoclaw-with-saladcloud.mdx Use this command to connect to your sandboxed assistant after onboarding is complete. Ensure you replace `` with your actual assistant's name. ```bash nemoclaw connect ``` -------------------------------- ### Start NemoClaw Onboarding Source: https://github.com/saladtechnologies/salad-cloud-docs/blob/main/container-engine/tutorials/agentic-tools/use-nemoclaw-with-saladcloud.mdx Initiate the NemoClaw onboarding wizard to configure your inference endpoint. Follow the prompts to select the endpoint type and enter the necessary details. ```bash nemoclaw onboard ```