can1357/oh-my-pi · error · CliUsageError

Invalid --service-tier value

Error message

Invalid --service-tier value: ${JSON.stringify(value)}. Expected one of: ${SERVICE_TIER_OPENAI_VALUES.join(", ")}.

What it means

The --service-tier flag setter validates the value against SERVICE_TIER_OPENAI_VALUES (the OpenAI service-tier enum, e.g. auto/flex/priority/default). Unknown strings raise this CliUsageError listing every accepted value, so the message itself documents the valid set.

Solutions

  1. Use exactly one of the values listed in the error message (they are joined after 'Expected one of:')
  2. Match casing precisely — the check is a literal membership test
  3. Omit --service-tier to use the provider default instead of guessing a tier name
  4. Check the provider actually supports the tier you want; the flag only forwards OpenAI-recognized values

Example fix

// before
omp <cmd> --service-tier Priority
// after
omp <cmd> --service-tier priority
Defensive patterns

Strategy: validation

Validate before calling

const SERVICE_TIERS = ['auto','flex','priority','default']; // match the CLI's accepted set / error message
if (!SERVICE_TIERS.includes(value)) throw new Error(`--service-tier must be one of: ${SERVICE_TIERS.join(', ')}`);

Type guard

type ServiceTier = (typeof SERVICE_TIERS)[number];
const isServiceTier = (v: string): v is ServiceTier =>
  (SERVICE_TIERS as readonly string[]).includes(v);

Try / catch

try {
  parse(['--service-tier', tier]);
} catch (e) {
  if (e instanceof CliUsageError && e.message.includes('--service-tier')) {
    console.error(`Pick a listed tier: ${e.message.match(/Expected one of: (.+)\./)?.[1]}`);
  } else throw e;
}

Prevention

When it happens

Trigger: `--service-tier something` where something is not in the accepted enum: typos (`flexi`, `prioroty`), wrong casing if the enum is lowercase-only (`Flex`), or tiers from other providers that OpenAI does not support.

Common situations: Users copying service-tier names from another provider's docs, assuming the flag accepts arbitrary provider-specific tiers, or capitalizing the value (`--service-tier Priority`) when only exact enum members pass the type guard.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/d45732af211d7415. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/cli/flag-tables.ts:157

	},
	"--slow": (result, value) => {
		result.slow = value;
	},
	"--plan": (result, value) => {
		result.plan = value;
	},
	"--prewalk-into": (result, value) => {
		result.prewalkInto = value;
	},
	"--plan-yolo-into": (result, value) => {
		result.planYoloInto = value;
	},
	"--max-time": (result, value) => {
		result.maxTime = parseMaxTimeSeconds(value);
	},
	"--service-tier": (result, value) => {
		if (!isServiceTierOpenAISettingValue(value)) {
			throw new CliUsageError(
				`Invalid --service-tier value: ${JSON.stringify(value)}. Expected one of: ${SERVICE_TIER_OPENAI_VALUES.join(", ")}.`,
			);
		}
		result.serviceTier = value;
	},
	"--api-key": (result, value) => {
		result.apiKey = value;
	},
	"--system-prompt": (result, value) => {
		result.systemPrompt = value;
	},
	"--append-system-prompt": (result, value) => {
		result.appendSystemPrompt = value;
	},
	"--provider-session-id": (result, value) => {
		result.providerSessionId = value;
	},
	"--prompt-cache-key": (result, value) => {

View on GitHub (pinned to 9690622007)