router-for-me/CLIProxyAPI · error

count must be a positive integer

Error message

count must be a positive integer

What it means

The host.model.execute_stream callback explicitly requires the stream flag to be true. The RPC handler checks req.Stream after decoding and rejects non-streaming executions because this callback only manages streaming model bridges; non-streaming execution must use the non-stream callback.

Source

Thrown at internal/api/handlers/management/usage.go:52

	}

	items := redisqueue.PopOldest(count)
	records := make([]usageQueueRecord, 0, len(items))
	for _, item := range items {
		records = append(records, usageQueueRecord(append([]byte(nil), item...)))
	}

	c.JSON(http.StatusOK, records)
}

func parseUsageQueueCount(value string) (int, error) {
	value = strings.TrimSpace(value)
	if value == "" {
		return 1, nil
	}
	count, errCount := strconv.Atoi(value)
	if errCount != nil || count <= 0 {
		return 0, errors.New("count must be a positive integer")
	}
	return count, nil
}

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Set Stream: true on the HostModelExecutionRequest before invoking host.model.execute_stream.
  2. If you do not want streaming, call the non-streaming host.model.execute callback instead.

Example fix

// before
req := pluginapi.HostModelExecutionRequest{Model: "gpt-4o", Input: input}
host.Call(ctx, "host.model.execute_stream", mustMarshal(req)) // error: requires stream=true

// after
req := pluginapi.HostModelExecutionRequest{Model: "gpt-4o", Input: input, Stream: true}
host.Call(ctx, "host.model.execute_stream", mustMarshal(req))
Defensive patterns

Strategy: validation

Validate before calling

if !req.Stream {
    req.Stream = true // or route to the non-streaming host.model.execute callback instead
}

Try / catch

if err != nil && strings.Contains(err.Error(), "requires stream=true") {
    req.Stream = true
    // re-issue once with the corrected flag
}

Prevention

When it happens

Trigger: A plugin calls host.model.execute_stream with "stream": false or omits the field (Go zero value false) in HostModelExecutionRequest.

Common situations: Plugin developer copies the request struct from a non-streaming example and forgets to set Stream=true; default value of the bool field silently disabling streaming; plugin built against an SDK where the field was optional or implicit.

Related errors


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