litellm/tests/batches_tests
Mateo Wang c23b19f09c
feat(openai): apply regional-processing cost uplift for EU/US data residency (#28626)
* feat(openai): apply regional-processing cost uplift for EU/US data residency

OpenAI charges a 10% uplift on the latest GPT models when requests are
served from a regionalized hostname (eu./us.api.openai.com).  Infer the
region from `api_base`, expose it on `kwargs["litellm_params"]["data_residency"]`,
and multiply the computed cost by a per-model
`regional_processing_uplift_multiplier_<region>` field.

https://claude.ai/code/session_012ebH44s7ohYxjoix5CXzTW

* test: allow regional_processing_uplift_multiplier_{eu,us} in model_prices schema

* fix(cost): tighten data_residency inference and restore model_cost in tests

- Only infer OpenAI data_residency when custom_llm_provider == "openai";
  drop the implicit None fallback so non-OpenAI callers can't accidentally
  pick up a regional tag from a stray OpenAI hostname.
- _local_model_cost_map fixture now snapshots and restores
  litellm.model_cost and LITELLM_LOCAL_MODEL_COST_MAP so tests don't leak
  state across the session.

* refactor(openai): move data_residency helper under llms/openai

* fix: thread data_residency through realtime stream cost calculation

Co-authored-by: Yassin Kortam <yassin@berri.ai>

* fix(cost): thread data_residency through batch_cost_calculator

Apply the OpenAI regional-processing uplift multiplier to retrieve_batch
cost paths so Batch API requests served via eu./us.api.openai.com are
priced at the same uplifted token rates as completions/transcriptions.

* refactor(openai): encapsulate provider check inside infer_openai_data_residency

Move the custom_llm_provider == "openai" guard from get_litellm_params
into the helper itself so the core utility no longer carries
provider-specific dispatch logic. Callers pass through the provider
unconditionally; the helper returns None for any non-OpenAI provider.

* fix(responses): thread data_residency through Responses logging params

The Responses API paths build their logging litellm_params dict after
provider resolution but did not include data_residency, so cost calc
saw None even when the effective api_base was a regional OpenAI host.

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Yassin Kortam <yassin@berri.ai>
2026-05-25 20:36:14 -07:00
..
batch_job_results_furniture.jsonl
bedrock_batch_completions.jsonl test fix us.anthropic.claude-haiku-4-5-20251001-v1:0 (#24931) 2026-04-01 11:01:03 -07:00
conftest.py [Fix] Batches Tests: Remove VCR Auto-Marker 2026-05-07 15:39:46 -07:00
openai_batch_completions.jsonl
pathrise-convert-1606954137718.json use pathrise-convert-1606954137718 2025-01-05 14:14:43 -08:00
test_batch_custom_pricing.py feat(openai): apply regional-processing cost uplift for EU/US data residency (#28626) 2026-05-25 20:36:14 -07:00
test_batch_rate_limits.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_batches_logging_unit_tests.py chore(ci): modernize model references in tests and configs (#27856) 2026-05-15 15:44:28 -07:00
test_bedrock_files_and_batches.py chore(tests): migrate Bedrock CI to AWS account 941277531214 (#28728) 2026-05-25 12:03:17 -07:00
test_fine_tuning_api.py [Fix] Fine-Tuning Test: Bump Off Deprecated gpt-3.5-turbo-0125 2026-05-07 14:41:58 -07:00
test_hosted_vllm_batches_and_files.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_manus_files_all_methods.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_openai_batches_and_files.py Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_fix_scim_virtual_key_deactivation 2026-05-01 20:29:19 -07:00
vertex_batch_completions.jsonl