Embeddings OpenRouter

Use OpenRouter to generate text embeddings from multiple providers (OpenAI, Cohere, Google, and more)

Embeddings OpenRouter

AI-generated

Summary

Supplies an OpenRouter-backed LangChain embeddings model (ai_embedding output) to a connected parent node such as a vector store or AI agent, which calls OpenRouter's /embeddings endpoint to turn text into vectors.

Inputs

  • modelName (required) — Embedding model ID, loaded dynamically from OpenRouter's /embeddings/models endpoint (options show context length). Defaults to openai/text-embedding-3-small.
  • options.stripNewLines — Replaces newline characters with spaces in input text before embedding. Default true.
  • options.batchSize — Maximum texts sent per API request when embedding multiple documents; larger inputs are split into sequential batches. Default 100. Lower it if you hit rate limits.

Output shape

No item output. It returns an embeddings object on the ai_embedding connection that exposes embedDocuments (array of texts → array of vectors) and embedQuery (single text → one vector). The parent node invokes these.

Requires an openRouterApi credential (API key sent as a Bearer token). Each call is logged to the n8n execution view as input/output data. API errors (non-2xx status, malformed response, or empty vector for a query) throw an error that includes the status and response text. Results are sorted by the returned index to preserve input order. This node has no main inputs, so it cannot run standalone.

Examples

Example 1: Index documents into a vector store (e.g. Qdrant or Pinecone) using an OpenRouter embedding model

Connect the node to the vector store's Embedding input; select a model such as openai/text-embedding-3-small; keep Strip New Lines on and batch size at 100.

Example 2: Avoid rate limits when embedding a large document set

Add the Batch Size option and set it to a lower value such as 20, so documents are sent in smaller sequential requests.

Links

Discussion