grok2api / app /dataplane /reverse /runtime /endpoint_table.py
looknicemm1's picture
Deploy grok2api (jiujiu532) to HF Space: port 7860, bucket persistence at /app/data
48d895c verified
Raw
History Blame Contribute Delete
3.85 kB
"""Static URL table for all upstream XAI / Grok endpoints.
Canonical source of truth for every URL used by the reverse layer.
Protocol modules re-export the subset they need; transport modules
import from protocol โ€” this file is the single shared reference.
NOTE: gRPC-Web endpoints (accept_tos, nsfw_mgmt) live on different
hosts (accounts.x.ai, grok.com with gRPC path), listed separately.
"""
BASE = "https://grok.com"
ASSETS_CDN = "https://assets.grok.com"
CONSOLE_BASE = "https://console.x.ai"
# โ”€โ”€ App-chat (SSE streaming, new conversation) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
CHAT = f"{BASE}/rest/app-chat/conversations/new"
# โ”€โ”€ Asset management โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
ASSETS_UPLOAD = f"{BASE}/rest/app-chat/upload-file" # POST (base64 upload)
ASSETS_LIST = f"{BASE}/rest/assets" # GET
ASSETS_DELETE = f"{BASE}/rest/assets-metadata" # DELETE /{asset_id}
ASSETS_DOWNLOAD = ASSETS_CDN # GET /{path}
# โ”€โ”€ Rate limits (usage / quota sync) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
RATE_LIMITS = f"{BASE}/rest/rate-limits" # POST
# โ”€โ”€ gRPC-Web endpoints โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
ACCEPT_TOS = "https://accounts.x.ai/auth_mgmt.AuthManagement/SetTosAcceptedVersion"
NSFW_MGMT = f"{BASE}/auth_mgmt.AuthManagement/UpdateUserFeatureControls"
# โ”€โ”€ Auth REST โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
SET_BIRTH = f"{BASE}/rest/auth/set-birth-date" # POST
# โ”€โ”€ Media (video) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
MEDIA_POST = f"{BASE}/rest/media/post/create" # POST
MEDIA_POST_LINK = f"{BASE}/rest/media/post/create-link" # POST
VIDEO_UPSCALE = f"{BASE}/rest/media/video/upscale" # POST
# โ”€โ”€ WebSocket endpoints โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
WS_IMAGINE = "wss://grok.com/ws/imagine/listen"
WS_LIVEKIT = "wss://livekit.grok.com"
# โ”€โ”€ LiveKit โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
LIVEKIT_TOKENS = f"{BASE}/rest/livekit/tokens" # POST
# โ”€โ”€ Console API (console.x.ai) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
# ไฝฟ็”จ Bearer token ่ฎค่ฏ๏ผŒไธŽ grok.com SSO token ๅ…ฑไบซๅŒไธ€ๅฅ—ๅ‡ญ่ฏ
CONSOLE_RESPONSES = f"{CONSOLE_BASE}/v1/responses" # POST (OpenAI Responses API)
CONSOLE_CHAT = f"{CONSOLE_BASE}/v1/chat/completions" # POST (OpenAI Chat API)
__all__ = [
"BASE", "ASSETS_CDN", "CONSOLE_BASE",
"CHAT",
"ASSETS_UPLOAD", "ASSETS_LIST", "ASSETS_DELETE", "ASSETS_DOWNLOAD",
"RATE_LIMITS",
"ACCEPT_TOS", "NSFW_MGMT", "SET_BIRTH",
"MEDIA_POST", "MEDIA_POST_LINK", "VIDEO_UPSCALE",
"WS_IMAGINE", "WS_LIVEKIT", "LIVEKIT_TOKENS",
"CONSOLE_RESPONSES", "CONSOLE_CHAT",
]