fix(cloudflare): clarify chat and decisions endpoints (#47965) (#48265)

This commit is contained in:
ishaan-j-berri 2026-10-24 17:29:48 -07:00 • committed by GitHub
parent 5171b3fbd8
commit 2223895010
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View file

@ -58,7 +58,7 @@ class CloudflareChatConfig(OpenAIGPTConfig):
trimmed: Final = api_base.rstrip("/")
if trimmed.endswith("/ai/run"):
verbose_logger.warning(
"Cloudflare api_base ending in '/ai/run' is the legacy Workers AI path and no longer serves OpenAI-compatible requests; rewriting to the '/ai/v1' endpoint"
"Cloudflare chat completions require the OpenAI-compatible '/ai/v1' endpoint; rewriting api_base ending in '/ai/run' to '/ai/v1'. Decision models continue to use the native Workers AI '/ai/run/{model}' endpoint."
)
return join_api_base(trimmed[: -len("/ai/run")], "ai/v1")
return api_base

View file

@ -20,6 +20,8 @@ class CloudflareDecisionsConfig(BaseDecisionsConfig):
inlines_remote_images = True
def get_default_api_base(self) -> str | None:
# Decision models (Clef) require native /ai/run/{model} requests with
# state and questions; /ai/v1/chat/completions only accepts chat requests.
return workers_ai_default_api_base()
def missing_api_base_message(self, custom_llm_provider: str) -> str: