Skip to content

Conversation

@Chesars
Copy link
Contributor

@Chesars Chesars commented Nov 6, 2025

Title

fix: Use valid CallTypes enum value in embeddings endpoint

Relevant issues

Fixes #16240

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Summary

  • Embeddings endpoint failing with 'embeddings' is not a valid CallTypes error when guardrails are enabled.

Changes

  • Changed call_type="embeddings" to call_type="aembedding" in embeddings endpoint (proxy_server.py lines 5084, 5092)
  • Added unit tests to validate the fix

Root Cause

The embeddings endpoint used call_type="embeddings" (invalid) instead of call_type="aembedding" (valid CallTypes enum value).

Bug only appeared with guardrails enabled because guardrails validate the call_type against the CallTypes enum.

Test Plan

  • Added unit tests in tests/proxy_unit_tests/test_embeddings_call_type.py
  • All tests passing

Fixed bug where the `/embeddings` endpoint was passing `call_type="embeddings"`
to guardrail hooks, but "embeddings" is not a valid value in the CallTypes enum.

Changed to use `call_type="aembedding"` (async embedding) which is the correct
CallTypes enum value and matches the route_type used in the same function.

Added unit tests to verify:
- "embeddings" is not a valid CallTypes enum value
- "aembedding" is the correct valid value
- The fix prevents ValueError when guardrails are enabled

Fixes BerriAI#16240
@vercel
Copy link

vercel bot commented Nov 6, 2025

@Chesars is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

@krrishdholakia krrishdholakia merged commit 1632502 into BerriAI:main Nov 7, 2025
3 of 6 checks passed
Chesars added a commit to Chesars/litellm that referenced this pull request Nov 7, 2025
Add "aembedding" to Literal type hints in ProxyLogging methods:
- pre_call_hook overloads (lines 872, 893, 913)
- during_call_hook (line 1052)
- _process_guardrail_callback (line 803)

Add type: ignore comments where ProxyLogging calls CustomLogger
callbacks (lines 1021, 1106) to handle type mismatch between
ProxyLogging's broader Literal (includes "aembedding") and
CustomLogger's narrower Literal (doesn't include "aembedding").

Related to PR BerriAI#16328 which changed embeddings endpoint to use
call_type="aembedding" for async operations.
ishaan-jaff pushed a commit that referenced this pull request Nov 7, 2025
Add "aembedding" to Literal type hints in ProxyLogging methods:
- pre_call_hook overloads (lines 872, 893, 913)
- during_call_hook (line 1052)
- _process_guardrail_callback (line 803)

Add type: ignore comments where ProxyLogging calls CustomLogger
callbacks (lines 1021, 1106) to handle type mismatch between
ProxyLogging's broader Literal (includes "aembedding") and
CustomLogger's narrower Literal (doesn't include "aembedding").

Related to PR #16328 which changed embeddings endpoint to use
call_type="aembedding" for async operations.
yashwantbezawada added a commit to yashwantbezawada/litellm that referenced this pull request Nov 8, 2025
…erriAI#16362)

## Problem
The `call_type` parameter's Literal type hint was duplicated across 36+ files
(CustomLogger subclasses), causing:
1. **DRY violation**: Adding new call types required editing 36+ files
2. **Liskov Substitution Principle violation**: Some subclasses had more restrictive
   types than the base class
3. **Inconsistencies**: Between CallTypes enum and CustomLogger Literals

## Solution
Created centralized TypeAliases in `litellm/types/callbacks.py`:
- `PreCallHookCallType`: For async_pre_call_hook methods
- `ModerationHookCallType`: For async_moderation_hook methods

Updated 36 files to use these TypeAliases instead of duplicating Literal definitions.

## Benefits
- ✅ Single source of truth for call_type values
- ✅ Easier maintenance: new types added in one place
- ✅ Fixes LSP violations: all subclasses accept same types as base
- ✅ Consistent type checking across all CustomLogger implementations
- ✅ Added support for "aembedding" (async embeddings) from PR BerriAI#16328

## Files Changed
- New: `litellm/types/callbacks.py` (TypeAlias definitions)
- Updated: `litellm/integrations/custom_logger.py` (base class)
- Updated: 35 CustomLogger subclass files across:
  - `litellm/proxy/guardrails/guardrail_hooks/`
  - `litellm/proxy/hooks/`
  - `enterprise/`

Fixes BerriAI#16362
Related: BerriAI#16240, BerriAI#16328
yashwantbezawada added a commit to yashwantbezawada/litellm that referenced this pull request Nov 8, 2025
…erriAI#16362)

## Problem
The `call_type` parameter's Literal type hint was duplicated across 36+ files
(CustomLogger subclasses), causing:
1. **DRY violation**: Adding new call types required editing 36+ files
2. **Liskov Substitution Principle violation**: Some subclasses had more restrictive
   types than the base class
3. **Inconsistencies**: Between CallTypes enum and CustomLogger Literals

## Solution
Created centralized TypeAliases in `litellm/types/callbacks.py`:
- `PreCallHookCallType`: For async_pre_call_hook methods
- `ModerationHookCallType`: For async_moderation_hook methods

Updated 36 files to use these TypeAliases instead of duplicating Literal definitions.

## Benefits
- ✅ Single source of truth for call_type values
- ✅ Easier maintenance: new types added in one place
- ✅ Fixes LSP violations: all subclasses accept same types as base
- ✅ Consistent type checking across all CustomLogger implementations
- ✅ Added support for "aembedding" (async embeddings) from PR BerriAI#16328

## Files Changed
- New: `litellm/types/callbacks.py` (TypeAlias definitions)
- Updated: `litellm/integrations/custom_logger.py` (base class)
- Updated: 35 CustomLogger subclass files across:
  - `litellm/proxy/guardrails/guardrail_hooks/`
  - `litellm/proxy/hooks/`
  - `enterprise/`

Fixes BerriAI#16362
Related: BerriAI#16240, BerriAI#16328
yashwantbezawada added a commit to yashwantbezawada/litellm that referenced this pull request Nov 8, 2025
…erriAI#16362)

## Problem
The `call_type` parameter's Literal type hint was duplicated across 36+ files
(CustomLogger subclasses), causing:
1. **DRY violation**: Adding new call types required editing 36+ files
2. **Liskov Substitution Principle violation**: Some subclasses had more restrictive
   types than the base class
3. **Inconsistencies**: Between CallTypes enum and CustomLogger Literals

## Solution
Created centralized TypeAliases in `litellm/types/callbacks.py`:
- `PreCallHookCallType`: For async_pre_call_hook methods
- `ModerationHookCallType`: For async_moderation_hook methods

Updated 36 files to use these TypeAliases instead of duplicating Literal definitions.

## Benefits
- ✅ Single source of truth for call_type values
- ✅ Easier maintenance: new types added in one place
- ✅ Fixes LSP violations: all subclasses accept same types as base
- ✅ Consistent type checking across all CustomLogger implementations
- ✅ Added support for "aembedding" (async embeddings) from PR BerriAI#16328

## Files Changed
- New: `litellm/types/callbacks.py` (TypeAlias definitions)
- Updated: `litellm/integrations/custom_logger.py` (base class)
- Updated: 35 CustomLogger subclass files across:
  - `litellm/proxy/guardrails/guardrail_hooks/`
  - `litellm/proxy/hooks/`
  - `enterprise/`

Fixes BerriAI#16362
Related: BerriAI#16240, BerriAI#16328
LingXuanYin pushed a commit to talesofai/litellm that referenced this pull request Nov 14, 2025
…6328)

* Fix embeddings endpoint call_type to use valid CallTypes enum value

Fixed bug where the `/embeddings` endpoint was passing `call_type="embeddings"`
to guardrail hooks, but "embeddings" is not a valid value in the CallTypes enum.

Changed to use `call_type="aembedding"` (async embedding) which is the correct
CallTypes enum value and matches the route_type used in the same function.

Added unit tests to verify:
- "embeddings" is not a valid CallTypes enum value
- "aembedding" is the correct valid value
- The fix prevents ValueError when guardrails are enabled

Fixes BerriAI#16240

* Inline embeddings call type regression check

* Ensure embedding test preserves proxy metadata
LingXuanYin pushed a commit to talesofai/litellm that referenced this pull request Nov 14, 2025
Add "aembedding" to Literal type hints in ProxyLogging methods:
- pre_call_hook overloads (lines 872, 893, 913)
- during_call_hook (line 1052)
- _process_guardrail_callback (line 803)

Add type: ignore comments where ProxyLogging calls CustomLogger
callbacks (lines 1021, 1106) to handle type mismatch between
ProxyLogging's broader Literal (includes "aembedding") and
CustomLogger's narrower Literal (doesn't include "aembedding").

Related to PR BerriAI#16328 which changed embeddings endpoint to use
call_type="aembedding" for async operations.
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]: Issue calling /embeddings in v1.79.0-stable

2 participants