router-for-me/CLIProxyAPI · error
xai device code: device authorization endpoint is required
Error message
xai device code: device authorization endpoint is required
What it means
Error "xai device code: device authorization endpoint is required" thrown in router-for-me/CLIProxyAPI.
Source
Thrown at internal/auth/xai/xai.go:129
}
// StartDeviceFlow requests a device code from xAI.
func (a *XAIAuth) StartDeviceFlow(ctx context.Context) (*DeviceCodeResponse, error) {
discovery, errDiscover := a.Discover(ctx)
if errDiscover != nil {
return nil, errDiscover
}
return a.RequestDeviceCode(ctx, discovery.DeviceAuthorizationEndpoint, discovery.TokenEndpoint)
}
// RequestDeviceCode requests a device authorization code from the given endpoint.
func (a *XAIAuth) RequestDeviceCode(ctx context.Context, deviceAuthorizationEndpoint, tokenEndpoint string) (*DeviceCodeResponse, error) {
if ctx == nil {
ctx = context.Background()
}
deviceAuthorizationEndpoint = strings.TrimSpace(deviceAuthorizationEndpoint)
if deviceAuthorizationEndpoint == "" {
return nil, fmt.Errorf("xai device code: device authorization endpoint is required")
}
form := url.Values{
"client_id": {ClientID},
"scope": {Scope},
}
req, err := http.NewRequestWithContext(ctx, http.MethodPost, deviceAuthorizationEndpoint, strings.NewReader(form.Encode()))
if err != nil {
return nil, fmt.Errorf("xai device code: create request: %w", err)
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Accept", "application/json")
resp, err := a.httpClient.Do(req)
if err != nil {
return nil, fmt.Errorf("xai device code request failed: %w", err)
}
defer func() {View on GitHub (pinned to 78f0c4079e)
Solutions
- Ensure the discovery document provides device_authorization_endpoint before starting device flow.
- Re-fetch the xAI discovery document if the endpoint was missing.
When it happens
Trigger: Thrown at internal/auth/xai/xai.go:129 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/a50bbe0ad05085ce.
Report an issue: GitHub.