Ollama 官方中文文档
  1. 创建模型
Ollama 官方中文文档
  • 接口 Endpoints
  • 规范 Conventions
  • 生成补全
    • 概括
    • 流式生成请求(Streaming)
      POST
    • 非流式生成请求(No Streaming)
      POST
    • 带后缀的生成请求(with Suffix)
      POST
    • 结构化输出请求(Structured Outputs)
      POST
    • JSON 模式请求(JSON Mode)
      POST
    • 带图像的生成请求(with Images)
      POST
    • 原始模式请求(Raw Mode)
      POST
    • 可复现输出请求(Reproducible Outputs)
      POST
    • 参数化生成请求(with Options)
      POST
    • 加载模型
      POST
    • 卸载模型
      POST
  • 生成对话补全
    • 概括
    • 流式对话请求(Streaming)
      POST
    • 非流式对话请求(No Streaming)
      POST
    • 结构化输出对话请求(Structured Outputs)
      POST
    • 带历史上下文的对话请求(With History)
      POST
    • 带图像的对话请求(with Images)
      POST
    • 可复现输出的对话请求(Reproducible Outputs)
      POST
    • 支持工具调用的对话请求(with Tools)
      POST
    • 加载模型
      POST
    • 卸载模型
      POST
  • 创建模型
    • 概括
    • 创建新模型
      POST
    • 量化模型
      POST
    • 从 GGUF 文件创建模型
      POST
    • 从 Safetensors 目录创建模型
      POST
  • 检查 Blob 是否存在
    • 概括
  • 推送 Blob
    • 概括
  • 列出本地模型
    • 概括
    • 示例
  • 显示模型详情
    • 概括
    • 示例
  • 复制模型
    • 概括
    • 示例
  • 删除模型
    • 概括
    • 示例
  • 拉取模型
    • 概括
    • 示例
  • 推送模型
    • 概括
  • 生成嵌入向量
    • 概括
    • 示例
    • 多输入请求(Multiple Input)
  • 列出运行中模型
    • 概括
    • 示例
  • 生成单个嵌入向量
    • 概括
    • 示例
  • 版本信息
    • 概括
  1. 创建模型

从 Safetensors 目录创建模型

POST
http://localhost:11434/api/create
The files parameter should include a dictionary of files for the safetensors model which includes the file names and SHA256 digest of each file. Use /api/blobs/:digest to first push each of the files to the server before calling this API. Files will remain in the cache until the Ollama server is restarted.
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'http://localhost:11434/api/create' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "bert-base-chinese",
    "files": {
        "config.json": "a1b2c3d4e5f6",
        "generation_config.json": "b2c3d4e5f6g7",
        "special_tokens_map.json": "c3d4e5f6g7h8",
        "tokenizer.json": "d4e5f6g7h8i9",
        "tokenizer_config.json": "e5f6g7h8i9j0",
        "model.safetensors": "f6g7h8i9j0k1"
    }
}'
响应示例响应示例
{"status":"converting model"}
{"status":"creating new layer sha256:05ca5b813af4a53d2c2922933936e398958855c44ee534858fcfd830940618b6"}
{"status":"using autodetected template llama3-instruct"}
{"status":"using existing layer sha256:56bb8bd477a519ffa694fc449c2413c6f0e1d3b1c88fa7e3c9d88d3ae49d4dcb"}
{"status":"writing manifest"}
{"status":"success"}

请求参数

Body 参数application/json
model
string 
模型名称
必需
示例值:
bert-base-chinese
files
object 
必需
config.json
string 
配置文件哈希值
必需
示例值:
a1b2c3d4e5f6
generation_config.json
string 
生成配置文件哈希值
必需
示例值:
b2c3d4e5f6g7
special_tokens_map.json
string 
必需
特殊token映射文件哈希值
示例值:
c3d4e5f6g7h8
tokenizer.json
string 
分词器文件哈希值
必需
示例值:
d4e5f6g7h8i9
tokenizer_config.json
string 
必需
分词器配置文件哈希值
示例值:
e5f6g7h8i9j0
model.safetensors
string 
模型权重文件哈希值
必需
示例值:
f6g7h8i9j0k1
示例

返回响应

🟢200Success
application/json
A stream of JSON objects is returned:
Body
status
string 
必需
修改于 2025-03-27 09:22:30
上一页
从 GGUF 文件创建模型
下一页
概括
Built with