claude-proxy / src /free_claude_code /api /generation_paths.py
dheraingoud's picture
Copilot App
Sync upstream v6.19.35 and preserve custom addons
a9e27c0
Raw History Blame Contribute Delete
835 Bytes
from __future__ import annotations
"""Public generation route classification shared by HTTP boundaries."""
from typing import Literal
type WireApi = Literal["messages", "responses", "gemini", "chat"]
_GEMINI_ACTIONS = (":generateContent", ":streamGenerateContent")
def generation_api(path: str) -> WireApi | None:
if path == "/v1/messages":
return "messages"
if path == "/v1/responses":
return "responses"
if path == "/v1/chat/completions":
return "chat"
if path.startswith("/v1beta/models/"):
return "gemini"
# Gemini SDKs with a custom base URL call /v1/models/... too. OpenAI clients
# share that prefix, so only Gemini generation methods are Gemini there.
if path.startswith("/v1/models/") and path.endswith(_GEMINI_ACTIONS):
return "gemini"
return None