Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[BUG] embed(array) returns one vector for many texts with Bedrock Titan behind an OpenAI-compatible gateway

Closed Beginner friendly
#1,269 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

@DevKaurav-14 is already working on this.

Since Oct 23, 2026.

  • #1297 by @crmne — merged

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
aws, ruby
Domain
ai

Research direction

Start with lib/ruby_llm/protocols/chat_completions/embeddings.rb, where the response rows are handled. Add validation that the number of returned embeddings matches the number of input texts, raising the appropriate RubyLLM::Error when it does not. Exercise the issue's array-embedding reproduction and verify that a complete response still returns one vector per text.

Written by the indexing model from the issue text.

Description

bug
Basic checks
  • I searched existing issues - this hasn't been reported
  • I can reproduce this consistently
  • This is a RubyLLM bug, not my application code
What's broken?

On OpenAI-compatible endpoints, RubyLLM.embed(array) returns whatever rows the server sends. It never checks that there is one row per input (embeddings.rb:23).

We hit this with Portkey in front of Amazon Titan, which takes one input per request. The gateway returns a single vector for the first text and drops the rest. RubyLLM returns that one vector for the whole array, without an error.

The index check from #1160 does not catch this: one row with index: 0 is valid. Switching to provider: :bedrock, which sends one request per text for Titan, doesn't help either: it only signs requests with SigV4, so it can't use a gateway bearer key.

How to reproduce
require "ruby_llm"

# An OpenAI-compatible gateway (Portkey) routing to Bedrock Titan,
# e.g. GATEWAY_MODEL="@<bedrock-slug>/amazon.titan-embed-text-v2:0"
RubyLLM.configure do |config|
  config.openai_api_key = ENV.fetch("GATEWAY_API_KEY")
  config.openai_api_base = ENV.fetch("GATEWAY_BASE_URL")
end

texts = %w[Ruby Python JavaScript]
embedding = RubyLLM.embed(texts, model: ENV.fetch("GATEWAY_MODEL"), provider: :openai, assume_model_exists: true)

puts "#{texts.size} texts -> #{embedding.vectors.size} vector(s)"
Expected behavior
3 texts -> 3 vector(s)

Or a RubyLLM::Error such as Expected 3 embeddings, got 1

What actually happened
3 texts -> 1 vector(s)

No error is raised. The returned vector is the first text's embedding

Environment
  • RubyLLM version: 2.1.1
  • Provider (OpenAI, Anthropic, etc.): :openai via a Portkey gateway, model amazon.titan-embed-text-v2:0
Dominant language
Ruby
Stars
4.5k
Forks
523
Avg merge
13h 49m
Merged PRs (30d)
221

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from crmne/ruby_llm

All issues in crmne/ruby_llm

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.