1. Async task model redirection (aligned with sync tasks):
- Integrate ModelMappedHelper in RelayTaskSubmit after model name
determination, populating OriginModelName / UpstreamModelName on RelayInfo.
- All task adaptors now send UpstreamModelName to upstream providers:
- Gemini & Vertex: BuildRequestURL uses UpstreamModelName.
- Doubao & Ali: BuildRequestBody conditionally overwrites body.Model.
- Vidu, Kling, Hailuo, Jimeng: convertToRequestPayload accepts RelayInfo
and unconditionally uses info.UpstreamModelName.
- Sora: BuildRequestBody parses JSON and multipart bodies to replace
the "model" field with UpstreamModelName.
- Frontend log visibility: LogTaskConsumption and taskBillingOther now
emit is_model_mapped / upstream_model_name in the "other" JSON field.
- Billing safety: RecalculateTaskQuotaByTokens reads model name from
BillingContext.OriginModelName (via taskModelName) instead of
task.Data["model"], preventing billing leaks from upstream model names.
2. Per-call billing (TaskPricePatches lifecycle):
- Rename TaskBillingContext.ModelName → OriginModelName; add PerCallBilling
bool field, populated from TaskPricePatches at submission time.
- settleTaskBillingOnComplete short-circuits when PerCallBilling is true,
skipping both adaptor adjustments and token-based recalculation.
- Remove ModelName from TaskSubmitResult; use relayInfo.OriginModelName
consistently in controller/relay.go for billing context and logging.
3. Multipart retry boundary mismatch fix:
- Root cause: after Sora (or OpenAI audio) rebuilds a multipart body with a
new boundary and overwrites c.Request.Header["Content-Type"], subsequent
calls to ParseMultipartFormReusable on retry would parse the cached
original body with the wrong boundary, causing "NextPart: EOF".
- Fix: ParseMultipartFormReusable now caches the original Content-Type in
gin context key "_original_multipart_ct" on first call and reuses it for
all subsequent parses, making multipart parsing retry-safe globally.
- Sora adaptor reverted to the standard pattern (direct header set/get),
which is now safe thanks to the root fix.
4. Tests:
- task_billing_test.go: update makeTask to use OriginModelName; add
PerCallBilling settlement tests (skip adaptor adjust, skip token recalc);
add non-per-call adaptor adjustment test with refund verification.
| Name |
Last commit
|
Last Update |
|---|---|---|
| .. | ||
| ai360 | Loading commit data... | |
| ali | Loading commit data... | |
| aws | Loading commit data... | |
| baidu | Loading commit data... | |
| baidu_v2 | Loading commit data... | |
| claude | Loading commit data... | |
| cloudflare | Loading commit data... | |
| codex | Loading commit data... | |
| cohere | Loading commit data... | |
| coze | Loading commit data... | |
| deepseek | Loading commit data... | |
| dify | Loading commit data... | |
| gemini | Loading commit data... | |
| jimeng | Loading commit data... | |
| jina | Loading commit data... | |
| lingyiwanwu | Loading commit data... | |
| minimax | Loading commit data... | |
| mistral | Loading commit data... | |
| mokaai | Loading commit data... | |
| moonshot | Loading commit data... | |
| ollama | Loading commit data... | |
| openai | Loading commit data... | |
| openrouter | Loading commit data... | |
| palm | Loading commit data... | |
| perplexity | Loading commit data... | |
| replicate | Loading commit data... | |
| siliconflow | Loading commit data... | |
| submodel | Loading commit data... | |
| task | Loading commit data... | |
| tencent | Loading commit data... | |
| vertex | Loading commit data... | |
| volcengine | Loading commit data... | |
| xai | Loading commit data... | |
| xinference | Loading commit data... | |
| xunfei | Loading commit data... | |
| zhipu | Loading commit data... | |
| zhipu_4v | Loading commit data... | |
| adapter.go | Loading commit data... | |
| api_request.go | Loading commit data... | |
| api_request_test.go | Loading commit data... |