Skip to content

feat: volcengine支持自定义域名 - #1886

Merged
seefs001 merged 5 commits into
QuantumNous:mainfrom
ShibaInu64:feature/volcengine-base-url
Sep 27, 2025
Merged

feat: volcengine支持自定义域名#1886
seefs001 merged 5 commits into
QuantumNous:mainfrom
ShibaInu64:feature/volcengine-base-url

Conversation

@ShibaInu64

@ShibaInu64 ShibaInu64 commented Sep 27, 2025

Copy link
Copy Markdown

例行检查

  • 我已确认目前没有类似 issue
  • 我已确认我已升级到最新版本
  • 我已完整查看过项目 README,已确定现有版本无法满足需求
  • 我理解并愿意跟进此 issue,协助测试和提供反馈
  • 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭

功能描述

volcengine支持自定义域名,如果未设置则使用默认域名https://ark.cn-beijing.volces.com
模型列表:

功能配置

image

测试用例

修改前:不支持自定义API域名

国内站点:
image
国外站点:
image

修改后:支持自定义API域名

国内站点:如果未设置则使用默认域名https://ark.cn-beijing.volces.com
image
国外站点:使用配置的自定义域名,如东南亚节点(新加坡)https://ark.ap-southeast.bytepluses.com
image

接口调试

请求api格式一致,model id不同,国内model id和国外model id基本差异在于国外model id没有前缀doubao-

国内api请求

curl -L -g 'http://{{domain}}/v1/images/generations' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {{token}}' \
-d '{
    "model": "doubao-seedream-4-0-250828",
    "prompt": "星际穿越,黑洞,黑洞里冲出一辆快支离破碎的复古列车,抢视觉冲击力,电影大片,末日既视感,动感,对比色,oc渲染,光线追踪,动态模糊,景深,超现实主义,深蓝,画面通过细腻的丰富的色彩层次塑造主体与场景,质感真实,暗黑风背景的光影效果营造出氛围,整体兼具艺术幻想感,夸张的广角透视效果,耀光,反射,极致的光影,强引力,吞噬",
    "size": "2K",
    "sequential_image_generation": "disabled",
    "stream": false,
    "response_format": "url",
    "watermark": true
}'

返回值

