BerriAI/litellm · error · ValueError
Invalid invoke provider
Error message
Invalid invoke provider: {invoke_provider}, for model: {model} What it means
When transforming a streamed passthrough response from an 'invoke' endpoint, AmazonInvokeConfig.get_bedrock_invoke_provider(model) derives the provider from the model id prefix (e.g. 'amazon.', 'anthropic.', 'meta.', 'cohere.', 'mistral.', 'ai21.'). If it returns None there is no event-stream decoder for the model, so LiteLLM raises ValueError. The message interpolates invoke_provider, which is always None here, so the useful part is the model id.
Solutions
- Use the canonical Bedrock model id with its provider prefix, e.g. 'amazon.nova-lite-v1:0' or 'anthropic.claude-3-5-sonnet-...'
- Upgrade litellm so newly added Bedrock providers are recognized in get_bedrock_invoke_provider
- Inspect get_bedrock_invoke_provider's known prefix list to confirm your provider is supported before streaming via invoke passthrough
Example fix
// before # custom alias without provider prefix litellm.router.completion(model="bedrock/my-custom-alias", ...) // after # canonical id with provider prefix litellm.router.completion(model="bedrock/amazon.nova-lite-v1:0", ...)
Defensive patterns
Strategy: validation
Validate before calling
KNOWN_INVOKE_PREFIXES = ("amazon.", "anthropic.", "meta.", "cohere.", "mistral.", "ai21.", "deepseek.", "writer.")
def validate_bedrock_model_id(model: str) -> None:
if not model.startswith(KNOWN_INVOKE_PREFIXES):
raise ValueError(
f"model '{model}' lacks a known Bedrock provider prefix; "
"use the canonical id like 'amazon.nova-lite-v1:0'"
) Type guard
def is_known_bedrock_invoke_model(model: str) -> bool:
"""True when the model id starts with a provider prefix get_bedrock_invoke_provider recognizes."""
return model.startswith(("amazon.", "anthropic.", "meta.", "cohere.", "mistral.", "ai21.")) Try / catch
try:
stream = litellm.completion(model=f"bedrock/{model_id}", messages=msgs, stream=True)
except ValueError as e:
if "Invalid invoke provider" in str(e):
raise ConfigurationError(f"unrecognized Bedrock model id: {model_id}") from e
raise Prevention
- Store canonical Bedrock model ids (with vendor prefix) in configuration, never hand-typed aliases
- Validate model ids against a known-prefix list at config load time
- Cover passthrough streaming paths in integration tests with every model id you ship
When it happens
Trigger: Streaming a Bedrock invoke passthrough request whose model id lacks a recognized provider prefix: custom names like 'my-model', provisioned-throughput aliases, typos, or a provider not registered in get_bedrock_invoke_provider's list.
Common situations: Custom or fine-tuned model ids without the standard '<vendor>.' prefix, copy-paste of inference profile or ARN fragments instead of the model id, older litellm lacking newer providers.
Related errors
- AgentCore: Failed to read/parse JSON response body
- {err.response.text}
- No provider config found for model
- {str(e)}
- Timeout error occurred.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/dd6a327c9d60cbba.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/bedrock/passthrough/transformation.py:200
3. Return the model_response
"""
from litellm.litellm_core_utils.streaming_handler import (
convert_generic_chunk_to_model_response_stream,
generic_chunk_has_all_required_fields,
)
from litellm.llms.bedrock.chat import get_bedrock_event_stream_decoder
from litellm.llms.bedrock.chat.invoke_transformations.base_invoke_transformation import (
AmazonInvokeConfig,
)
from litellm.main import stream_chunk_builder
from litellm.types.utils import GenericStreamingChunk, ModelResponseStream
all_translated_chunks: Final = []
if "invoke" in endpoint:
invoke_provider: Final = AmazonInvokeConfig.get_bedrock_invoke_provider(model)
if invoke_provider is None:
raise ValueError(f"Invalid invoke provider: {invoke_provider}, for model: {model}")
obj = get_bedrock_event_stream_decoder(
invoke_provider=invoke_provider,
model=model,
sync_stream=True,
json_mode=False,
)
elif "converse" in endpoint:
obj = get_bedrock_event_stream_decoder(
invoke_provider=None,
model=model,
sync_stream=True,
json_mode=False,
)
else:
return None
for chunk in all_chunks:
message = json.loads(chunk)View on GitHub (pinned to 77b7c6c40c)