Routing and trust

Discover routes by capability, then place explicit bounds on the provider selected for a paid request. Omit every routing header to retain the default marketplace selection.

View as Markdown

Catalog filters

GET /v1/models is public and cursor-paginated. Filters compose with AND semantics; repeated values are not accepted.

Query parameterMeaning
liveOnly routes live now when true; otherwise inspect registered capabilities.
endpoint_familyHosted endpoint family, such as CHAT, VIDEOS or WORKFLOWS.
modalityText, embedding, image, video, audio, music or workflow capability.
attestation_tierExact integer 1–4; mutually exclusive with min_attestation_tier.
min_attestation_tierInteger 1–4 minimum; mutually exclusive with attestation_tier.
max_input_price_per_million_usdMaximum retail input price in USD per one million tokens.
max_output_price_per_million_usdMaximum retail output price in USD per one million tokens.
max_representative_request_price_usdMaximum unit-aware retail cost for the model's representative request.
min_context_tokensMinimum context capacity in tokens.
quantizationCanonical quantization bucket such as bf16, nvfp4 or int4.
toolsRequire or exclude native tool calling.
structured_outputRequire or exclude structured JSON output.
providerRestrict results to one 64-hex provider public key.
prompt_confidentialRequire or exclude prompt-confidential compute.
sortSort by id, providers, input_price, output_price, request_price, context or listed.
orderAscending or descending order.
limitPage size from 1 to 100; default 50.
cursorOpaque continuation cursor from the previous response.

Exact tier, minimum tier, and confidentiality

attestation_tier is exact. min_attestation_tier accepts that tier or a higher one. T1 is a verified software report; T2 adds hardware device identity; T3 is confidential hardware; T4 is an admin-KYB identity tier. Tier order alone does not imply prompt confidentiality, so use prompt_confidential when that property is required.

With live=true, capability, tier, provider and confidentiality filters inspect only routes that can dispatch now. Without it, a result may be registered but temporarily offline.

Per-request routing headers

Tier, quantization, provider, throughput, wait and retail-cost controls apply to every paid endpoint. Context and hedging apply only to text generation. Throughput uses each endpoint's native measured unit. Every supplied value is validated before provider spend.

HeaderEffect
X-Mayhem-Min-Att-TierMinimum provider tier as 1–4 or T1–T4; higher tiers also qualify.
X-Mayhem-Min-CtxText generation only. Minimum context capacity in tokens; the calculated request need remains the floor.
X-Mayhem-QuantRequire one canonical quantization bucket.
X-Mayhem-Prefer-ProvidersStrict ordered provider set; comma-separated 64-hex public keys.
X-Mayhem-HedgeText generation only. Use 1 to request hedging, 0 to disable; incompatible with a strict provider list.
X-Mayhem-Min-Tok-SPositive minimum sustained throughput in the endpoint's native measured unit per second.
X-Mayhem-Max-Wait-MsWait 0–60,000 ms for provider admission; not a generation timeout.
X-OpenMayhem-Max-Cost-UsdMaximum retail USD hold for this request, checked before spend.
No routing headers means normal marketplace routing. Existing clients keep their current behavior.

Provider preference and failover

X-Mayhem-Prefer-Providers is strict, not a hint. Providers are tried in the supplied order, and the request fails with preferred_provider_unavailable when none qualifies. OpenMayhem never silently falls back outside the list.

Tier, context, quantization, throughput and price constraints apply to every retry, failover and hedge candidate. Hedging does not weaken those constraints and cannot be combined with a strict preferred-provider list.

Asynchronous jobs

Routing headers are captured as immutable asynchronous-job evidence at creation. Idempotent replays must match those stored requirements, and they remain attached during reconciliation. Poll and artifact requests do not need the headers again; later changes cannot mutate the job.

Retail cost versus wholesale routing price

X-OpenMayhem-Max-Cost-Usd limits the customer's worst-case retail hold. The stricter of this value and the API key's per-request cap wins. It is an exact decimal USD string, not a floating-point estimate.

X-Mayhem-Max-Price-Au is the platform's private wholesale rate-basis gate: a standardized 1,000-unit basket of every priced dimension, or the fixed-price fallback. It is not a request-total ceiling. Hosted customers must never send or control it.

Examples

curl

curl "https://api.openmayhem.ai/v1/chat/completions" \
  -H "Authorization: Bearer $OPENMAYHEM_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Mayhem-Min-Att-Tier: T2" \
  -H "X-Mayhem-Min-Ctx: 131072" \
  -H "X-Mayhem-Quant: nvfp4" \
  -H "X-Mayhem-Max-Wait-Ms: 30000" \
  -H "X-OpenMayhem-Max-Cost-Usd: 0.50" \
  -d '{
    "model": "qwen/qwen3.8-27b",
    "messages": [{"role": "user", "content": "Summarize this contract."}],
    "max_tokens": 1000
  }'

JavaScript

const response = await fetch(
  "https://api.openmayhem.ai/v1/chat/completions",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.OPENMAYHEM_API_KEY}`,
      "Content-Type": "application/json",
      "X-Mayhem-Min-Att-Tier": "T2",
      "X-Mayhem-Hedge": "1",
      "X-Mayhem-Min-Tok-S": "20",
      "X-OpenMayhem-Max-Cost-Usd": "0.50",
    },
    body: JSON.stringify({
      model: "qwen/qwen3.8-27b",
      messages: [{ role: "user", content: "Give me three release risks." }],
      max_tokens: 800,
    }),
  },
);

if (!response.ok) throw new Error(await response.text());
const completion = await response.json();

Python

import os
import requests

response = requests.post(
    "https://api.openmayhem.ai/v1/chat/completions",
    headers={
        "Authorization": f"Bearer {os.environ['OPENMAYHEM_API_KEY']}",
        "X-Mayhem-Prefer-Providers": "PROVIDER_PUBLIC_KEY",
        "X-Mayhem-Min-Att-Tier": "T2",
        "X-Mayhem-Max-Wait-Ms": "30000",
        "X-OpenMayhem-Max-Cost-Usd": "0.50",
    },
    json={
        "model": "qwen/qwen3.8-27b",
        "messages": [{"role": "user", "content": "Hello"}],
        "max_tokens": 500,
    },
    timeout=120,
)
response.raise_for_status()
print(response.json())

Stable constraint errors

Invalid values and unavailable combinations fail before spend with stable codes. Recheck the live catalog before changing the constraint or retrying. See Errors for the complete code catalog. Errors.

CodeStatusRetry
retail_cost_limit_exceeded403—
invalid_catalog_filter400—
invalid_routing_control400—
routing_control_not_public400—
incompatible_routing_constraints400—
no_provider_satisfies_attestation_tier400—
no_provider_satisfies_quant400—
context_requirement_unavailable400—
preferred_provider_unavailable503✓
confidential_compute_unavailable503✓