litellm/tests/test_litellm/llms
Guilherme Segantini e335dd70f8
fix(sap provider layer): enable response-format for anthropic models and improve compatibility for GPT models via LangChain (#22804)
* (sap) ensure tool parameters have type='object' for SAP compatibility

Fix SAP GenAI Hub Orchestration Service rejecting tool calls with error:
"400 - LLM Module: tools.0.custom.input_schema.type: Input should be 'object'"

Root cause: When Claude Code uses tools (like web_search) with the SAP provider
through LiteLLM's Anthropic experimental pass-through adapter, Anthropic's
input_schema format doesn't always include the required type="object" field.

The adapter's translate_anthropic_tools_to_openai() function was directly
copying input_schema to OpenAI's parameters field without ensuring the
type="object" requirement that SAP's API strictly enforces.

Changes:
- Modified translate_anthropic_tools_to_openai() to check if input_schema
  is missing the type field and add type="object" if absent
- Preserves existing type field if already present
- Added comprehensive test suite (6 tests) covering:
  - Missing type field scenario (now adds type="object")
  - Existing type preservation
  - Empty input_schema handling
  - Multiple tools transformation
  - Additional schema properties preservation
  - SAP-specific compatibility regression test

Testing:
- All new tests pass (6/6 in test_anthropic_tool_schema_fix.py)
- All existing Anthropic tool tests pass (57/57 tool-related tests)
- SAP tool parameter validation tests pass (9/9 in test_sap_tool_parameters.py)

* (sap) enable native response_format for anthropic models

* (sap) filter strict param from model_params for GPT models only

* (sap) revert Anthropic adapter type='object' fix

The SAP FunctionTool Pydantic validator in litellm/llms/sap/chat/models.py
already ensures type='object' is added to all tool parameters for SAP
API compatibility.

The Anthropic adapter change affected ALL consumers, not just SAP, which
was broader scope than intended for this PR.

- Revert input_schema modification in Anthropic adapter
- Remove Anthropic-specific test file (SAP tests still cover this case)

* (sap) gate markdown stripping to Anthropic models only

SAP GenAI Hub with Anthropic models sometimes returns JSON wrapped in
markdown code blocks. GPT/Gemini/Mistral models don't exhibit this
behavior, so stripping is now gated to avoid accidentally modifying
valid responses that may contain markdown in JSON string values.
2026-03-04 16:03:59 -08:00
..
amazon_nova/chat
anthropic Revert "fix(anthropic): remove hardcoded reasoning summary in adapter" 2026-03-04 17:52:49 +05:30
azure Exclude aresponses_websocket from Azure SDK client init test 2026-03-04 11:13:57 -03:00
azure_ai fix: support Azure AD token auth for non-Claude azure_ai models (#20981) 2026-02-11 10:48:44 -08:00
baseten/chat
bedrock Merge branch 'litellm_oss_staging_02_27_2026' of https://github.com/BerriAI/litellm into litellm_oss_staging_02_27_2026 2026-02-28 09:54:56 -03:00
bytez/chat
chat test(bedrock): add unit tests for region extraction from bedrock/{region}/{model} path 2026-03-02 11:06:27 +05:30
chatgpt fix(chatgpt): normalize streaming tool_call indices and deduplicate closing chunks 2026-02-18 18:02:36 -03:00
cohere
cometapi/chat
compactifai
custom_httpx [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
dashscope fix: remove list-to-str transformation from dashscope 2026-02-19 07:30:13 +00:00
databricks Address Greptile review: fix SDK auth fallback and remove unused imports 2026-02-18 15:57:50 +09:00
datarobot
deepgram
deepinfra Fix: tool content should be str 2026-01-07 11:01:31 +05:30
docker_model_runner
featherless_ai/chat fix(tests): use monkeypatch for env var isolation in featherless tests 2026-03-01 23:46:15 +01:00
fireworks_ai Fix: Extra inputs are not permitted, field: 'messages[2].provider_specific_fields' 2026-02-03 16:23:18 +05:30
gemini Add get files API support and tests 2026-02-03 18:57:39 +05:30
github_copilot
heroku
hosted_vllm feat: add native Responses API support for hosted_vllm provider (#22298) 2026-03-02 19:21:11 +05:30
huggingface fix: improve test isolation for parallel execution 2026-02-17 21:28:23 -03:00
jina_ai/embedding
lemonade
litellm_proxy/chat
llamafile/chat
lm_studio
manus [Feat] New provider - Manus API on /responses, GET /responses (#18804) 2026-01-08 18:37:42 +05:30
meta_llama fix: add missing OpenAI chat completion params to OPENAI_CHAT_COMPLETION_PARAMS (#21360) 2026-02-16 20:31:21 -08:00
minimax
mistral
moonshot fix(moonshot): preserve image_url blocks in multimodal messages 2026-02-19 16:44:38 -03:00
nebius
novita/chat
nscale/chat
oci/chat Fixes #20957 2026-02-11 11:20:18 +00:00
ocr Add OCR guardrail_translation handler and support (#22145) 2026-02-28 17:39:36 -08:00
ollama fix(ollama): thread api_base to get_model_info + graceful fallback (#21970) 2026-02-23 21:00:37 -08:00
openai fix(responses): preserve query params in compact URL construction (#22668) 2026-03-04 11:33:13 -08:00
openai_like fix(proxy): fix master key rotation Prisma validation errors (#21330) 2026-02-16 15:13:05 -08:00
openrouter Merge pull request #22403 from shivaaang/fix/openrouter-image-edit 2026-03-03 15:31:04 -03:00
ovhcloud
perplexity feat(perplexity): add embedding support for pplx-embed-v1 models (#22610) 2026-03-02 17:37:50 -08:00
pg_vector/vector_stores
publicai fix: add missing OpenAI chat completion params to OPENAI_CHAT_COMPLETION_PARAMS (#21360) 2026-02-16 20:31:21 -08:00
ragflow/chat
recraft
runwayml
s3_vectors [Feat] RAG API - Add s3_vectors as provider on /vector_store/search API + UI for creating + PDF support for /rag/ingest (#19895) 2026-01-27 16:30:59 -08:00
sagemaker fix(sagemaker): Support TEI raw array response format for embeddings (#20487) 2026-02-12 19:39:05 +05:30
sambanova
sap fix(sap provider layer): enable response-format for anthropic models and improve compatibility for GPT models via LangChain (#22804) 2026-03-04 16:03:59 -08:00
snowflake
stability
vercel_ai_gateway feat(vercel_ai_gateway): add embeddings support 2026-01-23 15:11:37 -03:00
vertex_ai Merge pull request #22765 from BerriAI/main 2026-03-04 17:40:42 +05:30
volcengine test: Fix additional broken tests 2026-02-15 13:08:41 -03:00
voyage/rerank
wandb
watsonx [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
xai Add xai websearch params support 2026-01-28 09:54:43 +05:30
zai
test_cache_control_and_reasoning.py Add Prompt caching and reasoning support for MiniMax, GLM, Xiaomi 2026-01-28 17:25:26 +05:30
test_lifecycle_fix.py fix: revert httpx client caching that caused closed client errors (#20025) 2026-02-03 16:15:04 -08:00
test_oom_fixes.py fix: HTTP client memory leaks in Presidio, OpenAI, and Gemini (#19190) 2026-01-19 19:02:55 -08:00