Skip to content
Studeia Docs

Multi-provider AI: pick the model, never get locked in

Studeia is multi-provider by default: admins choose the model per task (Claude, GPT, Grok, Gemini) via TenantTaskModelConfig, with an automatic fallback chain, circuit breaker, BYO keys and metering.

2026-05-31 6 min
Resposta curta

Studeia is multi-provider by default. Every LLM-backed feature goes through an internal LLM Router that selects a provider+model per task via TenantTaskModelConfig — admins switch between Claude, GPT, Grok and Gemini without breaking any agent (tool calling works across providers via the Vercel AI SDK). A fallback chain with a Redis-backed circuit breaker handles outages, tenants can bring their own encrypted API keys (costs go to their account, no AI margin), and every call is metered.

How model selection works

The LLM Router (packages/core/src/ai/router.ts) resolves the provider and model for each call from TenantTaskModelConfig, keyed by task type:

Task typeTypical default
chat_tutorSonnet-class
chat_evaluation / summarization / supervisorHaiku-class
content_generationHaiku-class
course_review / course_agent / gamification_agentSonnet-class

An institution admin can override any task to a different provider/model. No model IDs are hardcoded in agents — the router is the single decision point.

Router methods

  • stream() — streaming chat (metered).
  • generate() — agents with tools (metered); tools are converted from JSON Schema to the AI SDK format so they work on any provider.
  • generateDirect() — background, fire-and-forget calls (evaluation, content, summarizer, supervisor) that run in Next.js after() without the full metering pipeline.

Fallback chain + circuit breaker

By tier: Claude → GPT → Grok → Gemini (LLMs); Voyage → OpenAI → Cohere (embeddings). A circuit breaker stored in Redis trips after a failure threshold and is shared across instances, so an open breaker skips a failing provider with no timeout. Incidents are recorded for observability.

Bring-your-own keys + metering

  • Per-tenant keys (TenantApiKey) are encrypted AES-256-GCM. Resolution order: tenant key → global provider key → environment variable.
  • Every LLM call passes through the metering middleware (rate limit → credit check → cost calculation), recording input and output tokens separately. Prices come from a database table, never hardcoded.

Why it matters

You are not betting your platform on one lab's pricing, latency or availability. As models improve, you switch a dropdown — not your codebase.

See also

FAQ

Is Studeia locked into one AI vendor?

No. Every LLM-backed feature routes through an internal LLM Router that selects a provider+model per task type. Admins can switch a task from Anthropic Claude to OpenAI GPT, xAI Grok or Google Gemini without breaking any agent — tool calling works across providers via the Vercel AI SDK. If the primary provider fails, an automatic fallback chain takes over.

Can an institution use its own API keys?

Yes. Each tenant can store its own provider keys (TenantApiKey, encrypted AES-256-GCM). When a tenant brings its own key, AI costs go directly to that tenant's provider account — Studeia does not add an AI margin and never sets process.env (which would leak across tenants); the key is passed per request.

What stops a provider outage from taking down the tutor?

A circuit breaker (state in Redis, shared across instances) trips after repeated failures and skips straight to the next provider in the fallback chain, so a single vendor outage degrades gracefully instead of failing the request. Every fallback is logged as a provider incident.

Veja tambem

Multi-provider AI: pick the model, never get locked in