Skip to content

Cohere Embeddings

Cohere Embeddings lets you turn plain text into numerical vectors that can be used for searching, clustering, or feeding into other AI models. It talks to Cohere’s online service, so you only need to provide your API key once and then you can embed any amount of text.

How it Works

When you give the component a piece of text, it sends that text to Cohere’s embedding API. Cohere returns a list of numbers (the embedding) that represents the meaning of the text. The component then passes that list back to the rest of your workflow so you can store it, compare it, or use it in other calculations.

Inputs

Mapping Mode

This component has a special mode called Mapping Mode. When you enable this mode using the toggle switch, an additional input called Mapping Data is activated, and each input field offers you three different ways to provide data:

  • Fixed: You type the value directly into the field.
  • Mapped: You connect the output of another component to use its result as the value.
  • Javascript: You write Javascript code to dynamically calculate the value.

This flexibility allows you to create more dynamic and connected workflows.

Input Fields

The following fields are available to configure this component. Each field may be visible in different operations:

  • Mapping Mode: Turn on this switch to enable batch processing of many records at once.
  • Max Retries: How many times the component should try again if the API call fails (default is 3).
  • Model: Choose which Cohere embedding model to use. Options include English, multilingual, and lighter versions.
  • Request Timeout: How long the component should wait for a response from Cohere before giving up (in seconds).
  • Truncate: If your text is longer than the model can handle, this setting tells Cohere how to cut it down.
  • User Agent: A string that identifies your application to Cohere. The default is “langchain”.

Credential
Before you can use the component, you must set up a Cohere API credential in Nappai’s credential section. The credential stores your Cohere API key securely. After creating the credential, select it in the component’s Credential field. Do not enter the API key directly in any input field.

Outputs

  • Embeddings: A list of numbers that represents the input text. You can feed this output into a vector store, a similarity search, or any other component that works with embeddings.

Usage Example

  1. Set up the credential

    • Go to CredentialsAdd Credential → choose Cohere API.
    • Enter your Cohere API key and save.
  2. Add the Cohere Embeddings component

    • Drag it onto the canvas.
    • In the Credential dropdown, pick the credential you just created.
    • Choose a model (e.g., embed-english-v2.0).
    • (Optional) Set Max Retries or Request Timeout if you need more control.
  3. Connect the input

    • If you have a text component, map its output to the Mapping Data field of Cohere Embeddings.
    • If you’re processing a single string, use the Fixed mode and type the text directly.
  4. Use the embeddings

    • Connect the Embeddings output to a vector store or a similarity search component to find related documents.
  • OpenAI Embeddings – Generates embeddings using OpenAI’s models.
  • Text Splitter – Breaks long documents into smaller chunks before embedding.
  • Vector Store – Stores embeddings for fast similarity queries.
  • Similarity Search – Finds the most similar embeddings to a query vector.

Tips and Best Practices

  • Pick the light models (embed-english-light-v2.0) for faster results when you don’t need the highest precision.
  • Use Mapping Mode when you have a list of documents to embed in one run.
  • If you hit rate limits, increase Max Retries or add a short Request Timeout.
  • Keep your API key in the credential store; never hard‑code it in a workflow.

Security Considerations

  • Store your Cohere API key in Nappai’s credential system, not in plain text.
  • Restrict access to the credential so only authorized users can run embeddings.
  • Monitor API usage to detect any unexpected spikes that might indicate misuse.