OpenRouter migration

Move the gateway, preserve the choice.

Move an OpenRouter-style OpenAI client to OpenWaya and replace provider-specific routing fields with governed policy.

01 / Inventory

Treat extensions as an explicit migration.

Both services expose an OpenAI-style base URL, but their model catalogs and routing extensions are different contracts. Inventory every model ID, operation, request extension, fallback rule, and usage field before changing traffic. Fetch the authenticated OpenWaya /v1/models catalog and map only models that are active, priced, routed, and capability-complete for your workspace.

  • Do not assume provider/model identifiers have the same OpenWaya ID or availability.
  • OpenRouter provider, transforms, and models fallback fields are not OpenWaya request fields and fail strict validation.
  • HTTP-Referer and X-Title attribution headers are not required by OpenWaya.

02 / Client

Change two client values.

Replace the gateway URL and secret. Keep the OpenAI SDK and standard Chat Completions parsing for fields supported by both contracts. Use a separately scoped key per environment and never expose it in browser code.

JavaScript · replacement client
const client = new OpenAI({
  apiKey: process.env.OPENWAYA_API_KEY,
  baseURL: "https://api.openwaya.africa/v1",
  maxRetries: 0,
  timeout: 30_000,
});

03 / Routing

Move routing policy out of ad hoc payloads.

Replace caller-supplied provider ordering and fallback arrays with an administrator-reviewed OpenWaya routing policy. Hard capability, privacy, country, plan, quota, and safety constraints run before health, latency, cost, and regional scoring. Use openwaya/auto when the application wants policy selection, or a catalog model ID when it needs a specific model profile.

  • Do not send provider, transforms, or models request properties.
  • For streams, choose terminate or replay behavior explicitly only when stream is true.
  • Read the returned provider and route-attempt count instead of inferring the selected route.
OpenWaya routing request
{
  "model": "openwaya/auto",
  "messages": [{ "role": "user", "content": "Hello from Africa" }],
  "openwaya": {
    "routing_policy": "balanced",
    "stream_fallback_behavior": "terminate"
  }
}

04 / Cutover

Prove equivalence before volume.

Replay a sanitized fixture set in non-production, compare supported response and stream shapes, and verify stable error handling. Reconcile usage and OpenWaya wallet charges independently; do not compare provider-native price displays as if they were the same retail ledger. Canary eligible models first, observe request and route evidence, then widen traffic with the previous gateway available for new-request rollback.

  • Use one unique idempotency key per logical billable operation and preserve it only across identical retries.
  • Avoid nested retry storms by coordinating client retries with OpenWaya route fallback and caller deadlines.
  • Do not replay completed requests during rollback; reconcile by request ID and usage evidence.

Migration checkpoint

Validate against the live contract.