router-for-me/CLIProxyAPI · error

unsupported Codex Alpha Search model route target

Error message

unsupported Codex Alpha Search model route target %q (%q)

What it means

Thrown while resolving the model for a Codex Alpha Search request. A plugin handled RouteModel, but the route target it returned is not a provider route pointing at the 'codex' provider. The server only accepts TargetKind == pluginapi.ModelRouteTargetProvider with Target == "codex" for this endpoint, so any other target kind (e.g. a model rewrite or a different provider) is rejected.

Solutions

  1. Update the plugin's route rules so requests sourced from Codex Alpha Search either return Target 'codex' with TargetKind ModelRouteTargetProvider, or return handled=false to let the server use the original model
  2. Check the plugin configuration for model-route entries whose source pattern accidentally matches the alpha search endpoint
  3. Temporarily disable the routing plugin to confirm it is the source of the redirect

Example fix

// before (plugin)
return ModelRouteResponse{Handled: true, TargetKind: "model", Target: "gpt-5"}, true

// after (plugin)
return ModelRouteResponse{Handled: true, TargetKind: pluginapi.ModelRouteTargetProvider, Target: "codex", TargetModel: "gpt-5"}, true
Defensive patterns

Strategy: validation

Try / catch

if _, err := resolveCodexAlphaSearchModel(...); err != nil && strings.Contains(err.Error(), "unsupported Codex Alpha Search model route target") {
	// plugin misroute: log target kind/target and bypass plugin routing for this request
}

Prevention

When it happens

Trigger: A loaded plugin's RouteModel hook returns handled=true with TargetKind other than ModelRouteTargetProvider, or Target set to a provider name other than 'codex' (e.g. 'gemini', 'openrouter'), while a Codex Alpha Search request is being routed.

Common situations: Installing a third-party routing plugin that rewrites all model requests to a different provider; misconfiguring a plugin's route table so the codex alpha search path matches a cross-provider rule; plugin version change that altered TargetKind semantics.

Related errors


AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15). Data as JSON: /api/errors/76bf0e93800f79dc. Report an issue: GitHub.

Appendix: source

Thrown at internal/api/server_routes.go:237

	metadata := map[string]any{
		coreexecutor.RequestedModelMetadataKey: model,
	}
	if requestPath != "" {
		metadata[coreexecutor.RequestPathMetadataKey] = requestPath
	}
	resp, handled := host.RouteModel(ctx, pluginapi.ModelRouteRequest{
		SourceFormat:   codexAlphaSearchSourceFormat,
		RequestedModel: model,
		Headers:        headers,
		Query:          queryValues,
		Body:           body,
		Metadata:       metadata,
	})
	if !handled || !resp.Handled {
		return model, nil
	}
	if resp.TargetKind != pluginapi.ModelRouteTargetProvider || !strings.EqualFold(strings.TrimSpace(resp.Target), "codex") {
		return "", fmt.Errorf("unsupported Codex Alpha Search model route target %q (%q)", resp.TargetKind, resp.Target)
	}
	if targetModel := strings.TrimSpace(resp.TargetModel); targetModel != "" {
		return targetModel, nil
	}
	return model, nil
}

func sanitizeCodexAlphaSearchBody(body []byte) []byte {
	var payload map[string]json.RawMessage
	if errUnmarshal := json.Unmarshal(body, &payload); errUnmarshal != nil || payload == nil {
		return body
	}

	removed := false
	for _, field := range []string{"prompt_cache_key", "prompt_cache_retention"} {
		if _, exists := payload[field]; exists {
			delete(payload, field)
			removed = true

View on GitHub (pinned to 78f0c4079e)