Skip to content

云端模型

Ollama 的云端模型是 Ollama 中的一种新型模型,可以在没有强大 GPU 的情况下运行。相反,云端模型会自动托管到 Ollama 的云服务中,同时提供与本地模型相同的功能,从而使您能够在运行无法在个人电脑上运行的大模型时,继续使用您的本地工具。

支持的模型

要查看支持的模型列表,请参阅 Ollama 的 模型库

运行云端模型

Ollama 的云端模型需要 ollama.com 账号。要登录或创建账号,请运行:

ollama signin

CLI

要运行云端模型,打开终端并运行:

ollama run gpt-oss:120b-cloud

Python

首先,拉取一个云端模型以供访问:

ollama pull gpt-oss:120b-cloud

接下来,安装 Ollama 的 Python 库

pip install ollama

然后,创建并运行一个简单的 Python 脚本:

python
from ollama import Client

client = Client()

messages = [
  {
    'role': 'user',
    'content': 'Why is the sky blue?',
  },
]

for part in client.chat('gpt-oss:120b-cloud', messages=messages, stream=True):
  print(part['message']['content'], end='', flush=True)

JavaScript

首先,拉取一个云端模型以供访问:

ollama pull gpt-oss:120b-cloud

接下来,安装 Ollama 的 JavaScript 库

npm i ollama

然后使用该库运行云端模型:

typescript
const ollama = new Ollama();

const response = await ollama.chat({
  model: "gpt-oss:120b-cloud",
  messages: [{ role: "user", content: "Explain quantum computing" }],
  stream: true,
});

for await (const part of response) {
  process.stdout.write(part.message.content);
}

cURL

首先,拉取一个云端模型以供访问:

ollama pull gpt-oss:120b-cloud

运行以下 cURL 命令通过 Ollama 的 API 运行命令:

curl http://localhost:11434/api/chat -d '{
  "model": "gpt-oss:120b-cloud",
  "messages": [{
    "role": "user",
    "content": "Why is the sky blue?"
  }],
  "stream": false
}'

云端 API 访问

也可以直接通过 ollama.com 的 API 访问云端模型。在此模式下,ollama.com 作为远程 Ollama 主机。

身份验证

要直接访问 ollama.com 的 API,首先创建 API 密钥

然后,将 OLLAMA_API_KEY 环境变量设置为您的 API 密钥。

export OLLAMA_API_KEY=your_api_key

列出模型

对于可通过 Ollama API 直接获取的模型,可以通过以下命令列出:

curl https://ollama.com/api/tags

生成响应

Python

首先,安装 Ollama 的 Python 库

pip install ollama

然后发起请求

python

from ollama import Client

client = Client(
    host="https://ollama.com",
    headers={'Authorization': 'Bearer ' + os.environ.get('OLLAMA_API_KEY')}
)

messages = [
  {
    'role': 'user',
    'content': 'Why is the sky blue?',
  },
]

for part in client.chat('gpt-oss:120b', messages=messages, stream=True):
  print(part['message']['content'], end='', flush=True)

JavaScript

首先,安装 Ollama 的 JavaScript 库

npm i ollama

接下来,向模型发起请求:

typescript

const ollama = new Ollama({
  host: "https://ollama.com",
  headers: {
    Authorization: "Bearer " + process.env.OLLAMA_API_KEY,
  },
});

const response = await ollama.chat({
  model: "gpt-oss:120b",
  messages: [{ role: "user", content: "Explain quantum computing" }],
  stream: true,
});

for await (const part of response) {
  process.stdout.write(part.message.content);
}

cURL

通过 Ollama 的聊天 API 生成响应:

curl https://ollama.com/api/chat \
  -H "Authorization: Bearer $OLLAMA_API_KEY" \
  -d '{
    "model": "gpt-oss:120b",
    "messages": [{
      "role": "user",
      "content": "Why is the sky blue?"
    }],
    "stream": false
  }'

仅限本地

通过 禁用 Ollama 的云端功能,Ollama 可以以仅限本地模式运行。

停用

随着更新且更好的开源模型的发布,Ollama 将偶尔弃用并停用旧的云端模型。依赖于 Ollama 云端模型的工具和应用程序可能需要更新以保持正常工作。受影响的用户将在模型弃用和停用前收到通知。弃用通知将通过电子邮件和 Ollama 网站进行传达。

Ollama 云端模型的停用不会影响本地模型。

即将停用的模型

停用日期模型推荐替代方案
July 15, 2026deepseek-v3.1:671bdeepseek-v4-flash
July 15, 2026deepseek-v3.2deepseek-v4-flash
July 15, 2026devstral-2:123bmistral-large-3:675b
July 15, 2026devstral-small-2:24b
July 15, 2026ministral-3:14b
July 15, 2026ministral-3:3b
July 15, 2026ministral-3:8b
July 15, 2026gemini-3-flash-previewminimax-m3
July 15, 2026gemma3:12bgemma4:31b
July 15, 2026gemma3:27bgemma4:31b
July 15, 2026gemma3:4bgemma4:31b
July 15, 2026glm-4.7glm-5.2
July 15, 2026glm-5glm-5.2
July 15, 2026minimax-m2.1minimax-m3
July 15, 2026qwen3-coder-nextqwen3.5:397b
July 15, 2026qwen3-coder:480bqwen3.5:397b

已停用的模型