feat(channel): add channel management with custom model pricing#1448
Closed
touwaeriol wants to merge 8 commits intoWei-Shaw:mainfrom
Closed
feat(channel): add channel management with custom model pricing#1448touwaeriol wants to merge 8 commits intoWei-Shaw:mainfrom
touwaeriol wants to merge 8 commits intoWei-Shaw:mainfrom
Conversation
Add a complete channel management system that enables administrators to define custom pricing rules per model, per platform, with multiple billing modes. Backend: - Channel CRUD handler, service, and repository layers - 7 database migrations (channels, pricing, intervals, model mapping) - Three billing modes: token, per-request, and image - Platform-specific pricing configuration - Wildcard model matching and context interval pricing - Model mapping (request model → upstream model) - Billing model source control (requested/upstream/channel-mapped) - Model restriction (limit groups to channel-defined models) - Group isolation (each group belongs to at most one channel) - ImageOutputPricePerToken field in ModelPricing for image billing - Wire dependency injection for ChannelHandler and ChannelRepository Frontend: - Full channel management page (ChannelsView.vue) - Pricing entry card with interval configuration - Model tag input component with paste/batch support - Platform tab layout for per-platform configuration - Sidebar navigation entry and route registration - Complete i18n translations (en + zh) Tests: - Channel service unit tests (2187 lines) - Channel handler unit tests (502 lines) - Channel model unit tests (435 lines) - Channel repository unit tests (227 lines) - Account handler mixed-channel test
lodash/lodash-es template injection vulnerability is not exploitable in our codebase as we never pass user-controlled strings to _.template.
- Fix channel_service.go gofmt alignment to match release - Move channels nav item after groups with hideInSimpleMode: true - Move channels route after groups in router - Move registerChannelRoutes after ScheduledTest in admin routes
…ranch Integrate channel management associated changes from release/custom-0.1.106 that were missing from the initial channel CRUD PR: Backend: - ModelPricingResolver: unified pricing chain (Channel → LiteLLM → Fallback) - CalculateCostUnified: three billing modes (token/per-request/image) - recordUsageCore: merge RecordUsage + RecordUsageWithLongContext - Gateway handlers: channel mapping + restriction at all 6 entry points - Channel model restriction moved to scheduling phase - Usage log: channel_id, model_mapping_chain, billing_tier, billing_mode fields - Credits precheck with fail-open degradation - Sticky session upstream restriction bypass fix - Wire DI: inject ChannelService + ModelPricingResolver into gateway services - DB migrations: 087 (billing_mode), 089 (image_output_tokens) Frontend: - Usage views: billing mode column, three-level mapping chain display - formatters.ts: shared formatCacheTokens/formatMultiplier utilities - Chart components: filters prop passthrough - i18n: billingMode keys (en + zh) Excluded: affinity scheduling, ClaudeMax simulation (to be removed)
Channel-related fixes: - Add BillingMode to UsageLog DTO for frontend display - Add ChannelID/ModelMappingChain/BillingTier to AdminUsageLog DTO - Add billing_type and drill-down filters to dashboard handler/API Independent improvements: - Gemini image output token extraction (CandidatesTokensDetails support) - OpenAI Instructions field for GPT-5/Codex compatibility - Sonnet 4.5 → 4.6 model mapping in constants and frontend presets - Fix user_group_rate_repo JOIN to filter deleted users - Fix concurrency service using detached context to prevent HTTP cancellation - Sidebar channel icon update and i18n fallback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景 / Background
目前系统缺乏对不同用户分组进行差异化定价的能力。管理员无法为不同分组配置独立的模型定价、计费模式或模型访问限制,所有分组共享相同的全局定价策略。
Currently the system lacks the ability to apply differentiated pricing to different user groups. Administrators cannot configure independent model pricing, billing modes, or model access restrictions per group — all groups share the same global pricing strategy.
目的 / Purpose
引入「渠道(Channel)」管理功能,允许管理员创建渠道并关联分组,为每个渠道独立配置模型定价规则、模型映射和访问限制,实现灵活的分组级计费管理。
Introduce a "Channel" management feature that allows administrators to create channels associated with groups, independently configure model pricing rules, model mappings, and access restrictions per channel — enabling flexible group-level billing management.
改动内容 / Changes
后端 / Backend
前端 / Frontend
测试 / Tests