litellm/tests/test_litellm/llms
Tim Elfrink c5eb22381d fix(bedrock): include cacheWriteInputTokens in prompt_tokens calculation
Fixes #15263

This PR fixes the cost calculation for Bedrock Anthropic models with prompt caching.

**Root Cause:**
PR #9838 incorrectly removed adding `cacheWriteInputTokens` to `prompt_tokens`
for Bedrock, based on the assumption that it would cause double counting (similar
to an Anthropic API issue). However, Bedrock's token structure is different:

- **Bedrock API**: `inputTokens`, `cacheReadInputTokens`, and `cacheWriteInputTokens`
  are ALL separate values that should be summed for total input tokens
- **Anthropic API**: Same structure - all three token types are separate

The fix in #9838 was later reverted for Anthropic (correctly re-adding
`cache_creation_input_tokens` to `prompt_tokens`), but Bedrock was never fixed.

**Changes:**
1. Re-add `cacheWriteInputTokens` to `input_tokens` in Bedrock transformation
2. Update test assertions to reflect correct behavior
3. Add regression test for prompt caching cost calculation
4. Fix typo in Anthropic transformation where `cache_creation_tokens` was
   incorrectly set to `cache_read_input_tokens`

**Testing:**
- All existing Bedrock transformation tests pass
- New test validates correct cost calculation with prompt caching
- Verified costs are non-negative and accurate
2025-10-07 20:28:46 +02:00
..
anthropic Fix Anthropic streaming IDs 2025-09-26 18:31:10 -04:00
azure Add support for GPT 5 codex models (#14841) 2025-09-30 18:44:35 -07:00
azure_ai Removed stop param from unsupported azure models (#15229) 2025-10-06 19:56:18 -07:00
baseten/chat add testing and remove redundant function 2025-08-21 11:25:26 -07:00
bedrock fix(bedrock): include cacheWriteInputTokens in prompt_tokens calculation 2025-10-07 20:28:46 +02:00
bytez/chat Integration: Bytez as a model provider (#12121) 2025-07-12 10:50:39 -07:00
chat Litellm fix GitHub action testing (#11163) 2025-05-26 14:41:42 -07:00
cohere/chat Litellm fix GitHub action testing (#11163) 2025-05-26 14:41:42 -07:00
cometapi/chat feat: add CometAPI provider support with chat completions and streaming (#13458) 2025-08-11 18:06:37 -07:00
compactifai Fix CompactifAI provider tests and implementation 2025-09-15 22:03:42 +02:00
custom_httpx Update var name for consistency 2025-09-23 10:28:40 -07:00
dashscope [Fixes] Using Qwen API Tiered Pricing (#14479) 2025-09-11 20:07:41 -07:00
databricks Merge branch 'main' into feature/databricks-function-call-missing-pass-description 2025-09-09 22:42:32 -07:00
datarobot Updated URL handling for DataRobot provider base 2025-08-21 19:42:46 -06:00
deepgram [Feat] Add Eleven Labs - Speech To Text Support on LiteLLM (#12119) 2025-06-27 17:50:49 -07:00
deepinfra fix deepinfra test 2025-09-10 19:39:23 -07:00
featherless_ai/chat test: fixes 2025-05-31 12:42:56 -07:00
fireworks_ai/chat Litellm fix GitHub action testing (#11163) 2025-05-26 14:41:42 -07:00
gemini Fix gemini cli error (#14417) 2025-09-12 11:56:51 -07:00
github_copilot Merge branch 'main' into feat/github-copilot-thinking-reasoning-support 2025-08-27 22:09:15 -07:00
heroku adds tool calling test 2025-08-06 14:23:55 -06:00
hosted_vllm fix: fix vllm test 2025-09-27 10:01:48 -07:00
huggingface refactor: cleanup huggingface rerank transformation 2025-06-06 10:30:44 -07:00
jina_ai/embedding feat(JinaAI): support multimodal embedding models (#13181) 2025-08-05 19:21:56 -07:00
lemonade Adding unit tests and documentation 2025-09-30 12:12:24 -06:00
litellm_proxy/chat LiteLLM SDK <-> Proxy: support user param + Prisma - remove use_prisma_migrate flag - redundant as this is now default (#13555) 2025-08-12 22:03:39 -07:00
llamafile/chat test llamafile 2025-07-03 22:35:22 -07:00
lm_studio fix(lm_studio): resolve illegal Bearer header value issue 2025-09-12 22:41:30 +02:00
meta_llama [Bug Fix] Fix Error code: 307 for LlamaAPI Streaming Chat (#11946) 2025-06-30 16:52:42 -07:00
mistral Merge branch 'main' into litellm_dev_08_15_2025_p1 2025-08-23 10:51:56 -07:00
moonshot [Feat] New LLM API Integration - Add Moonshot API (Kimi) (#12551) (#12592) 2025-07-14 15:23:34 -07:00
nebius test: fixes 2025-05-31 12:42:56 -07:00
novita/chat Litellm fix GitHub action testing (#11163) 2025-05-26 14:41:42 -07:00
nscale/chat Litellm fix GitHub action testing (#11163) 2025-05-26 14:41:42 -07:00
oci/chat Merge pull request #14092 from gotsysdba/main 2025-09-09 22:39:16 -07:00
ollama fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
openai Added streaming support for response api streaming image generation (#15269) 2025-10-07 08:15:57 -07:00
openrouter/chat Openrouter - filter out cache_control flag for non-anthropic models (allows usage with claude code) (#12850) 2025-07-21 22:15:48 -07:00
ovhcloud feat: Add OVHCloud AI Endpoints as a provider 2025-09-12 13:37:03 +02:00
perplexity add Perplexity citation annotations support (#13225) 2025-08-02 08:47:35 -07:00
pg_vector/vector_stores [Bug Fix] QA - Use PG Vector Vector Store with LiteLLM (#12716) 2025-07-18 08:41:18 -07:00
recraft [Feat] Add Recraft API - Image Edits Support (#12874) 2025-07-22 15:03:08 -07:00
sagemaker Litellm fix GitHub action testing (#11163) 2025-05-26 14:41:42 -07:00
sambanova Feat/sambanova embeddings (#13308) 2025-08-12 17:15:26 -07:00
snowflake/chat feat(snowflake): add function calling support for Snowflake Cortex REST API 2025-10-05 13:08:33 +02:00
vercel_ai_gateway Convert integration tests to mocks 2025-07-31 23:57:53 -07:00
vertex_ai Merge pull request #15226 from otaviofbrito/chore/vertex-ai-context-caching 2025-10-06 20:05:24 -07:00
volcengine add more test 2025-09-16 12:11:10 +08:00
wandb (feat): Add W&B Inference to LiteLLM 2025-09-11 00:07:30 +05:30
watsonx Fixing watsonx error: 'model_id' or 'model' cannot be specified in the request body for models in a deployment space (#11854) 2025-06-23 10:14:10 -07:00
xai fix xai cost calculation (#14127) 2025-09-01 11:31:56 -07:00