Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(anthropic.py): fix linting error

Krrish Dholakia0ce6c038eed5
diff --git a/litellm/llms/anthropic.py b/litellm/llms/anthropic.py
index e3bc595dd4e..ab47c95372c 100644
--- a/litellm/llms/anthropic.py
+++ b/litellm/llms/anthropic.py
@@ -464,7 +464,8 @@ class AnthropicConfig:
# extract usage
usage: litellm.Usage = getattr(response, "usage")
anthropic_usage = AnthropicResponseUsageBlock(
- input_tokens=usage.prompt_tokens, output_tokens=usage.completion_tokens
+ input_tokens=usage.prompt_tokens or 0,
+ output_tokens=usage.completion_tokens or 0,
)
translated_obj = AnthropicResponse(
id=response.id,