Skip to content

[BUG] LiteLLM integration with Strands Agent #610

@shanicusyee

Description

@shanicusyee

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

1.3.0

Python Version

3.13

Operating System

macos 15.5

Installation Method

pip

Steps to Reproduce

from strands import Agent
from strands.models.litellm import LiteLLMModel

litellm_model = LiteLLMModel(
client_args={
"api_key": "sk-******",
},
# **model_config
model_id="gemini/gemini-1.5-flash",
params={
"max_tokens": 1000,
"temperature": 0.7,
}
)

Create an agent with the model via LiteLLM

agent = Agent(model=litellm_model)

response = agent(
"You're advising a startup with $10M funding, entering the AI productivity tools space. Given current trends, outline a go-to-market plan, suggest a pricing model, and identify key technical differentiators needed to compete with Notion AI and Microsoft Copilot."
)

Expected Behavior

Gemini to reply the request.

Actual Behavior

litellm.exceptions.AuthenticationError: litellm.AuthenticationError: vertex_ai_betaException - b'{\n "error": {\n "code": 400,\n "message": "API key not valid. Please pass a valid API key.",\n "status": "INVALID_ARGUMENT",\n "details": [\n {\n "@type": "type.googleapis.com/google.rpc.ErrorInfo",\n "reason": "API_KEY_INVALID",\n "domain": "googleapis.com",\n "metadata": {\n "service": "generativelanguage.googleapis.com"\n }\n },\n {\n "@type": "type.googleapis.com/google.rpc.LocalizedMessage",\n "locale": "en-US",\n "message": "API key not valid. Please pass a valid API key."\n }\n ]\n }\n}\n'

Additional Context

i have tested using litellm without strands agent and it works

Possible Solution

No response

Related Issues

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions