Thanks to visit codestin.com
Credit goes to github.com

Skip to content

LiteLLM with Gemini token issue #734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
handrew opened this issue May 21, 2025 · 1 comment
Closed

LiteLLM with Gemini token issue #734

handrew opened this issue May 21, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@handrew
Copy link
Contributor

handrew commented May 21, 2025

Using Gemini with LiteLLM - I get the following error

  File "/Users/handrew/env/lib/python3.11/site-packages/agents/extensions/models/litellm_model.py", line 111, in get_response
    input_tokens_details=InputTokensDetails(
                         ^^^^^^^^^^^^^^^^^^^
  File "/Users/handrew/env/lib/python3.11/site-packages/pydantic/main.py", line 253, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for InputTokensDetails
cached_tokens
  Input should be a valid integer [type=int_type, input_value=None, input_type=NoneType]

Issue is that getattr will return None if the attribute exists but is literally None. Just have to add "or 0".

I will write a PR.

@handrew handrew added the bug Something isn't working label May 21, 2025
@rm-openai
Copy link
Collaborator

thanks for fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants