### Container Start Command Example Source: https://docs.grafilab.ai/compute/templates/custom An example of a custom start command for a container image, specifically configured to launch Jupyter Lab as root. ```bash bash -c "jupyter lab --ip 0.0.0.0 --port 80 --allow-root" ``` -------------------------------- ### Clone and install from Git Source: https://docs.grafilab.ai/compute/templates/pytorch Download a repository and install its dependencies. ```bash git clone https://github.com//.git cd pip install -r requirements.txt ``` -------------------------------- ### Install and Verify PyTorch Source: https://docs.grafilab.ai/compute/templates/code-server Install project dependencies like PyTorch and verify the installation and CUDA availability. ```bash pip install torch python -c "import torch; print(torch.__version__, torch.cuda.is_available())" ``` -------------------------------- ### Expose JupyterLab service Source: https://docs.grafilab.ai/compute/templates/pytorch Install and start JupyterLab, binding to all interfaces to allow proxy access. ```bash pip install jupyterlab jupyter lab --ip 0.0.0.0 --port 8888 --allow-root ``` -------------------------------- ### Expose an Application Source: https://docs.grafilab.ai/compute/templates/code-server Start an application on a specific port, binding to all interfaces to ensure it is reachable via the proxy. ```bash python -m http.server 8080 --bind 0.0.0.0 ``` -------------------------------- ### Install Python packages Source: https://docs.grafilab.ai/compute/templates/jupyterlab Use this command within a notebook cell to install additional libraries. Restart the kernel after installation to make the packages importable. ```python !pip install transformers accelerate ``` -------------------------------- ### Install OpenAI TypeScript SDK Source: https://docs.grafilab.ai/models/integrations/openai-sdk Install the official OpenAI package for TypeScript. ```bash npm install openai ``` -------------------------------- ### Install OpenAI Python SDK Source: https://docs.grafilab.ai/models/integrations/openai-sdk Install the official OpenAI package for Python. ```bash pip install openai ``` -------------------------------- ### Quick start configuration for Windows (PowerShell) Source: https://docs.grafilab.ai/models/integrations/claude-code Set the required environment variables for the Claude Code CLI on Windows using PowerShell. ```powershell $env:ANTHROPIC_BASE_URL = "https://llm.grafilab.ai" $env:ANTHROPIC_AUTH_TOKEN = "sk-grafilab-..." $env:ANTHROPIC_MODEL = "grafilab/qwen3.6-flash" claude ``` -------------------------------- ### Start Claude Code Session Source: https://docs.grafilab.ai/models/integrations/claude-code Initiate a session and send a prompt to the configured gateway. ```bash claude "say hi" ``` -------------------------------- ### GET /v1/videos Source: https://docs.grafilab.ai/models Lists video generation jobs with cursor pagination. ```APIDOC ## GET /v1/videos ### Description Lists video generation jobs with cursor pagination. ### Method GET ### Endpoint /v1/videos ### Parameters #### Query Parameters - cursor (string) - Optional - Pagination cursor. ### Response #### Success Response (200) - List of video jobs. ``` -------------------------------- ### Quick start configuration for macOS / Linux Source: https://docs.grafilab.ai/models/integrations/claude-code Set the required environment variables for the Claude Code CLI on macOS or Linux. Ensure the base URL is the bare origin without the /v1/messages path. ```bash export ANTHROPIC_BASE_URL="https://llm.grafilab.ai" export ANTHROPIC_AUTH_TOKEN="sk-grafilab-..." export ANTHROPIC_MODEL="grafilab/qwen3.6-flash" claude ``` -------------------------------- ### Create and poll video job in Python Source: https://docs.grafilab.ai/models/integrations/openai-sdk Demonstrates creating a video job, polling its status until completion or failure, and downloading the resulting content. ```python video = client.videos.create(model="", prompt="a paper boat crossing a puddle") while video.status in ("queued", "in_progress"): time.sleep(5) video = client.videos.retrieve(video.id) if video.status == "failed": raise RuntimeError(video.error) content = client.videos.download_content(video.id) content.write_to_file("out.mp4") ``` -------------------------------- ### Verify API Endpoint with cURL Source: https://docs.grafilab.ai/models/integrations/claude-code Test the endpoint before starting the CLI to ensure the gateway is reachable. A successful response body starts with {"id":"msg_. ```bash curl -X POST "$ANTHROPIC_BASE_URL/v1/messages" \ -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \ -H "content-type: application/json" \ -d '{"model": "grafilab/qwen3.6-flash", "max_tokens": 16, "messages": [{"role": "user", "content": "Say hi."}]}' ``` -------------------------------- ### Connect to instance via SSH Source: https://docs.grafilab.ai/compute/instances Use these commands to connect to your instance. The specific command depends on whether you are using the Grafilab proxy or connecting directly to the node's IP address. ```bash ssh @ -p # or ssh @ -p ``` -------------------------------- ### Chat completion JSON response Source: https://docs.grafilab.ai/models/quickstart An example of the JSON structure returned by the chat completion API. ```json { "id": "chatcmpl-...", "object": "chat.completion", "model": "grafilab/qwen3.6-flash", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello, good to meet you today." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 13, "completion_tokens": 8, "total_tokens": 21 } } ``` -------------------------------- ### Download a model with huggingface-cli Source: https://docs.grafilab.ai/compute/templates/comfyui Use this to download a model from Hugging Face into the checkpoints folder. For gated repositories, run huggingface-cli login first and paste a token. ```bash huggingface-cli download \ --local-dir /opt/ComfyUI/models/checkpoints ``` -------------------------------- ### Initialize OpenAI Python client Source: https://docs.grafilab.ai/models/api-keys Configure the OpenAI Python client to use the Grafilab API key and base URL. ```python from openai import OpenAI client = OpenAI( api_key=os.environ["GRAFILAB_API_KEY"], base_url="https://llm.grafilab.ai/v1", ) ``` -------------------------------- ### GET /v1/models Source: https://docs.grafilab.ai/models Retrieves the live model catalogue. Each entry includes Grafilab extensions region and tags. ```APIDOC ## GET /v1/models ### Description Retrieves the live model catalogue. Each entry includes Grafilab extensions region and tags. ### Method GET ### Endpoint /v1/models ### Response #### Success Response (200) - List of model entries with id, region, and tags. ``` -------------------------------- ### GET /v1/videos/{video_id} Source: https://docs.grafilab.ai/models Polls a single video job status. Returns queued, in_progress, completed, or failed. ```APIDOC ## GET /v1/videos/{video_id} ### Description Polls a single video job status. Returns queued, in_progress, completed, or failed. ### Method GET ### Endpoint /v1/videos/{video_id} ### Parameters #### Path Parameters - video_id (string) - Required - The ID of the video job. ### Response #### Success Response (200) - Job status: queued, in_progress, completed, or failed. ``` -------------------------------- ### Verify GPU and Clone Repository Source: https://docs.grafilab.ai/compute/templates/code-server Use the integrated terminal to verify GPU availability with nvidia-smi and clone your project repository. ```bash nvidia-smi git clone https://github.com//.git ``` -------------------------------- ### GET /v1/models/{model} Source: https://docs.grafilab.ai/models Fetches a single model entry. Model IDs containing slashes work unencoded. ```APIDOC ## GET /v1/models/{model} ### Description Fetches a single model entry. Model IDs containing slashes work unencoded. ### Method GET ### Endpoint /v1/models/{model} ### Parameters #### Path Parameters - model (string) - Required - The model ID. ### Response #### Success Response (200) - Model entry with id, region, and tags. ``` -------------------------------- ### Create and poll video job in TypeScript Source: https://docs.grafilab.ai/models/integrations/openai-sdk Demonstrates creating a video job, polling its status until completion or failure, and downloading the resulting content using async/await. ```typescript let video = await client.videos.create({ model: "", prompt: "a paper boat crossing a puddle", }); while (video.status === "queued" || video.status === "in_progress") { await new Promise((r) => setTimeout(r, 5000)); video = await client.videos.retrieve(video.id); } if (video.status === "failed") throw new Error(String(video.error)); const content = await client.videos.downloadContent(video.id); // content is a Response — stream or buffer its body to a file. ``` -------------------------------- ### Send chat completion with Python Source: https://docs.grafilab.ai/models/quickstart Install the OpenAI library and use it to send a chat completion request to the Grafilab API. ```bash pip install openai ``` ```python import os from openai import OpenAI client = OpenAI( api_key=os.environ["GRAFILAB_API_KEY"], base_url="https://llm.grafilab.ai/v1", ) response = client.chat.completions.create( model="grafilab/qwen3.6-flash", messages=[{"role": "user", "content": "Say hello in five words."}], ) print(response.choices[0].message.content) ``` -------------------------------- ### Send chat completion with TypeScript Source: https://docs.grafilab.ai/models/quickstart Install the OpenAI library and use it to send a chat completion request to the Grafilab API. ```bash npm install openai ``` ```ts import OpenAI from "openai"; const client = new OpenAI({ apiKey: process.env.GRAFILAB_API_KEY, baseURL: "https://llm.grafilab.ai/v1", }); const response = await client.chat.completions.create({ model: "grafilab/qwen3.6-flash", messages: [{ role: "user", content: "Say hello in five words." }], }); console.log(response.choices[0].message.content); ``` -------------------------------- ### Download a model with wget over SSH Source: https://docs.grafilab.ai/compute/templates/comfyui Use this to download a model file directly into the checkpoints folder when the Manager does not list it. Run from an SSH session on the instance; the file is placed at /opt/ComfyUI/models/checkpoints/model.safetensors. ```bash cd /opt/ComfyUI/models/checkpoints wget -O model.safetensors "https://example.com/path/to/model.safetensors" ``` -------------------------------- ### GET /v1/videos/{video_id}/content Source: https://docs.grafilab.ai/models Redirects to the finished MP4 video. The redirect target requires no key and the result is kept for seven days after completion. ```APIDOC ## GET /v1/videos/{video_id}/content ### Description Redirects to the finished MP4 video. The redirect target requires no key and the result is kept for seven days after completion. ### Method GET ### Endpoint /v1/videos/{video_id}/content ### Parameters #### Path Parameters - video_id (string) - Required - The ID of the video job. ### Response #### Success Response (302) - Redirect to the MP4 file. ``` -------------------------------- ### Download data from the internet Source: https://docs.grafilab.ai/compute/templates/pytorch Download public datasets directly to the instance for faster transfer speeds. ```bash wget https://example.com/dataset.tar.gz huggingface-cli download --local-dir ./data ``` -------------------------------- ### Configure background and subagent models for macOS / Linux Source: https://docs.grafilab.ai/models/integrations/claude-code Set additional environment variables on macOS or Linux to ensure background tasks and subagents use a compatible Grafilab model. ```bash export ANTHROPIC_DEFAULT_HAIKU_MODEL="grafilab/qwen3.6-flash" export CLAUDE_CODE_SUBAGENT_MODEL="grafilab/qwen3.6-flash" ```