LiteLLM API Error: litellm.BadRequestError: OpenrouterException - {"error":{"message":"Provider returned error","code":400,"metadata":{"raw":"{\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"A maximum of 4 blocks with cache_control may be provided. Found 7.\"},\"request_id\":\"req_011CVuxStX4ojGj47gXdCvJM\"}","provider_name":"Anthropic"}},"user_id":"user_30YqKDHrYOuabrJeyr0BQO3afyE"}
litellm.APIError: Error building chunks for logging/streaming usage calculation
Retrying in 0.2 seconds...
LiteLLM API Error: litellm.BadRequestError: OpenrouterException - {"error":{"message":"Provider returned error","code":400,"metadata":{"raw":"{\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"A maximum of 4 blocks with cache_control may be provided. Found 7.\"},\"request_id\":\"req_vrtx_011CVuxT7aPAEnhZ7Qjjxnpg\"}","provider_name":"Google"}},"user_id":"user_30YqKDHrYOuabrJeyr0BQO3afyE"}
litellm.APIError: Error building chunks for logging/streaming usage calculation
Retrying in 0.5 seconds...
Issue
I've just wanted to try out agent mode:
aider-ce --model openrouter/anthropic/claude-sonnet-4.5 --agentwhat ever i write, it results in:
Version and model info
Aider 0.86.1