Skip to content

feat(bedrock): add amazon.titan-embed-g1-text-02 embedding model support - #29891

Open
bhumikadangayach wants to merge 6 commits into
BerriAI:litellm_internal_stagingfrom
bhumikadangayach:litellm_internal_staging
Open

feat(bedrock): add amazon.titan-embed-g1-text-02 embedding model support#29891
bhumikadangayach wants to merge 6 commits into
BerriAI:litellm_internal_stagingfrom
bhumikadangayach:litellm_internal_staging

Conversation

@bhumikadangayach

Copy link
Copy Markdown
Contributor

Problem

amazon.titan-embed-g1-text-02 isn't in LiteLLM's routing table, so any
request to it fails with Unable to map Bedrock request to provider.

Fixes #29786

What I changed

  • Added amazon.titan-embed-g1-text-02 to the provider routing allowlist
  • Wired up request/response transformation using AmazonTitanG1Config
    same format as titan-embed-text-v1 since they share the same inputText schema
  • Added pricing entry to model_prices_and_context_window.json — PR feat(bedrock): add amazon.titan-embed-g1-text-02 embedding model support #29790
    missed this, which meant cost tracking would silently return $0 for every call
  • Added tests for both the embedding response and model info lookup

Testing

Added amazon.titan-embed-g1-text-02 to the existing parametrized
test_bedrock_embedding_models test, and a new
test_bedrock_titan_g1_text_02_model_info to verify the pricing metadata
is correct.

- Add model to provider routing allowlist in embedding.py
- Add request transformation using AmazonTitanG1Config
- Add response transformation using AmazonTitanG1Config
- Add pricing metadata to model_prices_and_context_window.json
- Add unit tests for embedding and model info

Fixes missing cost tracking reported in BerriAI#29786
Related to VANDRANKI/litellm PR BerriAI#29790
@CLAassistant

CLAassistant commented Jun 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@greptile-apps

greptile-apps Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds support for the amazon.titan-embed-g1-text-02 embedding model on Bedrock by wiring it to the existing AmazonTitanG1Config transformer, registering it in the provider allow-list, and adding a pricing entry to model_prices_and_context_window.json.

  • embedding.py: Two new elif branches route amazon.titan-embed-g1-text-02 through AmazonTitanG1Config for both request and response transformation, matching the existing v1 pattern.
  • model_prices_and_context_window.json: New entry correctly sets litellm_provider, mode, input_cost_per_token ($0.0000001/token), and output_vector_size (1536) consistent with the v1 entry.
  • Tests: The parametrized test_bedrock_embedding_models test and a new test_bedrock_titan_g1_text_02_model_info test both use mocks — no real network calls.

Confidence Score: 4/5

Safe to merge; changes are additive and follow the existing Titan embedding pattern throughout.

The implementation mirrors the existing titan-embed-text-v1 setup end-to-end. The only nits are trailing whitespace on the new elif branches and a missing blank line before the new test function.

No files require special attention beyond the minor style issues noted in the comments.

Important Files Changed

Filename Overview
litellm/llms/bedrock/embed/embedding.py Adds amazon.titan-embed-g1-text-02 to the provider allow-list and wires it to AmazonTitanG1Config for both request and response transformation; trailing whitespace on the two new elif branches and a stale error message in the unreachable else branch.
model_prices_and_context_window.json Adds pricing entry for amazon.titan-embed-g1-text-02 with correct litellm_provider, mode, input cost, and vector size (1536), consistent with the existing titan-embed-text-v1 entry.
tests/llm_translation/test_bedrock_embedding.py Extends the parametrized embedding test to cover the new model using the same mock pattern; adds a model-info unit test. The new test function is missing a blank line separator and the file ends without a trailing newline.

Comments Outside Diff (1)

  1. litellm/llms/bedrock/embed/embedding.py, line 472-486 (link)

    P2 Trailing whitespace on both new elif branches. Also the error message in the else block no longer lists amazon.titan-embed-g1-text-02 — while that branch is now unreachable, keeping the list accurate avoids confusion if the block is ever reached via future refactoring.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Reviews (1): Last reviewed commit: "feat(bedrock): add amazon.titan-embed-g1..." | Re-trigger Greptile

Comment on lines +465 to +474
else:
os.environ.pop("AWS_REGION_NAME", None)
def test_bedrock_titan_g1_text_02_model_info():
"""Test that amazon.titan-embed-g1-text-02 has correct pricing metadata"""
model_info = litellm.get_model_info("amazon.titan-embed-g1-text-02")
assert model_info is not None, "Model info should not be None"
assert model_info["litellm_provider"] == "bedrock"
assert model_info["mode"] == "embedding"
assert model_info["input_cost_per_token"] == 1e-07
assert model_info["max_input_tokens"] == 8192 No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing blank line before the new function and no trailing newline at end of file — both are standard Python style (PEP 8) and will cause linter warnings.

Suggested change
else:
os.environ.pop("AWS_REGION_NAME", None)
def test_bedrock_titan_g1_text_02_model_info():
"""Test that amazon.titan-embed-g1-text-02 has correct pricing metadata"""
model_info = litellm.get_model_info("amazon.titan-embed-g1-text-02")
assert model_info is not None, "Model info should not be None"
assert model_info["litellm_provider"] == "bedrock"
assert model_info["mode"] == "embedding"
assert model_info["input_cost_per_token"] == 1e-07
assert model_info["max_input_tokens"] == 8192
else:
os.environ.pop("AWS_REGION_NAME", None)
def test_bedrock_titan_g1_text_02_model_info():
"""Test that amazon.titan-embed-g1-text-02 has correct pricing metadata"""
model_info = litellm.get_model_info("amazon.titan-embed-g1-text-02")
assert model_info is not None, "Model info should not be None"
assert model_info["litellm_provider"] == "bedrock"
assert model_info["mode"] == "embedding"
assert model_info["input_cost_per_token"] == 1e-07
assert model_info["max_input_tokens"] == 8192

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/llms/bedrock/embed/embedding.py 25.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@bhumikadangayach

Copy link
Copy Markdown
Contributor Author

"Hi, all required checks are passing. Happy to make any changes if needed!"

@bhumikadangayach

Copy link
Copy Markdown
Contributor Author

Hi, just following up — this has been open about 3 weeks with no review yet. All required checks are passing aside from a patch-coverage threshold on 3 lines (a defensive branch in the error-message path). Happy to add a test for that if it'd help, or address anything else needed to move this forward. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Bedrock Limited Embedding Model Support

2 participants