Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Ollama Ollama XCreate Client

From Leeroopedia
Revision as of 13:28, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Ollama_Ollama_XCreate_Client.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Model Creation, Safetensors
Last Updated 2025-02-15 00:00 GMT

Overview

Provides client-side model creation for importing safetensors-based models (both LLM and image generation) directly to disk, bypassing the HTTP API.

Description

CreateModel detects whether a directory contains a safetensors LLM model (config.json + .safetensors) or image generation model (model_index.json), then delegates to the appropriate creation function. Creates blob layers on disk via manifest.NewLayer, supports optional quantization (int4, int8, nvfp4, mxfp8) through callback-based architecture to avoid import cycles. Writes manifests with model capabilities, parser/renderer names, and Modelfile configurations (template, system prompt, license).

Usage

Called by ollama create when importing models from local directories in the experimental safetensors format.

Code Reference

Source Location

  • Repository: Ollama
  • File: x/create/client/create.go
  • Lines: 1-480

Signature

type ModelfileConfig struct {
    Template string
    System   string
    License  string
}

type CreateOptions struct {
    ModelName string
    ModelDir  string
    Quantize  string
    Modelfile *ModelfileConfig
}

func CreateModel(opts CreateOptions, p *progress.Progress) error

Import

import "github.com/ollama/ollama/x/create/client"

I/O Contract

Inputs

Name Type Required Description
opts CreateOptions Yes Model name, directory path, quantization type, and Modelfile config
p *progress.Progress Yes Progress reporter for UI feedback

Outputs

Name Type Description
error error Non-nil if model creation fails

Usage Examples

p := progress.NewProgress(os.Stderr)
err := client.CreateModel(client.CreateOptions{
    ModelName: "my-model:latest",
    ModelDir:  "/path/to/model",
    Quantize:  "int4",
    Modelfile: &client.ModelfileConfig{
        Template: "chatml",
        System:   "You are a helpful assistant.",
    },
}, p)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment