From 323fe8aeac91da77571257ab67d2bcc8d0e42ffd Mon Sep 17 00:00:00 2001 From: 0x5751 Date: Thu, 28 Aug 2025 22:21:41 +0800 Subject: [PATCH] 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 --- docs/my-website/docs/providers/anthropic.md | 21 +++++++++++++++++++ docs/my-website/docs/proxy/config_settings.md | 1 + 2 files changed, 22 insertions(+) diff --git a/docs/my-website/docs/providers/anthropic.md b/docs/my-website/docs/providers/anthropic.md index a7a9dc3001..820c2906bf 100644 --- a/docs/my-website/docs/providers/anthropic.md +++ b/docs/my-website/docs/providers/anthropic.md @@ -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 diff --git a/docs/my-website/docs/proxy/config_settings.md b/docs/my-website/docs/proxy/config_settings.md index 1fb4cd55aa..a89654af0c 100644 --- a/docs/my-website/docs/proxy/config_settings.md +++ b/docs/my-website/docs/proxy/config_settings.md @@ -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