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 |
|---|---|---|
| .. | ||
| openaicompat | Loading commit data... | |
| passkey | Loading commit data... | |
| audio.go | Loading commit data... | |
| billing.go | Loading commit data... | |
| billing_session.go | Loading commit data... | |
| channel.go | Loading commit data... | |
| channel_affinity.go | Loading commit data... | |
| channel_select.go | Loading commit data... | |
| codex_credential_refresh.go | Loading commit data... | |
| codex_credential_refresh_task.go | Loading commit data... | |
| codex_oauth.go | Loading commit data... | |
| codex_wham_usage.go | Loading commit data... | |
| convert.go | Loading commit data... | |
| download.go | Loading commit data... | |
| epay.go | Loading commit data... | |
| error.go | Loading commit data... | |
| error_test.go | Loading commit data... | |
| file_decoder.go | Loading commit data... | |
| file_service.go | Loading commit data... | |
| funding_source.go | Loading commit data... | |
| group.go | Loading commit data... | |
| http.go | Loading commit data... | |
| http_client.go | Loading commit data... | |
| image.go | Loading commit data... | |
| log_info_generate.go | Loading commit data... | |
| midjourney.go | Loading commit data... | |
| notify-limit.go | Loading commit data... | |
| openai_chat_responses_compat.go | Loading commit data... | |
| openai_chat_responses_mode.go | Loading commit data... | |
| quota.go | Loading commit data... | |
| sensitive.go | Loading commit data... | |
| str.go | Loading commit data... | |
| subscription_reset_task.go | Loading commit data... | |
| task.go | Loading commit data... | |
| task_billing.go | Loading commit data... | |
| task_billing_test.go | Loading commit data... | |
| task_polling.go | Loading commit data... | |
| token_counter.go | Loading commit data... | |
| token_estimator.go | Loading commit data... | |
| tokenizer.go | Loading commit data... | |
| usage_helpr.go | Loading commit data... | |
| user_notify.go | Loading commit data... | |
| violation_fee.go | Loading commit data... | |
| webhook.go | Loading commit data... |