Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Groq Groq python Embedding Input Pattern

From Leeroopedia
Knowledge Sources
Domains NLP, Embeddings
Last Updated 2026-02-15 16:00 GMT

Overview

User-defined pattern for preparing text inputs for the Groq embedding API.

Description

This is a Pattern Doc — there is no library API for this step. Users prepare input text as a str or List[str] using standard Python. The input is passed directly to client.embeddings.create(input=...).

Constraints:

  • Input cannot be an empty string
  • Arrays must be 2048 dimensions or less
  • Total tokens per input limited by model context window

Usage

Construct the input value before calling embeddings.create(). Use a single string for one embedding or a list for batch.

Interface Specification

# Type: Union[str, List[str]]

# Single input
input = "Text to embed"

# Batch input
input = ["First text", "Second text", "Third text"]

I/O Contract

Inputs

Name Type Required Description
text str or List[str] Yes Text to embed; single string or array of strings

Outputs

Name Type Description
(value) Union[str, List[str]] Value ready for embeddings.create(input=...)

Usage Examples

Single Text

# Embed a single text
input_text = "What is machine learning?"
response = client.embeddings.create(
    input=input_text,
    model="nomic-embed-text-v1_5",
)

Batch Texts

# Embed multiple texts at once
documents = [
    "Machine learning is a subset of AI.",
    "Deep learning uses neural networks.",
    "Natural language processing handles text.",
]
response = client.embeddings.create(
    input=documents,
    model="nomic-embed-text-v1_5",
)
# response.data[0].embedding -> first document vector
# response.data[1].embedding -> second document vector

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment