# cohere_rerank

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: cohere_rerank
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: connect/components/processors/cohere_rerank
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: connect/components/processors/cohere_rerank.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/develop/pages/connect/components/processors/cohere_rerank.adoc
page-git-created-date: "2025-05-19"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/develop/connect/components/processors/cohere_rerank.md -->

**Available in:** Cloud, [Self-Managed](https://docs.redpanda.com/connect/components/processors/cohere_rerank/%20%22View%20the%20Self-Managed%20version%20of%20this%20component%22)

Sends document strings to the [Cohere API](https://docs.cohere.com/reference/rerank), which returns them [ranked by their relevance to a specified query](https://docs.cohere.com/docs/rerank-2).

The output of this processor is an array of strings, ordered by their relevance to the query.

```yml
# Configuration fields, showing default values
label: ""
cohere_rerank:
  base_url: https://api.cohere.com
  api_key: "" # No default (required)
  model: rerank-v3.5 # No default (required)
  query: "" # No default (required)
  documents: "" # No default (required)
  top_n: 0
  max_tokens_per_doc: 4096
```

## [](#metadata)Metadata

-   `relevance_scores`: An array of scores for each input document that indicates how relevant it is to the query. The scores are in the same order as the documents in the input. The higher the score, the more relevant the document.


## [](#examples)Examples

### [](#rerank-some-documents-based-on-a-query)Rerank some documents based on a query

Rerank some documents based on a query

```yaml
input:
  generate:
    interval: 1s
    mapping: |
      root = {
        "query": fake("sentence"),
        "docs": [fake("paragraph"), fake("paragraph"), fake("paragraph")],
      }
pipeline:
  processors:
  - cohere_rerank:
      model: rerank-v3.5
      api_key: "${COHERE_API_KEY}"
      query: "${!this.query}"
      documents: "root = this.docs"
output:
  stdout: {}
```

## [](#fields)Fields

### [](#api_key)`api_key`

Your API key for the Cohere API.

> ⚠️ **CAUTION**
>
> This field contains sensitive information that usually shouldn’t be added to a configuration directly. For more information, see [Manage Secrets](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/secret-management/) before adding it to your configuration.

**Type**: `string`

### [](#base_url)`base_url`

The base URL to use for API requests.

**Type**: `string`

**Default**: `[https://api.cohere.com](https://api.cohere.com)`

### [](#documents)`documents`

A list of text strings that are compared to the specified query. For optimal performance:

-   Send fewer than 1000 documents in a single request

-   Send structured data in YAML format


**Type**: `string`

### [](#max_tokens_per_doc)`max_tokens_per_doc`

This processor automatically truncates long documents to the specified number of tokens.

**Type**: `int`

**Default**: `4096`

### [](#model)`model`

The name of the Cohere LLM you want to use.

**Type**: `string`

```yaml
# Examples:
model: rerank-v3.5
```

### [](#query)`query`

The search query you want to execute. This field supports [interpolation functions](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/interpolation/#bloblang-queries).

**Type**: `string`

### [](#top_n)`top_n`

The number of documents to return when the query is executed. If set to `0`, all documents are returned.

This field supports [interpolation functions](https://docs.redpanda.com/cloud-data-platform/develop/connect/configuration/interpolation/#bloblang-queries).

**Type**: `string`

**Default**: `0`