Get the litellm-compatible model name for a given provider. For Bedrock, prefixes the model name with 'bedrock/' if not already prefixed. For Anthropic, prefixes with 'anthropic/' if not already prefixed.
(model_name: str, provider: str)
| 52 | last_part = content[-1] |
| 53 | if isinstance(last_part, dict): |
| 54 | last_part.setdefault("cache_control", dict(_EPHEMERAL_CACHE)) |
| 55 | |
| 56 | |
| 57 | def _should_use_max_completion_tokens(model_name: str, base_url: str) -> bool: |
| 58 | """ |
| 59 | Determine whether to use max_completion_tokens instead of max_tokens. |
| 60 | |
| 61 | Newer OpenAI models (o1, o3, o4, gpt-4o, gpt-5, etc.) require |
| 62 | max_completion_tokens. Anthropic and other providers still use max_tokens. |
| 63 | """ |
| 64 | model_lower = model_name.lower() |
| 65 | # OpenAI models that require max_completion_tokens |
| 66 | new_openai_patterns = ("o1", "o3", "o4", "gpt-4o", "gpt-4-turbo", "gpt-5") |
| 67 | if any(pattern in model_lower for pattern in new_openai_patterns): |
| 68 | return True |
| 69 | # If base_url points to OpenAI directly, newer models may need it |
| 70 | if base_url and "api.openai.com" in base_url: |
no outgoing calls
no test coverage detected