router-for-me/CLIProxyAPI · error
Codex Alpha Search API key base URL unavailable
Error message
Codex Alpha Search API key base URL unavailable
What it means
The host returns this when currentModelExecutor() yields nil, meaning no model executor was registered on the plugin host before the plugin invoked host.model.execute_stream. The executor is the host-side bridge into the core model pipeline; without it the callback cannot reach any model.
Source
Thrown at internal/api/server_routes.go:391
return
}
ctx = attemptCtx
releaseAttempt = release
defer releaseAttempt()
}
logging.SetGinCPATraceID(c, selected.EnsureIndex())
baseHeaders := make(http.Header)
baseHeaders.Set("Content-Type", "application/json")
baseHeaders.Set("Accept", "application/json")
baseHeaders.Set("Originator", "codex_cli_rs")
for _, name := range []string{"Version", "User-Agent", "Session_id", "X-Client-Request-Id"} {
if value := strings.TrimSpace(c.GetHeader(name)); value != "" {
baseHeaders.Set(name, value)
}
}
errMissingBaseURL := errors.New("Codex Alpha Search API key base URL unavailable")
routeModel := strings.TrimSpace(selectionModel)
if routeModel == "" {
routeModel = strings.TrimSpace(routing.Model)
}
performRequest := func(current *auth.Auth) (*http.Response, error) {
headers := baseHeaders.Clone()
if accountID, ok := current.Metadata["account_id"].(string); ok && strings.TrimSpace(accountID) != "" {
headers.Set("Chatgpt-Account-Id", accountID)
}
upstreamURL := "https://chatgpt.com/backend-api/codex/alpha/search"
requestBody := upstreamRequestBody
// API-key Alpha Search reuses normal credential-aware model resolution so
// CPA routing prefixes and model aliases are not forwarded upstream.
if current.AuthKind() == auth.AuthKindAPIKey {
baseURL := ""
if current.Attributes != nil {
baseURL = strings.TrimSpace(current.Attributes["base_url"])
}View on GitHub (pinned to 78f0c4079e)
Solutions
- Ensure the host is fully initialized and the model executor is registered before plugins are loaded or allowed to call host.model.execute_stream.
- In tests, register a stub executor on the Host so currentModelExecutor() is non-nil.
- In the plugin, defer host.model.execute_stream calls until after host startup completes (e.g. an init/ready hook), and handle the error without retry loops against a shutting-down host.
Example fix
// test setup: give the host a model executor before plugins can stream
host := pluginhost.New(...)
host.SetModelExecutor(stubExecutor) // before LoadPlugins / plugin init
// plugin side: fail soft when executor is not wired yet
resp, err := host.Call(ctx, "host.model.execute_stream", raw)
if err != nil && strings.Contains(err.Error(), "executor is unavailable") {
return fmt.Errorf("host not ready for model execution: %w", err)
} Defensive patterns
Strategy: validation
Validate before calling
// plugin side: only call model callbacks once the host signaled readiness
if !hostReady.Load() {
return errors.New("host model executor not ready")
} Try / catch
resp, err := host.Call(ctx, "host.model.execute_stream", raw)
if err != nil && strings.Contains(err.Error(), "executor is unavailable") {
// host wiring/lifecycle problem: surface it, do not retry blindly
return fmt.Errorf("host not ready for model execution: %w", err)
} Prevention
- Register the model executor on the Host before loading plugins.
- Defer host.model.* calls until after host startup completes.
- In tests, always inject a stub executor.
When it happens
Trigger: A plugin calls host.model.execute_stream before the host has been given an executor via its SetModelExecutor-style wiring, or after the executor was cleared during host shutdown/reconfiguration.
Common situations: Unit tests that construct a bare Host without an executor; plugins that fire model calls during plugin load (before the core service registers the executor); host teardown racing an in-flight callback.
Related errors
- plugin host is unavailable
- host model executor is unavailable
- Realtime client secrets require an SDP or JSON call request
- Codex live call request requires an SDP offer
- core auth manager unavailable
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/ef80c214934690f4.
Report an issue: GitHub.