> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apiyi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# qwen3.7-text-rerank Text Reranking

> Alibaba Cloud Qwen3.7 reranking: 500 documents, 30K tokens per document, 201 languages, and clearly better negation and cross-lingual ranking than bge-reranker-v2-m3. Available on APIYI at /v1/rerank, $0.08 per 1M tokens.

`qwen3.7-text-rerank` is the Qwen3.7 reranking model (a cross-encoder) from Alibaba Cloud Model Studio. It solves the same problem as bge — **vector search pulled the right documents back, but the ones at the top aren't the ones that actually answer the question** — while raising the per-request candidate limit to **500 documents**, the per-document limit to **30K tokens**, and supporting **201 languages**. In our 2026-12-05 testing it also handled **negation**, a known weakness of bge, correctly.

APIYI exposes it on the standard `/v1/rerank` endpoint with the same key as every other model. For a side-by-side selection guide, see the [rerank overview](https://docs.apiyi.com/en/api-capabilities/rerank/overview.md).

> [!NOTE]
>
> **Model name**: `qwen3.7-text-rerank` (case-sensitive). **Endpoint**: `POST /v1/rerank`.
> Available in the Default / SVIP / VVIP / Aliyun / ChinaOpenSource groups.
> **Upstream**: Alibaba Cloud Model Studio (official passthrough).
> Every number on this page comes from APIYI testing on 2026-12-05 (UTC+8), 40+ test cases.

## How it differs from bge-reranker-v2-m3

| | `bge-reranker-v2-m3` | `qwen3.7-text-rerank` |
| - | - | - |
| List price | \$0.01 / 1M tokens | \$0.08 / 1M tokens |
| Per-document limit | 8,192 tokens per pair | 30,000 tokens per document |
| Documents per request | ≤100 recommended | 500 |
| Languages | Chinese, English, Japanese, Korean, Russian, French, Arabic and more | 201 |
| Negation semantics | ❌ Weak (nDCG\@3 0.47) | ✅ Correct in testing |
| Cross-lingual | Ordering correct, scores 1–2 orders of magnitude lower | Ordering correct, scores normal |
| `return_documents` | ❌ Ignored | ✅ Works |
| `documents` type | Strings only | Strings or `{"text": ...}` |
| Upstream quota | TPM 20,000 / RPM 120, \~4–5 concurrent | RPM 3,000 / TPM 9,000,000; 20/20 at 20 concurrent in testing |
| `instruct` | Not supported | Supported upstream, but **not forwarded by the APIYI gateway** today |

**How to choose**: if you have 50–100 candidates, a budget constraint and a simple matching task, `bge-reranker-v2-m3` is enough. If you need long documents, many candidates, multilingual ranking, negation/conditional semantics or higher concurrency, use `qwen3.7-text-rerank`.

## Model information

| Property | Value |
| - | - |
| **Model name** | `qwen3.7-text-rerank` (case-sensitive; a wrong name returns 503) |
| **Architecture** | Cross-encoder (Alibaba Cloud Qwen3.7 series) |
| **Per-document limit** | **30,000 tokens per document** (45K Chinese characters ≈ 29,271 tokens passed; 60K characters returned 400) |
| **Documents per request** | **500** (501 returns 400) |
| **Per-request token budget** | 120,000 (official recommendation) |
| **Languages** | 201 |
| **Endpoint** | `POST /v1/rerank` |
| **Groups** | Default / SVIP / VVIP / Aliyun / ChinaOpenSource |
| **Upstream** | Alibaba Cloud Model Studio (official passthrough) |
| **Billing** | Input tokens only; no output tokens |

## Pricing

| Item | Price |
| - | - |
| Input | \$0.08 / 1M tokens |
| Output | None (this model emits no output tokens) |

The official list price for `qwen3.7-text-rerank` is **¥0.5 / 1M tokens** (Beijing), about **\$0.0714 / 1M** at the fixed 1:7 rate. APIYI lists it at **\$0.08 / 1M**; after recharge bonuses the effective price is about **83–91%** of list, or **\$0.066–0.073 / 1M**, at or below the official price. See [recharge promotions](https://docs.apiyi.com/en/faq/recharge-promotions.md) for the current ratios and stacking rules.

> [!NOTE]
>
> Model prices can change with the official price list. The table above is APIYI's list price; after recharge bonuses the effective price is about 83–91% of list. The **Model Pricing** tab in the top navigation is authoritative: [Model Pricing](https://docs.apiyi.com/en/models/index.md).

**Cost intuition**: 100 candidates (about 3,000 tokens) cost roughly **\$0.00024**. A million such searches cost about **\$240**. Reranking is almost never the cost bottleneck in a RAG system — **latency and candidate quality are**.

**Usage semantics** (measured):

* `prompt_tokens` = the query (counted once) plus every candidate document; `total_tokens` equals it
* `input_tokens` / `output_tokens` are **always 0** on this channel — don't use them
* `top_n` and `return_documents` **do not change usage** — every candidate is scored either way
* Billing follows the upstream `prompt_tokens`: 105 tokens billed 5 quota, 2,030 billed 82, 21,280 billed 852 — `ceil(tokens × 0.04)`

## Minimal call

```bash cURL theme={null}
curl https://api.apiyi.com/v1/rerank \
  -H "Authorization: Bearer $APIYI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.7-text-rerank",
    "query": "What are the must-see attractions in Hangzhou?",
    "documents": [
      "West Lake is Hangzhou's most famous attraction, known for Broken Bridge and Leifeng Pagoda.",
      "The Bund in Shanghai sits along the Huangpu River and is the city's signature landmark.",
      "Lingyin Temple, in Hangzhou's West Lake district, is a well-known Buddhist temple."
    ],
    "top_n": 2,
    "return_documents": true
  }'
```

```python Python theme={null}
import os, requests

resp = requests.post(
    "https://api.apiyi.com/v1/rerank",
    headers={"Authorization": f"Bearer {os.environ['APIYI_API_KEY']}"},
    json={
        "model": "qwen3.7-text-rerank",
        "query": "What are the must-see attractions in Hangzhou?",
        "documents": [
            "West Lake is Hangzhou's most famous attraction, known for Broken Bridge and Leifeng Pagoda.",
            "The Bund in Shanghai sits along the Huangpu River and is the city's signature landmark.",
            "Lingyin Temple, in Hangzhou's West Lake district, is a well-known Buddhist temple.",
        ],
        "top_n": 2,
        "return_documents": True,
    },
    timeout=60,
).json()

for r in resp["results"]:
    print(f"{r['relevance_score']:.4f}  {r['document']['text']}")
```

```javascript Node.js theme={null}
const resp = await fetch('https://api.apiyi.com/v1/rerank', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.APIYI_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'qwen3.7-text-rerank',
    query: 'What are the must-see attractions in Hangzhou?',
    documents: [
      "West Lake is Hangzhou's most famous attraction, known for Broken Bridge and Leifeng Pagoda.",
      "The Bund in Shanghai sits along the Huangpu River and is the city's signature landmark.",
      "Lingyin Temple, in Hangzhou's West Lake district, is a well-known Buddhist temple.",
    ],
    top_n: 2,
    return_documents: true,
  }),
});

const data = await resp.json();
data.results.forEach((r) => console.log(r.relevance_score, r.document.text));
```

Response with `return_documents: true`:

```json theme={null}
{
  "results": [
    {
      "document": { "text": "West Lake is Hangzhou's most famous attraction..." },
      "index": 0,
      "relevance_score": 0.9369803889136425
    },
    {
      "document": { "text": "Lingyin Temple, in Hangzhou's West Lake district..." },
      "index": 2,
      "relevance_score": 0.7132409912219058
    }
  ],
  "usage": {
    "prompt_tokens": 105,
    "total_tokens": 105,
    "input_tokens": 0,
    "output_tokens": 0
  }
}
```

> [!TIP]
>
> **`index` is the field that matters.** It is the document's **original position** in the `documents` array you sent — use it to look up your own document object (ID, URL, metadata), not the returned `text`.
> When `return_documents` is omitted or `false`, the response contains **no** `document`, which keeps response bodies small.

## Request parameters

| Parameter | Type | Required | Notes |
| - | - | - | - |
| `model` | string | ✓ | Always `qwen3.7-text-rerank`, **case-sensitive** |
| `query` | string | ✓ | The search query. An empty string returns 400 `query is required` |
| `documents` | array | ✓ | 1–500 candidates. An array of strings, or `[{"text": "..."}]` objects (other fields return 400). An empty array returns 400 |
| `top_n` | int | | Return top N. Omitted returns everything; `0` is treated as omitted (everything); negative returns 400; a string returns 400. No effect on usage |
| `return_documents` | bool | | Whether to echo the source text. Defaults to `false`; `true` returns `document.text`. **This parameter works on this model** |
| `instruct` | string | | Supported upstream and changes ranking strategy; **currently not forwarded by the APIYI gateway**, so requests behave as the default QA-retrieval instruction (known issue) |

## Measured capability matrix

| Capability | Result |
| - | - |
| Chinese semantic ranking | ✅ Relevant 0.71–0.94, irrelevant 0.001–0.004 — clean separation |
| **Negation understanding** | ✅ **Correct**: two "not suitable in winter" documents ranked below the relevant ones (bge's known weakness) |
| Cross-lingual (ZH → EN) | ✅ Correct ordering; scores 0.57 / 0.42 / 0.06, no longer collapsing to 0.00x |
| Cross-lingual (EN → ZH) | ✅ Correct ordering; scores 0.85 / 0.70 / 0.15 |
| Determinism | ✅ Three repeats of the same request are bit-identical |
| Max documents per request | ✅ 500 passed (\~19K–21K tokens, 3.5–7.7s); 501 returns 400 |
| Max document length | ✅ 45K Chinese characters (≈29,271 tokens) passed; 60K characters returned 400 |
| Concurrency | ✅ 10/10 at 10 concurrent, 20/20 at 20 concurrent; slowest request \~5.9s / 7.1s |
| `return_documents` | ✅ Works; `false` omits `document` |
| `documents` objects | ✅ `{"text": ...}` scores identically to a plain string; other fields return 400 |
| `instruct` | ⚠️ Supported upstream, **not forwarded by the gateway** |
| Billing accuracy | ✅ Uses the upstream `prompt_tokens`, matching the response `usage` |

## How to read the scores

qwen's scores are much cleaner than bge's. For the same five candidates (Hangzhou attractions query):

| Rank | Document | Score |
| - | - | - |
| #1 | West Lake | 0.9370 |
| #2 | West Lake travel guide | 0.8176 |
| #3 | Lingyin Temple | 0.7132 |
| #4 | The Bund (Shanghai) | 0.0042 |
| #5 | Forbidden City (Beijing) | 0.0014 |

There is an order-of-magnitude gap between relevant and irrelevant documents, so a threshold like `0.5` separates this sample cleanly. But scores are still **comparable only within one request**: don't apply a fixed threshold across queries, languages or candidate sets. If you need to filter, use a relative threshold (`score >= top1_score × 0.3`) or take Top-N, and calibrate on your own labelled sample.

Negation comparison (query: "Which attractions are suitable for winter?"):

| Rank | Document | Score | Actually relevant |
| - | - | - | - |
| #1 | Rime Island — a winter must-visit | 0.9017 | ✅ |
| #2 | Harbin Ice Festival — top winter destination | 0.8947 | ✅ |
| #3 | Sanya — popular winter escape | 0.8149 | ✅ |
| #4 | Beidaihe — **not suitable for winter travel** | 0.5225 | ❌ |
| #5 | Qinghai Lake — **not recommended in winter** | 0.4896 | ❌ |

The two negated documents land below all three genuinely relevant ones. bge, in the same test, puts them in the top three with nDCG\@3 0.47. **This is one of the most valuable differences between the two models.**

Cross-lingual scores no longer collapse either:

| Scenario | Correct results | Distractor |
| - | - | - |
| Chinese query → English documents | 0.5713 / 0.4158 | 0.0569 |
| English query → Chinese documents | 0.8545 / 0.7019 | 0.1480 |

## Known issues

> [accordion] 1. instruct is not forwarded today
>
> The upstream model supports `instruct`, and different instructions change the scores (measured: default QA retrieval vs semantic-similarity retrieval vs a custom strong instruction all differ).
> The APIYI gateway **does not forward the field** today: sending `instruct` and omitting it produce bit-identical scores.
>
> **Workaround**: rewrite the query or add guidance on the document side; don't rely on `instruct`. We have reported the gap to the shell-api maintainers and will update this page when it is fixed.

> [accordion] 2. top\_n=0 and negative values behave differently
>
> * Omitted `top_n` → return everything
> * `top_n: 0` → treated as omitted, return everything
> * `top_n: -1` → upstream returns 400 (`parameter top_n should be larger than 0`)
> * `top_n: "2"` → 400 (must be an integer)
>
> bge returns everything for both `0` and negative values. The two models are not identical here — check your migration.

> [accordion] 3. The 60K-character error message does not match the documented limit
>
> A single 60K-character Chinese document returns 400 with `document index:0 is invalid, it should not be larger than 50000`, while the official per-document limit is **30,000 tokens**. The two numbers use different units — don't treat 50,000 as a token budget.
> Chunk by **30K tokens per document**. For Chinese, roughly 1.5 characters per token, so 45K characters is already near the limit.

> [accordion] 4. Object documents only accept text / image / video
>
> `[{"text": "..."}]` scores identically to a string array; `{"foo": "..."}` returns 400
> `No valid input found. Please provide exactly one of: "text", "image", or "video"`.
> This model only reranks text; other fields are meaningless.

## FAQ

> [accordion] qwen3.7-text-rerank or bge-reranker-v2-m3?
>
> Budget first, 50–100 candidates, simple matching → `bge-reranker-v2-m3` (\$0.01/M).
> Long documents, many languages, negation/conditional semantics, 500 candidates or high concurrency → `qwen3.7-text-rerank` (\$0.08/M).
> See the [rerank overview](https://docs.apiyi.com/en/api-capabilities/rerank/overview.md) for the full comparison.

> [accordion] Can I use the Cohere / Jina SDK directly?
>
> The parameter names (`query` / `documents` / `top_n` / `return_documents`) match Cohere Rerank v1,
> but **Cohere SDK v2 defaults to `/v2/rerank`**, which returns the site's HTML homepage instead of JSON — the SDK throws a parse error.
> The simplest approach is a thin HTTP call to `https://api.apiyi.com/v1/rerank`.

> [accordion] Why is there no document in the response when return\_documents=false?
>
> That is the normal behavior for qwen3.7: `return_documents` defaults to `false`, so the response contains only `index` and `relevance_score`; pass `true` to echo `document.text`.
> bge behaves the opposite way — it ignores the parameter and always echoes the source text.

> [accordion] How much concurrency can I use?
>
> The upstream quota is **RPM 3,000 / TPM 9,000,000**. We measured 10/10 at 10 concurrent and 20/20 at 20 concurrent, with the slowest request around 7 seconds.
> That is two orders of magnitude more headroom than bge's TPM 20,000 / 4–5 concurrent, but it is still a shared resource: keep production concurrency around 20–50 and retain exponential backoff.

> [accordion] Is billing accurate, or does the gateway charge its own token estimate?
>
> Billing follows the **upstream `prompt_tokens`**, not a local estimate: 105 tokens billed 5 quota, 2,030 billed 82, 21,280 billed 852 — exactly `ceil(tokens × 0.04)`.
> The `usage.prompt_tokens` in the response is the billing basis, so you can use it for cost accounting.

## Related docs

* [Rerank overview: bge vs qwen3.7](https://docs.apiyi.com/en/api-capabilities/rerank/overview.md)
* [bge-reranker-v2-m3 text reranking](https://docs.apiyi.com/en/api-capabilities/rerank/bge-reranker-v2-m3.md)
* [Rerank API playground](https://docs.apiyi.com/en/api-capabilities/rerank/rerank-api.md)
* [RAG tuning in practice](https://docs.apiyi.com/en/api-capabilities/rerank/rag-best-practices.md)
* [Text embeddings](https://docs.apiyi.com/en/api-capabilities/text-embedding.md)
* [Model pricing](https://docs.apiyi.com/en/models/index.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.