diff --git a/roles/vhosts/litellm/templates/api.svc.plus.caddy.j2 b/roles/vhosts/litellm/templates/api.svc.plus.caddy.j2 index 11eeda2..0e09254 100644 --- a/roles/vhosts/litellm/templates/api.svc.plus.caddy.j2 +++ b/roles/vhosts/litellm/templates/api.svc.plus.caddy.j2 @@ -2,71 +2,24 @@ encode zstd gzip # ------------------------------------------------------------------------ - # Model Registry - # GET /v1/models + # OpenAI/Anthropic Path Compatibility Rewrites # ------------------------------------------------------------------------ - handle /v1/models { - reverse_proxy {{ litellm_listen_host }}:{{ litellm_listen_port }} { - flush_interval -1 - } - } + rewrite /v1/openai/chat/completions /v1/chat/completions + rewrite /v1/openai/embeddings /v1/embeddings + rewrite /v1/anthropic/messages /v1/messages # ------------------------------------------------------------------------ - # OpenAI-Compatible Endpoints + # Proxy ALL requests to LiteLLM Backend # ------------------------------------------------------------------------ - handle_path /v1/openai/chat/completions { - rewrite * /v1/chat/completions - reverse_proxy {{ litellm_listen_host }}:{{ litellm_listen_port }} { - flush_interval -1 - transport http { - dial_timeout 30s - read_timeout 600s - write_timeout 600s - } + reverse_proxy {{ litellm_listen_host }}:{{ litellm_listen_port }} { + flush_interval -1 + transport http { + dial_timeout 30s + read_timeout 600s + write_timeout 600s } } - handle_path /v1/openai/embeddings { - rewrite * /v1/embeddings - reverse_proxy {{ litellm_listen_host }}:{{ litellm_listen_port }} { - flush_interval -1 - transport http { - dial_timeout 30s - read_timeout 600s - write_timeout 600s - } - } - } - - # ------------------------------------------------------------------------ - # Anthropic-Compatible Endpoint - # ------------------------------------------------------------------------ - handle_path /v1/anthropic/messages { - rewrite * /v1/messages - reverse_proxy {{ litellm_listen_host }}:{{ litellm_listen_port }} { - flush_interval -1 - transport http { - dial_timeout 30s - read_timeout 600s - write_timeout 600s - } - } - } - - # ------------------------------------------------------------------------ - # Admin UI - # ------------------------------------------------------------------------ - handle /ui* { - reverse_proxy {{ litellm_listen_host }}:{{ litellm_listen_port }} { - flush_interval -1 - } - } - - # Catch-all: block unknown paths - handle { - respond "Not Found" 404 - } - log { output file /var/log/caddy/{{ litellm_api_domain }}.access.log }