docs: add documentation for LITELLM_ANTHROPIC_DISABLE_URL_SUFFIX environment variable

Added comprehensive documentation for the new LITELLM_ANTHROPIC_DISABLE_URL_SUFFIX configuration option that allows users to disable automatic URL suffix appending when using custom Anthropic API endpoints. This is useful for proxy servers or custom endpoints that don't follow Anthropic's standard URL structure.

Changes:
- Added environment variable to Anthropic provider docs with examples
- Created "Custom API Base" section explaining usage scenarios
- Added entry to environment variables reference table in config settings
This commit is contained in:
0x5751
2025-08-28 22:21:41 +08:00
parent e638c5490d
commit 323fe8aeac
2 changed files with 22 additions and 0 deletions
@@ -55,8 +55,29 @@ import os
os.environ["ANTHROPIC_API_KEY"] = "your-api-key"
# os.environ["ANTHROPIC_API_BASE"] = "" # [OPTIONAL] or 'ANTHROPIC_BASE_URL'
# os.environ["LITELLM_ANTHROPIC_DISABLE_URL_SUFFIX"] = "true" # [OPTIONAL] Disable automatic URL suffix appending
```
### Custom API Base
When using a custom API base for Anthropic (e.g., a proxy or custom endpoint), LiteLLM automatically appends the appropriate suffix (`/v1/messages` or `/v1/complete`) to your base URL.
If your custom endpoint already includes the full path or doesn't follow Anthropic's standard URL structure, you can disable this automatic suffix appending:
```python
import os
os.environ["ANTHROPIC_API_BASE"] = "https://my-custom-endpoint.com/custom/path"
os.environ["LITELLM_ANTHROPIC_DISABLE_URL_SUFFIX"] = "true" # Prevents automatic suffix
```
Without `LITELLM_ANTHROPIC_DISABLE_URL_SUFFIX`:
- Base URL `https://my-proxy.com``https://my-proxy.com/v1/messages`
- Base URL `https://my-proxy.com/api``https://my-proxy.com/api/v1/messages`
With `LITELLM_ANTHROPIC_DISABLE_URL_SUFFIX=true`:
- Base URL `https://my-proxy.com/custom/path``https://my-proxy.com/custom/path` (unchanged)
## Usage
```python
@@ -558,6 +558,7 @@ router_settings:
| LITERAL_API_KEY | API key for Literal integration
| LITERAL_API_URL | API URL for Literal service
| LITERAL_BATCH_SIZE | Batch size for Literal operations
| LITELLM_ANTHROPIC_DISABLE_URL_SUFFIX | Disable automatic URL suffix appending for Anthropic API base URLs. When set to `true`, prevents LiteLLM from automatically adding `/v1/messages` or `/v1/complete` to custom Anthropic API endpoints
| LITELLM_DONT_SHOW_FEEDBACK_BOX | Flag to hide feedback box in LiteLLM UI
| LITELLM_DROP_PARAMS | Parameters to drop in LiteLLM requests
| LITELLM_MODIFY_PARAMS | Parameters to modify in LiteLLM requests