easyai-ai-gateway/apps/api/migrations/0009_provider_default_connection.sql

51 lines
2.9 KiB
SQL

ALTER TABLE model_catalog_providers
ADD COLUMN IF NOT EXISTS default_base_url text,
ADD COLUMN IF NOT EXISTS default_auth_type text NOT NULL DEFAULT 'APIKey';
WITH source_defaults(provider_key, default_base_url, default_auth_type) AS (
VALUES
('easyai', 'https://51easyai.com/api/v1', 'APIKey'),
('runninghub', 'https://www.runninghub.ai', 'APIKey'),
('LiblibAI', 'https://openapi.liblibai.cloud', 'AccessKey-SecretKey'),
('keling', 'https://api-beijing.klingai.com/v1', 'AccessKey-SecretKey'),
('gemini', 'https://generativelanguage.googleapis.com/v1beta', 'APIKey'),
('openai', 'https://api.openai.com/v1', 'APIKey'),
('aliyun-bailian-openai', 'https://dashscope.aliyuncs.com/compatible-mode/v1', 'APIKey'),
('gemini-openai', 'https://generativelanguage.googleapis.com/v1beta/openai', 'APIKey'),
('volces-openai', 'https://ark.cn-beijing.volces.com/api/v3', 'APIKey'),
('zhipu-openai', 'https://open.bigmodel.cn/api/paas/v4', 'APIKey'),
('minimax-openai', 'https://api.minimaxi.com/v1', 'APIKey'),
('openrouter-openai', 'https://openrouter.ai/api/v1', 'APIKey'),
('aliyun-bailian', 'https://dashscope.aliyuncs.com/api/v1', 'APIKey'),
('ollama', 'http://<your-local-ip>:11434/v1', 'APIKey'),
('blackforest', 'https://api.bfl.ai/v1', 'APIKey'),
('dify', 'http://localhost/v1', 'APIKey'),
('volces', 'https://ark.cn-beijing.volces.com/api/v3', 'AccessKey-SecretKey'),
('jimeng', '', 'APIKey'),
('silicon-flow-openai', 'https://api.siliconflow.cn/v1', 'APIKey'),
('tripo3d', 'https://api.tripo3d.ai/v2/openapi', 'APIKey'),
('tencent-hunyuan-image', 'https://aiart.tencentcloudapi.com', 'AccessKey-SecretKey'),
('tencent-hunyuan-video', 'https://vclm.tencentcloudapi.com', 'AccessKey-SecretKey'),
('tencent-hunyuan', 'https://ai3d.tencentcloudapi.com', 'AccessKey-SecretKey'),
('suno', 'https://api.cqtai.com/api/cqt', 'APIKey'),
('minimax', 'https://api.minimaxi.com/v1', 'APIKey'),
('midjourney', 'https://api.legnext.ai/api/v1', 'APIKey'),
('tencent-lke', 'https://wss.lke.cloud.tencent.com/v1', 'AccessKey-SecretKey'),
('universal', 'https://example.com/v1/image/edits', 'APIKey'),
('newapi', 'https://api.newapi.com/v1', 'APIKey'),
('vidu', 'https://api.vidu.cn/ent/v2', 'APIKey'),
('n8n', 'http://127.0.0.1:5678', 'APIKey'),
('mock-test', 'http://mock.test', 'APIKey')
)
UPDATE model_catalog_providers p
SET default_base_url = NULLIF(source_defaults.default_base_url, ''),
default_auth_type = source_defaults.default_auth_type,
metadata = p.metadata || jsonb_build_object(
'defaultConnectionSource', 'server-main.integration-platform',
'defaultBaseUrlSynced', NULLIF(source_defaults.default_base_url, ''),
'defaultAuthTypeSynced', source_defaults.default_auth_type
),
updated_at = now()
FROM source_defaults
WHERE p.provider_key = source_defaults.provider_key;