mirror of
https://gh-proxy.org/https://github.com/klinsmaya/new-api.git
synced 2026-11-08 01:17:09 +08:00
* feat: add ali MultimodalEmbedding qwen3-vl-embedding * fix: report image/video tokens in qwen3-vl-embedding usage for billing * fix(ali): serve every Bailian multimodal embedding model natively Route qwen2.5-vl-embedding, the tongyi-embedding-vision series and multimodal-embedding-v1, dated snapshots included, to the native multimodal-embedding endpoint like qwen3-vl-embedding. Text embedding models stay in compatible mode. Take tongyi-embedding-vision's text and image tokens from input_tokens_details so the image ratio applies to its image tokens, and set total_tokens to the billed input tokens: tongyi counts its unpriced output_tokens in total_tokens. A response without usage bills the request estimate, as compatible mode does. Return an error code carried in a 200 body as a 500, close the response body when reading it fails, and fold the input conversion into one function. Count the text, image and video parts of embedding input in the request estimate the way chat content is counted, so image calls are pre-charged and a response without usage is not free. With the default settings no image is downloaded for the estimate. * fix(gemini): reject embedding input that is not plain text Gemini embeds text only, so the converter kept the strings and dropped image, video and text parts. The embedding request estimate now counts those parts, and Gemini embeddings bill that estimate, so a dropped part would be charged without ever reaching Gemini. A part now fails the request with a 400 that skips retries, before anything is sent or charged. --------- Co-authored-by: CaIon <[email protected]>