diff --git a/backend/ent/channelmonitor/channelmonitor.go b/backend/ent/channelmonitor/channelmonitor.go
index 5fa6966c45..552b2ec3a4 100644
--- a/backend/ent/channelmonitor/channelmonitor.go
+++ b/backend/ent/channelmonitor/channelmonitor.go
@@ -184,6 +184,7 @@ const (
ProviderDeepseek Provider = "deepseek"
ProviderMinimax Provider = "minimax"
ProviderOpencodeGo Provider = "opencode_go"
+ ProviderOllamaCloud Provider = "ollama_cloud"
)
func (pr Provider) String() string {
@@ -193,7 +194,7 @@ func (pr Provider) String() string {
// ProviderValidator is a validator for the "provider" field enum values. It is called by the builders before save.
func ProviderValidator(pr Provider) error {
switch pr {
- case ProviderOpenai, ProviderAnthropic, ProviderGemini, ProviderGrok, ProviderAntigravity, ProviderKimi, ProviderZhipu, ProviderDeepseek, ProviderMinimax, ProviderOpencodeGo:
+ case ProviderOpenai, ProviderAnthropic, ProviderGemini, ProviderGrok, ProviderAntigravity, ProviderKimi, ProviderZhipu, ProviderDeepseek, ProviderMinimax, ProviderOpencodeGo, ProviderOllamaCloud:
return nil
default:
return fmt.Errorf("channelmonitor: invalid enum value for provider field: %q", pr)
diff --git a/backend/ent/channelmonitorrequesttemplate/channelmonitorrequesttemplate.go b/backend/ent/channelmonitorrequesttemplate/channelmonitorrequesttemplate.go
index d5ce2cc890..b9528672ff 100644
--- a/backend/ent/channelmonitorrequesttemplate/channelmonitorrequesttemplate.go
+++ b/backend/ent/channelmonitorrequesttemplate/channelmonitorrequesttemplate.go
@@ -110,6 +110,7 @@ const (
ProviderDeepseek Provider = "deepseek"
ProviderMinimax Provider = "minimax"
ProviderOpencodeGo Provider = "opencode_go"
+ ProviderOllamaCloud Provider = "ollama_cloud"
)
func (pr Provider) String() string {
@@ -119,7 +120,7 @@ func (pr Provider) String() string {
// ProviderValidator is a validator for the "provider" field enum values. It is called by the builders before save.
func ProviderValidator(pr Provider) error {
switch pr {
- case ProviderOpenai, ProviderAnthropic, ProviderGemini, ProviderGrok, ProviderAntigravity, ProviderKimi, ProviderZhipu, ProviderDeepseek, ProviderMinimax, ProviderOpencodeGo:
+ case ProviderOpenai, ProviderAnthropic, ProviderGemini, ProviderGrok, ProviderAntigravity, ProviderKimi, ProviderZhipu, ProviderDeepseek, ProviderMinimax, ProviderOpencodeGo, ProviderOllamaCloud:
return nil
default:
return fmt.Errorf("channelmonitorrequesttemplate: invalid enum value for provider field: %q", pr)
diff --git a/backend/ent/migrate/schema.go b/backend/ent/migrate/schema.go
index 17ee59bdca..96c229f578 100644
--- a/backend/ent/migrate/schema.go
+++ b/backend/ent/migrate/schema.go
@@ -623,7 +623,7 @@ var (
{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "name", Type: field.TypeString, Size: 100},
- {Name: "provider", Type: field.TypeEnum, Enums: []string{"openai", "anthropic", "gemini", "grok", "antigravity", "kimi", "zhipu", "deepseek", "minimax", "opencode_go"}},
+ {Name: "provider", Type: field.TypeEnum, Enums: []string{"openai", "anthropic", "gemini", "grok", "antigravity", "kimi", "zhipu", "deepseek", "minimax", "opencode_go", "ollama_cloud"}},
{Name: "check_mode", Type: field.TypeString, Size: 32, Default: "probe"},
{Name: "account_id", Type: field.TypeInt64, Nullable: true},
{Name: "api_mode", Type: field.TypeString, Size: 32, Default: "chat_completions"},
@@ -776,7 +776,7 @@ var (
{Name: "created_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "updated_at", Type: field.TypeTime, SchemaType: map[string]string{"postgres": "timestamptz"}},
{Name: "name", Type: field.TypeString, Size: 100},
- {Name: "provider", Type: field.TypeEnum, Enums: []string{"openai", "anthropic", "gemini", "grok", "antigravity", "kimi", "zhipu", "deepseek", "minimax", "opencode_go"}},
+ {Name: "provider", Type: field.TypeEnum, Enums: []string{"openai", "anthropic", "gemini", "grok", "antigravity", "kimi", "zhipu", "deepseek", "minimax", "opencode_go", "ollama_cloud"}},
{Name: "api_mode", Type: field.TypeString, Size: 32, Default: "chat_completions"},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 500, Default: ""},
{Name: "extra_headers", Type: field.TypeJSON},
diff --git a/backend/ent/schema/channel_monitor.go b/backend/ent/schema/channel_monitor.go
index 0e0330fe5e..ab1203fd77 100644
--- a/backend/ent/schema/channel_monitor.go
+++ b/backend/ent/schema/channel_monitor.go
@@ -36,7 +36,7 @@ func (ChannelMonitor) Fields() []ent.Field {
MaxLen(100),
field.Enum("provider").
Values("openai", "anthropic", "gemini", "grok",
- "antigravity", "kimi", "zhipu", "deepseek", "minimax", "opencode_go"),
+ "antigravity", "kimi", "zhipu", "deepseek", "minimax", "opencode_go", "ollama_cloud"),
// check_mode: 'probe' | 'quota' | 'quota_probe'
// probe - LLM 探活(默认,原有行为)
// quota - 仅查关联账号的用量/余额(零 LLM 成本;endpoint/api_key 可空)
diff --git a/backend/ent/schema/channel_monitor_request_template.go b/backend/ent/schema/channel_monitor_request_template.go
index 3fe78fe3e2..ed2bdea90c 100644
--- a/backend/ent/schema/channel_monitor_request_template.go
+++ b/backend/ent/schema/channel_monitor_request_template.go
@@ -40,7 +40,7 @@ func (ChannelMonitorRequestTemplate) Fields() []ent.Field {
MaxLen(100),
field.Enum("provider").
Values("openai", "anthropic", "gemini", "grok",
- "antigravity", "kimi", "zhipu", "deepseek", "minimax", "opencode_go"),
+ "antigravity", "kimi", "zhipu", "deepseek", "minimax", "opencode_go", "ollama_cloud"),
field.String("api_mode").
Default("chat_completions").
MaxLen(32).
diff --git a/backend/ent/schema/user_platform_quota.go b/backend/ent/schema/user_platform_quota.go
index 663be0a6ec..9744f189d5 100644
--- a/backend/ent/schema/user_platform_quota.go
+++ b/backend/ent/schema/user_platform_quota.go
@@ -42,7 +42,8 @@ func (UserPlatformQuota) Fields() []ent.Field {
// 此处为 ent 构建期约束,需与 service.AllowedQuotaPlatforms 保持同步。
switch s {
case "anthropic", "openai", "gemini", "antigravity", "grok",
- "kimi", "zhipu", "deepseek", "minimax", "opencode_go", "typesafe":
+ "kimi", "zhipu", "deepseek", "minimax", "opencode_go", "typesafe",
+ "ollama_cloud":
return nil
default:
return fmt.Errorf("platform %q is not allowed", s)
diff --git a/backend/internal/domain/constants.go b/backend/internal/domain/constants.go
index 37cb3a738f..56d3ad121b 100644
--- a/backend/internal/domain/constants.go
+++ b/backend/internal/domain/constants.go
@@ -32,7 +32,9 @@ const (
// PlatformOpenCodeGo 是 OpenCode 平台(账号类型 Zen 按量 / Go 订阅)。
// 值保持 opencode_go 以兼容已落库的分组、配额与 Composite 路由 CHECK。
PlatformOpenCodeGo = "opencode_go"
- PlatformComposite = "composite"
+ // PlatformOllamaCloud 是 Ollama Cloud 订阅制聚合上游(多协议 API Key 网关)。
+ PlatformOllamaCloud = "ollama_cloud"
+ PlatformComposite = "composite"
)
// Account mode constants 区分国产供应商的「按量付费(余额)」与「Coding Plan」两种接入方式。
diff --git a/backend/internal/service/domain_constants.go b/backend/internal/service/domain_constants.go
index e29b4639c0..02a6c87490 100644
--- a/backend/internal/service/domain_constants.go
+++ b/backend/internal/service/domain_constants.go
@@ -50,7 +50,9 @@ const (
PlatformMiniMax = domain.PlatformMiniMax
PlatformTypeSafe = domain.PlatformTypeSafe
PlatformOpenCodeGo = domain.PlatformOpenCodeGo
- PlatformComposite = domain.PlatformComposite
+ // PlatformOllamaCloud 是 Ollama Cloud 订阅制聚合上游。
+ PlatformOllamaCloud = domain.PlatformOllamaCloud
+ PlatformComposite = domain.PlatformComposite
// PlatformKiro is retained for unsupported-platform threshold tests and legacy
// account rows. Scheduling-threshold evaluation never pauses kiro accounts.
PlatformKiro = "kiro"
@@ -137,6 +139,7 @@ var AllowedQuotaPlatforms = []string{
PlatformMiniMax,
PlatformOpenCodeGo,
PlatformTypeSafe,
+ PlatformOllamaCloud,
}
// AllowedSchedulingThresholdPlatforms 是允许设置账号自动停调阈值的平台列表。
diff --git a/backend/migrations/239_ollama_cloud_platform.sql b/backend/migrations/239_ollama_cloud_platform.sql
new file mode 100644
index 0000000000..2aada9bd09
--- /dev/null
+++ b/backend/migrations/239_ollama_cloud_platform.sql
@@ -0,0 +1,67 @@
+-- Add Ollama Cloud as a first-class platform.
+--
+-- 1. user_platform_quotas.platform CHECK
+-- 2. composite_model_routes.target_platform CHECK
+-- 3. channel_monitors / channel_monitor_request_templates provider CHECK
+--
+-- Runs after 238_opencode_go_platform.sql. DROP ... IF EXISTS + 幂等守卫保证可重入;
+-- 新约束是 238 的超集,必须同时保留 MiniMax 与 OpenCode Go。
+-- 零 DML 回填:与 157/224/237/238 一致,只放宽约束,不写任何 DML。
+
+ALTER TABLE user_platform_quotas
+ DROP CONSTRAINT IF EXISTS user_platform_quotas_platform_check;
+
+ALTER TABLE user_platform_quotas
+ ADD CONSTRAINT user_platform_quotas_platform_check
+ CHECK (platform IN ('anthropic', 'openai', 'gemini', 'antigravity', 'grok',
+ 'kimi', 'zhipu', 'deepseek', 'minimax', 'opencode_go',
+ 'ollama_cloud'));
+
+ALTER TABLE composite_model_routes
+ DROP CONSTRAINT IF EXISTS composite_model_routes_target_platform_check;
+
+ALTER TABLE composite_model_routes
+ ADD CONSTRAINT composite_model_routes_target_platform_check
+ CHECK (target_platform IN ('anthropic', 'openai', 'gemini', 'antigravity', 'grok',
+ 'kimi', 'zhipu', 'deepseek', 'minimax', 'opencode_go',
+ 'ollama_cloud'));
+
+DO $$
+DECLARE
+ monitor_constraint_def TEXT;
+ template_constraint_def TEXT;
+BEGIN
+ SELECT pg_get_constraintdef(c.oid)
+ INTO monitor_constraint_def
+ FROM pg_constraint c
+ JOIN pg_class t ON t.oid = c.conrelid
+ WHERE t.relname = 'channel_monitors'
+ AND c.conname = 'channel_monitors_provider_check';
+
+ IF monitor_constraint_def IS NULL OR position('ollama_cloud' IN monitor_constraint_def) = 0 THEN
+ ALTER TABLE channel_monitors
+ DROP CONSTRAINT IF EXISTS channel_monitors_provider_check;
+ ALTER TABLE channel_monitors
+ ADD CONSTRAINT channel_monitors_provider_check
+ CHECK (provider IN ('openai', 'anthropic', 'gemini', 'grok',
+ 'antigravity', 'kimi', 'zhipu', 'deepseek', 'minimax', 'opencode_go',
+ 'ollama_cloud'));
+ END IF;
+
+ SELECT pg_get_constraintdef(c.oid)
+ INTO template_constraint_def
+ FROM pg_constraint c
+ JOIN pg_class t ON t.oid = c.conrelid
+ WHERE t.relname = 'channel_monitor_request_templates'
+ AND c.conname = 'channel_monitor_request_templates_provider_check';
+
+ IF template_constraint_def IS NULL OR position('ollama_cloud' IN template_constraint_def) = 0 THEN
+ ALTER TABLE channel_monitor_request_templates
+ DROP CONSTRAINT IF EXISTS channel_monitor_request_templates_provider_check;
+ ALTER TABLE channel_monitor_request_templates
+ ADD CONSTRAINT channel_monitor_request_templates_provider_check
+ CHECK (provider IN ('openai', 'anthropic', 'gemini', 'grok',
+ 'antigravity', 'kimi', 'zhipu', 'deepseek', 'minimax', 'opencode_go',
+ 'ollama_cloud'));
+ END IF;
+END $$;
diff --git a/backend/migrations/ollama_cloud_platform_migration_test.go b/backend/migrations/ollama_cloud_platform_migration_test.go
new file mode 100644
index 0000000000..ab5362f775
--- /dev/null
+++ b/backend/migrations/ollama_cloud_platform_migration_test.go
@@ -0,0 +1,30 @@
+package migrations
+
+import (
+ "strings"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+func TestOllamaCloudPlatformMigration(t *testing.T) {
+ content, err := FS.ReadFile("239_ollama_cloud_platform.sql")
+ require.NoError(t, err)
+
+ sql := strings.Join(strings.Fields(string(content)), " ")
+ require.Contains(t, sql, "user_platform_quotas_platform_check")
+ require.Contains(t, sql, "composite_model_routes_target_platform_check")
+ require.Contains(t, sql, "channel_monitors_provider_check")
+ require.Contains(t, sql, "channel_monitor_request_templates_provider_check")
+ require.Contains(t, sql, "'ollama_cloud'")
+ require.Contains(t, sql, "'minimax'")
+ require.Contains(t, sql, "'opencode_go'")
+ require.Contains(t, sql, "position('ollama_cloud' IN monitor_constraint_def) = 0")
+ require.Contains(t, sql, "position('ollama_cloud' IN template_constraint_def) = 0")
+ require.Contains(t, sql,
+ "CHECK (platform IN ('anthropic', 'openai', 'gemini', 'antigravity', 'grok', 'kimi', 'zhipu', 'deepseek', 'minimax', 'opencode_go', 'ollama_cloud'))")
+ require.Contains(t, sql,
+ "CHECK (target_platform IN ('anthropic', 'openai', 'gemini', 'antigravity', 'grok', 'kimi', 'zhipu', 'deepseek', 'minimax', 'opencode_go', 'ollama_cloud'))")
+ require.Contains(t, sql,
+ "CHECK (provider IN ('openai', 'anthropic', 'gemini', 'grok', 'antigravity', 'kimi', 'zhipu', 'deepseek', 'minimax', 'opencode_go', 'ollama_cloud'))")
+}
diff --git a/frontend/src/components/common/PlatformIcon.vue b/frontend/src/components/common/PlatformIcon.vue
index df1ec46db3..a17c72e337 100644
--- a/frontend/src/components/common/PlatformIcon.vue
+++ b/frontend/src/components/common/PlatformIcon.vue
@@ -48,6 +48,12 @@
+
+