{
    "model": "doubao-seedream-4-0-250828",
    "created": 1758939814,
    "data": [
        {
            "url": "https://ark-content-generation-v2-cn-beijing.tos-cn-beijing.volces.com/doubao-seedream-4-0/xxxxxxxx",
            "size": "3136x1344"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 16464,
        "total_tokens": 16464
    }
}

日志:
image

国外api请求

curl -L -g 'http://{{domain}}/v1/images/generations' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {{token}}' \
-d '{
    "model": "seedream-4-0-250828",
    "prompt": "星际穿越,黑洞,黑洞里冲出一辆快支离破碎的复古列车,抢视觉冲击力,电影大片,末日既视感,动感,对比色,oc渲染,光线追踪,动态模糊,景深,超现实主义,深蓝,画面通过细腻的丰富的色彩层次塑造主体与场景,质感真实,暗黑风背景的光影效果营造出氛围,整体兼具艺术幻想感,夸张的广角透视效果,耀光,反射,极致的光影,强引力,吞噬",
    "size": "2K",
    "sequential_image_generation": "disabled",
    "stream": false,
    "response_format": "url",
    "watermark": true
}'

返回值

{
    "model": "seedream-4-0-250828",
    "created": 1758940150,
    "data": [
        {
            "url": "https://ark-content-generation-v2-ap-southeast-1.tos-ap-southeast-1.volces.com/seedream-4-0/xxxxxxxx",
            "size": "3136x1344"
        }
    ],
    "usage": {
        "generated_images": 1,
        "output_tokens": 16464,
        "total_tokens": 16464
    }
}

日志:
image

Summary by CodeRabbit

  • New Features
    • Permit custom API base URL for Volcengine channels; one Volcengine channel now offers an API address selector with two predefined endpoints and requires a base URL on save.
    • Added new Volcengine models: seedream-4-0-250828, doubao-seedance-1-0-pro-250528, seedance-1-0-pro-250528, doubao-seed-1-6-thinking-250715, seed-1-6-thinking-250715.
    • Edit Channel modal: API Configuration card always visible; base URL input and model selection initialize for the new Volcengine channel type.

@coderabbitai

coderabbitai Bot commented Sep 27, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds configurable Volcengine channel base URL resolution in the relay adaptor, extends the Volcengine model list with five new model IDs, and updates the web EditChannelModal to always show API configuration and handle a default/selectable base URL for channel type 45.

Changes

Cohort / File(s) Summary of changes
Volcengine channel URL handling
relay/channel/volcengine/adaptor.go
Introduced local baseUrl resolved from info.ChannelBaseUrl or default https://ark.cn-beijing.volces.com; replaced usages of info.ChannelBaseUrl with baseUrl; added comment about custom domain behavior and an internal import alias.
Volcengine models constants
relay/channel/volcengine/constants.go
Expanded ModelList to include five additional model identifiers: seedream-4-0-250828, doubao-seedance-1-0-pro-250528, seedance-1-0-pro-250528, doubao-seed-1-6-thinking-250715, seed-1-6-thinking-250715.
Web UI channel modal
web/src/components/table/channels/modals/EditChannelModal.jsx
Always render the API configuration card; for channel type === 45, derive localModels via getChannelModels(value), set/initialize base_url to https://ark.cn-beijing.volces.com, validate base_url on submit, and render a select with predefined API URLs (defaulting to the Beijing URL).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant W as Web UI (EditChannelModal)
  participant B as Backend Relay (Volcengine adaptor)
  participant V as Volcengine API

  U->>W: Open/Edit channel modal
  W-->>U: Show API configuration controls (always)
  U->>W: Select type / choose base_url / Save
  W->>B: Submit channel settings (includes base_url for type 45)

  rect rgb(200,230,255)
    note right of B: Base URL resolution
    B->>B: baseUrl = info.ChannelBaseUrl ? info.ChannelBaseUrl : "https://ark.cn-beijing.volces.com"
    B->>V: Call Volcengine API using baseUrl
    V-->>B: API response
  end

  B-->>W: Persist result/status
  W-->>U: Show confirmation
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I sniffed a URL beneath the sky,
A Beijing default caught my eye.
Five new models joined the run,
The config card greets everyone.
Save the change — now hop, we’re done. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat: volcengine支持自定义域名" accurately and succinctly describes the primary enhancement of enabling custom domain configuration for the Volcengine integration, which aligns with the core changes in both backend URL handling and frontend UI dropdown selection. It is clear, specific, and free of extraneous details or vague terminology.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 923308a and 2e4405e.

📒 Files selected for processing (1)
  • web/src/components/table/channels/modals/EditChannelModal.jsx (4 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the applyModelMapping function transforms the models list by replacing original model names (mapping values) with display names (mapping keys). The database stores this transformed list containing mapped keys. On channel load, data.models contains these mapped display names, making the initialization filter if (data.models.includes(key)) correct.

Applied to files:

  • web/src/components/table/channels/modals/EditChannelModal.jsx
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the database stores mapped keys (display names) in the models field after applying model mapping transformations. When loading a channel, data.models contains the mapped keys, not the original model names. The filtering logic if (data.models.includes(key)) in the initialization is correct.

Applied to files:

  • web/src/components/table/channels/modals/EditChannelModal.jsx
🧬 Code graph analysis (1)
web/src/components/table/channels/modals/EditChannelModal.jsx (3)
web/src/helpers/api.js (1)
  • getChannelModels (279-295)
web/src/helpers/utils.jsx (1)
  • showInfo (161-163)
web/src/components/table/channels/modals/EditTagModal.jsx (2)
  • inputs (73-73)
  • handleInputChange (77-129)
🔇 Additional comments (1)
web/src/components/table/channels/modals/EditChannelModal.jsx (1)

1832-1838: Fix the overseas Volcengine endpoint typo

The “国际站” option still points to https://ark.ap-southeast.bytepluses.com, which is a misspelling and lacks the region segment. The official BytePlus Model Ark endpoint is https://ark.ap-southeast-1.byteplus.com; leaving the typo in place will make every overseas request fail with DNS errors. Please replace both the value and label with the documented host.

-                                {
-                                  value: 'https://ark.ap-southeast.bytepluses.com',
-                                  label: 'https://ark.ap-southeast.bytepluses.com'
-                                }
+                                {
+                                  value: 'https://ark.ap-southeast-1.byteplus.com',
+                                  label: 'https://ark.ap-southeast-1.byteplus.com'
+                                }

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
relay/channel/volcengine/adaptor.go (1)

191-205: Trim trailing separators on custom base URLs

If an admin enters the Volcengine base URL with a trailing slash, we start emitting endpoints like https://foo//api/v3/.... Many servers tolerate this, but some CDNs/reverse proxies don’t, so it’s safer to normalize the value up front. Let’s strip trailing slashes before we append the path segments.

-	baseUrl := info.ChannelBaseUrl
-	if baseUrl == "" {
-		baseUrl = "https://ark.cn-beijing.volces.com"
-	}
+	baseUrl := strings.TrimRight(info.ChannelBaseUrl, "/")
+	if baseUrl == "" {
+		baseUrl = "https://ark.cn-beijing.volces.com"
+	}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d2defa1 and 25a8473.

📒 Files selected for processing (3)
  • relay/channel/volcengine/adaptor.go (1 hunks)
  • relay/channel/volcengine/constants.go (1 hunks)
  • web/src/components/table/channels/modals/EditChannelModal.jsx (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the database stores mapped keys (display names) in the models field after applying model mapping transformations. When loading a channel, data.models contains the mapped keys, not the original model names. The filtering logic if (data.models.includes(key)) in the initialization is correct.

Applied to files:

  • web/src/components/table/channels/modals/EditChannelModal.jsx
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the applyModelMapping function transforms the models list by replacing original model names (mapping values) with display names (mapping keys). The database stores this transformed list containing mapped keys. On channel load, data.models contains these mapped display names, making the initialization filter if (data.models.includes(key)) correct.

Applied to files:

  • web/src/components/table/channels/modals/EditChannelModal.jsx
🧬 Code graph analysis (2)
relay/channel/volcengine/adaptor.go (1)
relay/constant/relay_mode.go (5)
  • RelayModeChatCompletions (10-10)
  • RelayModeEmbeddings (12-12)
  • RelayModeImagesGenerations (14-14)
  • RelayModeImagesEdits (15-15)
  • RelayModeRerank (46-46)
web/src/components/table/channels/modals/EditChannelModal.jsx (1)
web/src/components/table/channels/modals/EditTagModal.jsx (1)
  • inputs (73-73)

Comment thread relay/channel/volcengine/adaptor.go Outdated
@Calcium-Ion

Calcium-Ion commented Sep 27, 2025

Copy link
Copy Markdown
Member

因为防呆设计需要,不允许自定义,建议改为选项选择海外地址还是国内地址

@ShibaInu64

Copy link
Copy Markdown
Author

因为防呆设计需要,不允许自定义,建议改为选项选择海外地址还是国内地址

默认不填写任何地址就是国内地址,如需要切换为海外地址,则根据需要填写

@seefs001

Copy link
Copy Markdown
Collaborator

因为防呆设计需要,不允许自定义,建议改为选项选择海外地址还是国内地址

默认不填写任何地址就是国内地址,如需要切换为海外地址,则根据需要填写

这个意思是不想让直接写地址,防止有些用户写的奇奇怪怪的地址不会用产生一堆问题,毕竟现在也就这俩地址所以是建议弄一个开关切换这两个固定地址

@ShibaInu64
ShibaInu64 requested a review from seefs001 September 27, 2025 07:25
@ShibaInu64

Copy link
Copy Markdown
Author

因为防呆设计需要,不允许自定义,建议改为选项选择海外地址还是国内地址

好的,针对该渠道,那我在前端控件加多一个下拉选择框吧,默认选择国内地址,也可以选择国外地址

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
web/src/components/table/channels/modals/EditChannelModal.jsx (1)

1793-1813: Default the Volcengine base URL when it’s empty

Right now base_url remains an empty string when you create or edit a Volcengine channel that hasn’t explicitly stored a value. Because the field is controlled by the form, the <Form.Select> renders with no option selected even though we pass a defaultValue, so users see an empty dropdown instead of the domestic endpoint you intend to promote as the default. Please hydrate the field with https://ark.cn-beijing.volces.com as soon as type 45 is selected (or loaded) when base_url is falsy; that keeps the UI and the submitted payload aligned and removes the ambiguity.

@@
-    setInputs((inputs) => ({ ...inputs, [name]: value }));
+    setInputs((prev) => {
+      const next = { ...prev, [name]: value };
+      if (name === 'type' && value === 45 && !prev.base_url) {
+        const defaultVolcUrl = 'https://ark.cn-beijing.volces.com';
+        next.base_url = defaultVolcUrl;
+        if (formApiRef.current) {
+          formApiRef.current.setValue('base_url', defaultVolcUrl);
+        }
+      }
+      return next;
+    });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e0c6900 and e4efa34.

📒 Files selected for processing (1)
  • web/src/components/table/channels/modals/EditChannelModal.jsx (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
web/src/components/table/channels/modals/EditChannelModal.jsx (1)
web/src/components/table/channels/modals/EditTagModal.jsx (2)
  • inputs (73-73)
  • handleInputChange (77-129)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4efa34 and 923308a.

📒 Files selected for processing (1)
  • web/src/components/table/channels/modals/EditChannelModal.jsx (4 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the applyModelMapping function transforms the models list by replacing original model names (mapping values) with display names (mapping keys). The database stores this transformed list containing mapped keys. On channel load, data.models contains these mapped display names, making the initialization filter if (data.models.includes(key)) correct.

Applied to files:

  • web/src/components/table/channels/modals/EditChannelModal.jsx
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the database stores mapped keys (display names) in the models field after applying model mapping transformations. When loading a channel, data.models contains the mapped keys, not the original model names. The filtering logic if (data.models.includes(key)) in the initialization is correct.

Applied to files:

  • web/src/components/table/channels/modals/EditChannelModal.jsx
🧬 Code graph analysis (1)
web/src/components/table/channels/modals/EditChannelModal.jsx (3)
web/src/helpers/api.js (1)
  • getChannelModels (278-294)
web/src/helpers/utils.jsx (1)
  • showInfo (157-159)
web/src/components/table/channels/modals/EditTagModal.jsx (2)
  • inputs (73-73)
  • handleInputChange (77-129)

Comment on lines +1811 to +1818
{
value: 'https://ark.cn-beijing.volces.com',
label: 'https://ark.cn-beijing.volces.com'
},
{
value: 'https://ark.ap-southeast.bytepluses.com',
label: 'https://ark.ap-southeast.bytepluses.com'
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Outbound Volcengine domain is misspelled and missing the region suffix

The dropdown hard-codes https://ark.ap-southeast.bytepluses.com, but the official overseas Model Ark endpoint is https://ark.ap-southeast-1.byteplus.com (see the BytePlus international documentation linked in the PR description). With the current value, every “国际站” selection will point at a non-existent host, so all requests will fail.

Update the option to the documented host before shipping.

Based on learnings

🤖 Prompt for AI Agents
In web/src/components/table/channels/modals/EditChannelModal.jsx around lines
1811-1818, the dropdown option for the international Model Ark endpoint is
incorrect; replace the hard-coded 'https://ark.ap-southeast.bytepluses.com'
option (both value and label) with the documented host
'https://ark.ap-southeast-1.byteplus.com' so the "国际站" selection points to the
valid endpoint.

@ShibaInu64

ShibaInu64 commented Sep 27, 2025

Copy link
Copy Markdown
Author

因为防呆设计需要,不允许自定义,建议改为选项选择海外地址还是国内地址

默认不填写任何地址就是国内地址,如需要切换为海外地址,则根据需要填写

这个意思是不想让直接写地址,防止有些用户写的奇奇怪怪的地址不会用产生一堆问题,毕竟现在也就这俩地址所以是建议弄一个开关切换这两个固定地址

代码已经commit并完成测试

1. 创建自动选择国内地址
image

2.不选择API地址提示
image

3.支持选择国内地址或者海外地址
image

4.检查一下数据库的baser url
image

5.测试是否正常:按照上面的测试用例,请求并检查返回值和日志
image

image

system_prompt: '',
});
const showApiConfigCard = inputs.type !== 45; // 控制是否显示 API 配置卡片(仅当渠道类型不是 豆包 时显示)
const showApiConfigCard = true; // 控制是否显示 API 配置卡片

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个渠道不让手动写,只能让选择

@seefs001
seefs001 merged commit 74122e4 into QuantumNous:main Sep 27, 2025
1 check passed
@seefs001

Copy link
Copy Markdown
Collaborator

感谢您的PR

@Calcium-Ion

Copy link
Copy Markdown
Member

对于已存在渠道,没有设置默认值,导致编辑的时候无法保存

@ShibaInu64

ShibaInu64 commented Sep 29, 2025 via email

Copy link
Copy Markdown
Author

@seefs001

Copy link
Copy Markdown
Collaborator

晚点会修复,当前电脑有点问题,我访问不了GitHub 在 2025-09-28 15:34:20,"Calcium-Ion" @.> 写道: Calcium-Ion left a comment (QuantumNous/new-api#1886) 对于已存在渠道,没有设置默认值,导致编辑的时候无法保存 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>

没关系,好好休假,我已经改了

x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
…e-base-url

feat: volcengine支持自定义域名
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants