module
CrystalMistral::Methods::Embeddings
Direct including types
Defined in:
crystal-mistral/methods/embeddings.crInstance Method Summary
-
#embeddings(model : String, input : Array(String)) : EmbeddingResponse
Sends an embeddings request to the Mistral API.
Instance Method Detail
def embeddings(model : String, input : Array(String)) : EmbeddingResponse
#
Sends an embeddings request to the Mistral API.
Arguments:
- model : String — the model name for embedding (e.g., "mistral-embed")
- input : Array(String) — list of texts to be embedded
Returns:
- EmbeddingResponse — includes vectors for each input
Raises:
- ArgumentError if model is empty
- RuntimeError via
handle_error
if the response indicates an error
Example:
input = [
"Crystal is a fast language.",
"Mistral provides language models.",
]
client = CrystalMistral::Client.new
response = client.embeddings(
model: "mistral-embed",
input: input
)
response.data.each_with_index do |embedding, i|
puts "Embedding for input ##{i}: #{embedding.embedding[0..4]}..."
end