Open History to see the last commit
1---
2id: RerankResult
3title: RerankResult
4---
5
6Defined in: [packages/ai/src/types.ts:1916](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1916)
7
8Public result of the `rerank()` activity, generic over the caller's document
9element type so `document` / `rerankedDocuments` carry the original values
10(strings or objects), not their serialized form.
11
12## Type Parameters
13
14### TDocument
15
16`TDocument` = `string`
17
18## Properties
19
20### id
21
22```ts
23id: string;
24```
25
26Defined in: [packages/ai/src/types.ts:1917](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1917)
27
28***
29
30### model
31
32```ts
33model: string;
34```
35
36Defined in: [packages/ai/src/types.ts:1918](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1918)
37
38***
39
40### ranking
41
42```ts
43ranking: object[];
44```
45
46Defined in: [packages/ai/src/types.ts:1920](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1920)
47
48Scored results, highest relevance first.
49
50#### document
51
52```ts
53document: TDocument;
54```
55
56#### index
57
58```ts
59index: number;
60```
61
62#### score
63
64```ts
65score: number;
66```
67
68***
69
70### rerankedDocuments
71
72```ts
73rerankedDocuments: TDocument[];
74```
75
76Defined in: [packages/ai/src/types.ts:1922](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1922)
77
78The documents reordered by relevance — `ranking.map(r => r.document)`.
79
80***
81
82### usage
83
84```ts
85usage: TokenUsage;
86```
87
88Defined in: [packages/ai/src/types.ts:1930](https://github.com/TanStack/ai/blob/main/packages/ai/src/types.ts#L1930)
89
90Usage for the request. Rerank typically bills in provider-defined "search
91units" (`usage.billed = { quantity, unit: 'units' }`) rather than tokens.
92Some providers (e.g. OpenRouter) may also report `totalTokens` and `cost`.
93Cohere reports only search units and leaves the token counts at 0.
94The deprecated `unitsBilled` field is still populated for compatibility.