LiyaEngine Docs
Platform

Models + Router

Bring your own keys for OpenAI, Anthropic, Gemini, or a custom endpoint — with automatic fallback on provider failure.

Dashboard

Model routing runs automatically inside the engine on every intent call. Configure multiple providers with your own API keys — if your primary provider fails, LiyaEngine falls back to your next configured provider. Same request, same response shape, zero code changes.

Replaces the old BYOK config

This supersedes the older single-provider providerConfig mechanism. The Models + Router API supports multiple named provider credentials with an explicit default and per-provider health checks.

Why bring your own keys

  • Cost control — inference costs hit your own provider account, not a shared pool
  • Data residency — route to a region-scoped endpoint (e.g. Azure OpenAI) to satisfy GDPR/HIPAA requirements
  • Provider preference — choose the model family that suits your use case
  • Resilience — a fallback chain means a single provider outage doesn't take you down

Provider credentials API

GET    /dashboard/models/providers                    # list configured providers
POST   /dashboard/models/providers/:provider           # add or update a provider's credentials
DELETE /dashboard/models/providers/:provider           # remove a provider
POST   /dashboard/models/providers/:provider/default    # set as the default (primary) provider
POST   /dashboard/models/providers/:provider/check      # run a live health check

Add a provider:

POST https://api.liyaengine.ai/dashboard/models/providers/anthropic
Authorization: Bearer <jwt>
Content-Type: application/json

{
  "apiKey": "sk-ant-...",
  "baseUrl": null
}

Keys are AES-256-GCM encrypted before storage. The raw key itself is never returned in any API response — only a masked preview (first 3 and last 4 characters, e.g. sk-...ab12).

List providers:

{
  "success": true,
  "data": {
    "providers": [
      { "provider": "anthropic", "configured": true, "isDefault": true, "keyPreview": "sk-...ab12", "lastValidatedAt": "2026-08-20T10:00:00Z", "lastHealthStatus": "healthy" },
      { "provider": "openai", "configured": true, "isDefault": false, "keyPreview": "sk-...cd34", "lastValidatedAt": "2026-08-20T10:00:00Z", "lastHealthStatus": "healthy" },
      { "provider": "gemini", "configured": false, "isDefault": false, "keyPreview": null, "lastValidatedAt": null, "lastHealthStatus": null }
    ]
  }
}

The list always includes every supported provider slot (openai, anthropic, gemini, azure_openai, bedrock, openrouter, custom) — configured tells you which ones actually have a saved credential.

How fallback works

  1. The engine calls your default provider first
  2. On any error — including auth failures — it immediately retries the next configured provider in order
  3. The whole retry happens inside the same request; your application sees one response either way

No retries to write, no error handling to build. Custom endpoints (OpenAI-compatible) are supported via baseUrl for self-hosted or fine-tuned model deployments.

On this page