Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

957 B
Raw Blame
/**
 * Concurrency fields copied from a stored connection onto the selected
 * credentials (#13700). Shared by `auth.ts` materializeConnection and the
 * optional no-auth key path so both propagate the same caps. The per-model
 * map is normalized fail-open: a missing or malformed map yields null, which
 * the chat core treats as "no model gate".
 */
import type { ProviderConnectionView } from "@/lib/db/providers/lazyConnectionView";
import { normalizeModelConcurrencyMap } from "@/lib/db/providers/columns";

export function buildConnectionConcurrencyFields(connection: ProviderConnectionView): {
  maxConcurrent: number | null;
  rateLimitMaxConcurrent: number | null;
  modelConcurrency: Record<string, number> | null;
} {
  return {
    maxConcurrent: connection.maxConcurrent,
    rateLimitMaxConcurrent: connection.rateLimitMaxConcurrent,
    modelConcurrency: normalizeModelConcurrencyMap(connection.rateLimitOverrides?.modelConcurrency),
  };
}