7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.
TypeScript
fix(keys): add a key to a custom endpoint without registering a model (#702) (#706)
Tashfeen8c4c430070fc
diff --git a/client/src/components/keys/add-endpoint-key-dialog.tsx b/client/src/components/keys/add-endpoint-key-dialog.tsxnew file mode 100644index 00000000..f68d9056--- /dev/null+++ b/client/src/components/keys/add-endpoint-key-dialog.tsx@@ -0,0 +1,102 @@+import { useState, type FormEvent } from 'react'+import { useMutation, useQueryClient } from '@tanstack/react-query'+import { apiFetch } from '@/lib/api'+import { Button } from '@/components/ui/button'+import { Dialog, DialogPopup, DialogTitle } from '@/components/ui/dialog'+import { Input } from '@/components/ui/input'+import { Label } from '@/components/ui/label'+import { useI18n } from '@/i18n'+import { toast } from '@/lib/toast'++// #702: a custom endpoint pools several credentials (#619), but the only way to+// register one was the model form, which insists on a model id. Once every model+// an endpoint serves is already registered there is nothing left to name there,+// so adding a second key needs its own door. Models belong to the endpoint, not+// to the key, so this form asks for the credential and nothing else.++export function AddEndpointKeyDialog({+ open,+ onOpenChange,+ baseUrl,+}: {+ open: boolean+ onOpenChange: (open: boolean) => void+ baseUrl: string+}) {+ const { t } = useI18n()+ const queryClient = useQueryClient()+ // Mounted only while open, so every open starts with an empty field and no+ // reset effect is needed.+ const [apiKey, setApiKey] = useState('')+ const [label, setLabel] = useState('')++ const addKey = useMutation({+ meta: { silenceToast: true },+ mutationFn: () => apiFetch('/api/keys/custom', {+ method: 'POST',+ body: JSON.stringify({ baseUrl, apiKey, label: label.trim() || undefined }),+ }),+ onSuccess: () => {+ for (const key of ['keys', 'health']) {+ queryClient.invalidateQueries({ queryKey: [key] })+ }+ toast.success(t('keys.keyAdded'))+ onOpenChange(false)+ },+ })++ const submit = (e: FormEvent) => {+ e.preventDefault()+ if (!apiKey.trim()) return+ addKey.mutate()+ }++ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogPopup maxWidth="max-w-md">+ <DialogTitle>{t('keys.addKey')}</DialogTitle>+ <p className="mt-1 text-xs text-muted-foreground">{t('keys.endpointKeysShareModels')}</p>+ <code className="mt-2 block truncate font-mono text-[11px] text-muted-foreground" title={baseUrl}>+ {baseUrl}+ </code>++ <form onSubmit={submit} className="mt-4 space-y-4">+ <div className="space-y-1.5">+ <Label className="text-xs" htmlFor="endpoint-key">{t('keys.customApiKey')}</Label>+ <Input+ id="endpoint-key"+ type="password"+ autoFocus+ value={apiKey}+ onChange={e => setApiKey(e.target.value)}+ placeholder={t('keys.pasteKeyPlaceholder')}+ className="font-mono text-xs"+ />+ </div>+ <div className="space-y-1.5">+ <Label className="text-xs" htmlFor="endpoint-key-label">{t('keys.label')}</Label>+ <Input+ id="endpoint-key-label"+ value={label}+ onChange={e => setLabel(e.target.value)}+ placeholder={t('keys.customDisplayNameOptional')}+ />+ </div>++ {addKey.isError && (+ <p className="text-xs text-destructive">{(addKey.error as Error).message}</p>+ )}++ <div className="flex items-center justify-end gap-2">+ <Button type="button" variant="outline" size="sm" onClick={() => onOpenChange(false)}>+ {t('common.cancel')}+ </Button>+ <Button type="submit" size="sm" disabled={!apiKey.trim() || addKey.isPending}>+ {addKey.isPending ? t('keys.adding') : t('keys.addKey')}+ </Button>+ </div>+ </form>+ </DialogPopup>+ </Dialog>+ )+}diff --git a/client/src/components/keys/provider-list.tsx b/client/src/components/keys/provider-list.tsxindex 48e41300..3e6cb6fa 100644--- a/client/src/components/keys/provider-list.tsx+++ b/client/src/components/keys/provider-list.tsx@@ -32,6 +32,7 @@ import {} from './shared'import type { HealthData } from './shared'import { DiscoverModelsDialog } from './discover-models-dialog'+import { AddEndpointKeyDialog } from './add-endpoint-key-dialog'type StatusFilter = 'all' | 'healthy' | 'issues' | 'disabled'@@ -52,6 +53,10 @@ export function ProviderList({ onAddKey }: { onAddKey: () => void }) {// Custom endpoint whose model list is being fetched (#488) — relays change// what they serve constantly, so this is a repeat action, not a one-off.const [discoverKeyId, setDiscoverKeyId] = useState<number | null>(null)+ // Custom endpoint taking another credential (#702). Keyed by base URL, since+ // a key joins the pool of an endpoint rather than of the row it was opened+ // from, and every key of that endpoint offers the same action.+ const [addKeyBaseUrl, setAddKeyBaseUrl] = useState<string | null>(null)const editInputRef = useRef<HTMLInputElement>(null)const { data: keys = [], isLoading } = useQuery<ApiKey[]>({@@ -418,16 +423,28 @@ export function ProviderList({ onAddKey }: { onAddKey: () => void }) {</Button>)}{k.platform === 'custom' && k.baseUrl && (- <Tooltip text={t('keys.discoverModels')}>- <Button- variant="ghost"- size="icon-xs"- onClick={() => setDiscoverKeyId(k.id)}- aria-label={t('keys.discoverModels')}- >- <ListPlus className="size-3" />- </Button>- </Tooltip>+ <>+ <Tooltip text={t('keys.addKey')}>+ <Button+ variant="ghost"+ size="icon-xs"+ onClick={() => setAddKeyBaseUrl(k.baseUrl!)}+ aria-label={t('keys.addKey')}+ >+ <KeyRound className="size-3" />+ </Button>+ </Tooltip>+ <Tooltip text={t('keys.discoverModels')}>+ <Button+ variant="ghost"+ size="icon-xs"+ onClick={() => setDiscoverKeyId(k.id)}+ aria-label={t('keys.discoverModels')}+ >+ <ListPlus className="size-3" />+ </Button>+ </Tooltip>+ </>)}<Tooltip text={t('keys.checkNow')}><Button@@ -510,6 +527,14 @@ export function ProviderList({ onAddKey }: { onAddKey: () => void }) {endpoint={{ keyId: discoverKeyId }}/>)}++ {addKeyBaseUrl !== null && (+ <AddEndpointKeyDialog+ open+ onOpenChange={(open) => { if (!open) setAddKeyBaseUrl(null) }}+ baseUrl={addKeyBaseUrl}+ />+ )}</div>)}diff --git a/client/src/i18n/locales/am.json b/client/src/i18n/locales/am.jsonindex b4f59d04..82047eb2 100644--- a/client/src/i18n/locales/am.json+++ b/client/src/i18n/locales/am.json@@ -325,6 +325,7 @@"selectPlatform": "አቅራቢ ይምረጡ","addKey": "ቁልፍ አክል","keyAdded": "ቁልፍ ታክሏል",+ "endpointKeysShareModels": "የአንድ መዳረሻ ቁልፎች ተመሳሳይ ሞዴሎችን ይጋራሉ።","export": "ወደ ውጪ መላክ","exportAll": "ሁሉም ቁልፎች","exportHealthy": "ጤናማ ብቻ",diff --git a/client/src/i18n/locales/ar.json b/client/src/i18n/locales/ar.jsonindex 816f6884..fce53dc5 100644--- a/client/src/i18n/locales/ar.json+++ b/client/src/i18n/locales/ar.json@@ -325,6 +325,7 @@"selectPlatform": "حدد مزودًا","addKey": "إضافة مفتاح","keyAdded": "تمت إضافة المفتاح",+ "endpointKeysShareModels": "المفاتيح لنقطة النهاية نفسها تتشارك نماذجها.","export": "تصدير","exportAll": "جميع المفاتيح","exportHealthy": "صحي فقط",diff --git a/client/src/i18n/locales/az.json b/client/src/i18n/locales/az.jsonindex 9cf520dd..3d126afe 100644--- a/client/src/i18n/locales/az.json+++ b/client/src/i18n/locales/az.json@@ -325,6 +325,7 @@"selectPlatform": "Təminatçı seçin","addKey": "Açar əlavə et","keyAdded": "Açar əlavə edildi",+ "endpointKeysShareModels": "Eyni son nöqtənin açarları onun modellərini paylaşır.","export": "İxrac","exportAll": "Bütün açarlar","exportHealthy": "Yalnız sağlam",diff --git a/client/src/i18n/locales/bg.json b/client/src/i18n/locales/bg.jsonindex 8c662939..6e6b5dea 100644--- a/client/src/i18n/locales/bg.json+++ b/client/src/i18n/locales/bg.json@@ -325,6 +325,7 @@"selectPlatform": "Изберете доставчик","addKey": "Добави ключ","keyAdded": "Добавен ключ",+ "endpointKeysShareModels": "Ключовете за една и съща крайна точка споделят нейните модели.","export": "Износ","exportAll": "Всички клавиши","exportHealthy": "Само здравословно",diff --git a/client/src/i18n/locales/bn.json b/client/src/i18n/locales/bn.jsonindex 1ec60f54..971f82ca 100644--- a/client/src/i18n/locales/bn.json+++ b/client/src/i18n/locales/bn.json@@ -325,6 +325,7 @@"selectPlatform": "একটি প্রদানকারী নির্বাচন করুন","addKey": "কী যোগ করুন","keyAdded": "কী যোগ করা হয়েছে",+ "endpointKeysShareModels": "একই এন্ডপয়েন্টের কীগুলি একই মডেল ভাগ করে।","export": "রপ্তানি","exportAll": "সব কী","exportHealthy": "শুধুমাত্র স্বাস্থ্যকর",diff --git a/client/src/i18n/locales/cs.json b/client/src/i18n/locales/cs.jsonindex 0b5d80fe..52e588d9 100644--- a/client/src/i18n/locales/cs.json+++ b/client/src/i18n/locales/cs.json@@ -325,6 +325,7 @@"selectPlatform": "Vyberte poskytovatele","addKey": "Přidat klíč","keyAdded": "Klíč přidán",+ "endpointKeysShareModels": "Klíče stejného endpointu sdílejí jeho modely.","export": "Export","exportAll": "Všechny tóniny","exportHealthy": "Pouze zdravé",diff --git a/client/src/i18n/locales/da.json b/client/src/i18n/locales/da.jsonindex 5027c986..7e8f8588 100644--- a/client/src/i18n/locales/da.json+++ b/client/src/i18n/locales/da.json@@ -325,6 +325,7 @@"selectPlatform": "Vælg en udbyder","addKey": "Tilføj nøgle","keyAdded": "Nøgle tilføjet",+ "endpointKeysShareModels": "Nøgler til det samme endpoint deler dets modeller.","export": "Eksport","exportAll": "Alle nøgler","exportHealthy": "Kun sundt",diff --git a/client/src/i18n/locales/de.json b/client/src/i18n/locales/de.jsonindex ea83f111..aee3547f 100644--- a/client/src/i18n/locales/de.json+++ b/client/src/i18n/locales/de.json@@ -325,6 +325,7 @@"selectPlatform": "Wählen Sie einen Anbieter aus","addKey": "Schlüssel hinzufügen","keyAdded": "Schlüssel hinzugefügt",+ "endpointKeysShareModels": "Schlüssel desselben Endpunkts teilen sich dessen Modelle.","export": "Exportieren","exportAll": "Alle Schlüssel","exportHealthy": "Nur gesund",diff --git a/client/src/i18n/locales/el.json b/client/src/i18n/locales/el.jsonindex 00fea1b5..2a748a18 100644--- a/client/src/i18n/locales/el.json+++ b/client/src/i18n/locales/el.json@@ -325,6 +325,7 @@"selectPlatform": "Επιλέξτε έναν πάροχο","addKey": "Προσθήκη κλειδιού","keyAdded": "Προστέθηκε κλειδί",+ "endpointKeysShareModels": "Τα κλειδιά του ίδιου endpoint μοιράζονται τα μοντέλα του.","export": "Εξαγωγή","exportAll": "Όλα τα κλειδιά","exportHealthy": "Μόνο υγιεινά",diff --git a/client/src/i18n/locales/en.json b/client/src/i18n/locales/en.jsonindex d9270e43..1141e0f4 100644--- a/client/src/i18n/locales/en.json+++ b/client/src/i18n/locales/en.json@@ -347,6 +347,7 @@"selectPlatform": "Select a provider","addKey": "Add key","keyAdded": "Key added",+ "endpointKeysShareModels": "Keys for the same endpoint share its models.","export": "Export","exportAll": "All keys","exportHealthy": "Healthy only",diff --git a/client/src/i18n/locales/es.json b/client/src/i18n/locales/es.jsonindex 6bded779..c4c24ec2 100644--- a/client/src/i18n/locales/es.json+++ b/client/src/i18n/locales/es.json@@ -325,6 +325,7 @@"selectPlatform": "Selecciona un proveedor","addKey": "Añadir clave","keyAdded": "Clave añadida",+ "endpointKeysShareModels": "Las claves del mismo endpoint comparten sus modelos.","export": "Exportar","exportAll": "All keys","exportHealthy": "Healthy only",diff --git a/client/src/i18n/locales/fa.json b/client/src/i18n/locales/fa.jsonindex 2a53b9db..bd2f0f11 100644--- a/client/src/i18n/locales/fa.json+++ b/client/src/i18n/locales/fa.json@@ -325,6 +325,7 @@"selectPlatform": "ارائه دهنده ای را انتخاب کنید","addKey": "کلید اضافه کنید","keyAdded": "کلید اضافه شد",+ "endpointKeysShareModels": "کلیدهای یک نقطه پایانی، مدلهای آن را به اشتراک میگذارند.","export": "صادرات","exportAll": "همه کلیدها","exportHealthy": "فقط سالم",diff --git a/client/src/i18n/locales/fi.json b/client/src/i18n/locales/fi.jsonindex d7b6ddf5..826eb4c8 100644--- a/client/src/i18n/locales/fi.json+++ b/client/src/i18n/locales/fi.json@@ -325,6 +325,7 @@"selectPlatform": "Valitse palveluntarjoaja","addKey": "Lisää avain","keyAdded": "Avain lisätty",+ "endpointKeysShareModels": "Saman päätepisteen avaimet jakavat sen mallit.","export": "Vienti","exportAll": "Kaikki avaimet","exportHealthy": "Vain terveellisiä",diff --git a/client/src/i18n/locales/fr.json b/client/src/i18n/locales/fr.jsonindex 6e5fdd69..e0d6c4e0 100644--- a/client/src/i18n/locales/fr.json+++ b/client/src/i18n/locales/fr.json@@ -325,6 +325,7 @@"selectPlatform": "Sélectionner un fournisseur","addKey": "Ajouter une clé","keyAdded": "Clé ajoutée",+ "endpointKeysShareModels": "Les clés d'un même endpoint partagent ses modèles.","export": "Exporter","exportAll": "All keys","exportHealthy": "Healthy only",diff --git a/client/src/i18n/locales/gu.json b/client/src/i18n/locales/gu.jsonindex ac21d2c2..0bcfef1d 100644--- a/client/src/i18n/locales/gu.json+++ b/client/src/i18n/locales/gu.json@@ -325,6 +325,7 @@"selectPlatform": "પ્રદાતા પસંદ કરો","addKey": "કી ઉમેરો","keyAdded": "કી ઉમેરી",+ "endpointKeysShareModels": "એક જ એન્ડપોઇન્ટની કી તેના મોડેલ વહેંચે છે.","export": "નિકાસ કરો","exportAll": "બધી કીઓ","exportHealthy": "માત્ર સ્વસ્થ",diff --git a/client/src/i18n/locales/ha.json b/client/src/i18n/locales/ha.jsonindex ef7381b2..497e12cc 100644--- a/client/src/i18n/locales/ha.json+++ b/client/src/i18n/locales/ha.json@@ -325,6 +325,7 @@"selectPlatform": "Zaɓi mai bayarwa","addKey": "Ƙara maɓalli","keyAdded": "Key ya kara",+ "endpointKeysShareModels": "Maɓallan matattara ɗaya suna raba samfuranta.","export": "fitarwa","exportAll": "Duk maɓallai","exportHealthy": "Lafiyayyan kawai",diff --git a/client/src/i18n/locales/he.json b/client/src/i18n/locales/he.jsonindex cdff70cd..13ec993b 100644--- a/client/src/i18n/locales/he.json+++ b/client/src/i18n/locales/he.json@@ -325,6 +325,7 @@"selectPlatform": "בחר ספק","addKey": "הוספת מפתח","keyAdded": "מפתח נוסף",+ "endpointKeysShareModels": "מפתחות של אותה נקודת קצה משתפים את המודלים שלה.","export": "יצוא","exportAll": "כל המפתחות","exportHealthy": "בריא בלבד",diff --git a/client/src/i18n/locales/hi.json b/client/src/i18n/locales/hi.jsonindex a24569a4..03922264 100644--- a/client/src/i18n/locales/hi.json+++ b/client/src/i18n/locales/hi.json@@ -325,6 +325,7 @@"selectPlatform": "एक प्रदाता चुनें","addKey": "कुंजी जोड़ें","keyAdded": "कुंजी जोड़ी गई",+ "endpointKeysShareModels": "एक ही एंडपॉइंट की कुंजियाँ उसके मॉडल साझा करती हैं।","export": "निर्यात करें","exportAll": "सभी चाबियाँ","exportHealthy": "केवल स्वस्थ",diff --git a/client/src/i18n/locales/hr.json b/client/src/i18n/locales/hr.jsonindex f633880a..46dd189c 100644--- a/client/src/i18n/locales/hr.json+++ b/client/src/i18n/locales/hr.json@@ -325,6 +325,7 @@"selectPlatform": "Odaberite pružatelja usluga","addKey": "Dodaj ključ","keyAdded": "Ključ dodan",+ "endpointKeysShareModels": "Ključevi iste krajnje točke dijele njezine modele.","export": "Izvoz","exportAll": "Sve tipke","exportHealthy": "Samo za zdravlje",diff --git a/client/src/i18n/locales/hu.json b/client/src/i18n/locales/hu.jsonindex 1b51ed22..a52f52bb 100644--- a/client/src/i18n/locales/hu.json+++ b/client/src/i18n/locales/hu.json@@ -325,6 +325,7 @@"selectPlatform": "Válassz szolgáltatót","addKey": "Add hozzá kulcsot","keyAdded": "Kulcs hozzáadva",+ "endpointKeysShareModels": "Ugyanazon végpont kulcsai közösen használják annak modelljeit.","export": "Export","exportAll": "Minden kulcs","exportHealthy": "Csak egészségesnek",diff --git a/client/src/i18n/locales/id.json b/client/src/i18n/locales/id.jsonindex 0f0f93ee..6addbbd2 100644--- a/client/src/i18n/locales/id.json+++ b/client/src/i18n/locales/id.json@@ -325,6 +325,7 @@"selectPlatform": "Pilih penyedia","addKey": "Tambahkan kunci","keyAdded": "Kunci ditambahkan",+ "endpointKeysShareModels": "Kunci untuk endpoint yang sama berbagi model-modelnya.","export": "Ekspor","exportAll": "Semua kunci","exportHealthy": "Hanya sehat",diff --git a/client/src/i18n/locales/ig.json b/client/src/i18n/locales/ig.jsonindex 5ddc6dcf..38ff4c1c 100644--- a/client/src/i18n/locales/ig.json+++ b/client/src/i18n/locales/ig.json@@ -325,6 +325,7 @@"selectPlatform": "Họrọ onye na-eweta ya","addKey": "Tinye igodo","keyAdded": "Igodo agbakwunyere",+ "endpointKeysShareModels": "Igodo nke otu njedebe na-ekekọrịta ụdị ya.","export": "Mbupụ","exportAll": "Igodo niile","exportHealthy": "Nwere ahụike naanị",diff --git a/client/src/i18n/locales/it.json b/client/src/i18n/locales/it.jsonindex 0d5acd06..59763436 100644--- a/client/src/i18n/locales/it.json+++ b/client/src/i18n/locales/it.json@@ -325,6 +325,7 @@"selectPlatform": "Seleziona un fornitore","addKey": "Aggiungi chiave","keyAdded": "Chiave aggiunta",+ "endpointKeysShareModels": "Le chiavi dello stesso endpoint condividono i suoi modelli.","export": "Esportazione","exportAll": "All keys","exportHealthy": "Healthy only",diff --git a/client/src/i18n/locales/ja.json b/client/src/i18n/locales/ja.jsonindex 67a72818..566024d6 100644--- a/client/src/i18n/locales/ja.json+++ b/client/src/i18n/locales/ja.json@@ -325,6 +325,7 @@"selectPlatform": "プロバイダーを選択してください","addKey": "キーを追加","keyAdded": "キーが追加されました",+ "endpointKeysShareModels": "同じエンドポイントのキーはそのモデルを共有します。","export": "エクスポート","exportAll": "すべてのキー","exportHealthy": "健康のみ",diff --git a/client/src/i18n/locales/ka.json b/client/src/i18n/locales/ka.jsonindex 2f5b6394..a7ad1f35 100644--- a/client/src/i18n/locales/ka.json+++ b/client/src/i18n/locales/ka.json@@ -325,6 +325,7 @@"selectPlatform": "აირჩიეთ პროვაიდერი","addKey": "გასაღების დამატება","keyAdded": "გასაღები დამატებულია",+ "endpointKeysShareModels": "ერთი და იმავე ბოლოწერტილის გასაღებები იზიარებენ მის მოდელებს.","export": "ექსპორტი","exportAll": "ყველა გასაღები","exportHealthy": "მხოლოდ ჯანსაღი",diff --git a/client/src/i18n/locales/km.json b/client/src/i18n/locales/km.jsonindex 14689104..6fa9b7ec 100644--- a/client/src/i18n/locales/km.json+++ b/client/src/i18n/locales/km.json@@ -325,6 +325,7 @@"selectPlatform": "ជ្រើសរើសអ្នកផ្គត់ផ្គង់","addKey": "បន្ថែមកូនសោ","keyAdded": "បានបន្ថែមកូនសោ",+ "endpointKeysShareModels": "កូនសោនៃចំណុចបញ្ចប់តែមួយ ចែករំលែកម៉ូដែលរបស់វា។","export": "នាំចេញ","exportAll": "សោទាំងអស់","exportHealthy": "មានសុខភាពល្អតែប៉ុណ្ណោះ",diff --git a/client/src/i18n/locales/kn.json b/client/src/i18n/locales/kn.jsonindex 20cfe499..09e0a1e8 100644--- a/client/src/i18n/locales/kn.json+++ b/client/src/i18n/locales/kn.json@@ -325,6 +325,7 @@"selectPlatform": "ಒದಗಿಸುವವರನ್ನು ಆಯ್ಕೆಮಾಡಿ","addKey": "ಕೀ ಸೇರಿಸಿ","keyAdded": "ಕೀ ಸೇರಿಸಲಾಗಿದೆ",+ "endpointKeysShareModels": "ಒಂದೇ ಎಂಡ್ಪಾಯಿಂಟ್ನ ಕೀಗಳು ಅದರ ಮಾದರಿಗಳನ್ನು ಹಂಚಿಕೊಳ್ಳುತ್ತವೆ.","export": "ರಫ್ತು ಮಾಡಿ","exportAll": "ಎಲ್ಲಾ ಕೀಲಿಗಳು","exportHealthy": "ಆರೋಗ್ಯಕರ ಮಾತ್ರ",diff --git a/client/src/i18n/locales/ko.json b/client/src/i18n/locales/ko.jsonindex bda69198..91774440 100644--- a/client/src/i18n/locales/ko.json+++ b/client/src/i18n/locales/ko.json@@ -325,6 +325,7 @@"selectPlatform": "제공업체 선택","addKey": "키 추가","keyAdded": "키가 추가됨",+ "endpointKeysShareModels": "같은 엔드포인트의 키는 해당 모델을 공유합니다.","export": "수출","exportAll": "모든 키","exportHealthy": "건강한 것만",diff --git a/client/src/i18n/locales/lt.json b/client/src/i18n/locales/lt.jsonindex 55376dc4..f6cf50f6 100644--- a/client/src/i18n/locales/lt.json+++ b/client/src/i18n/locales/lt.json@@ -325,6 +325,7 @@"selectPlatform": "Pasirinkite paslaugų teikėją","addKey": "Pridėti klavišą","keyAdded": "Pridėtas raktas",+ "endpointKeysShareModels": "To paties galinio taško raktai dalijasi jo modeliais.","export": "Eksportas","exportAll": "Visi raktai","exportHealthy": "Tik sveiki",diff --git a/client/src/i18n/locales/ml.json b/client/src/i18n/locales/ml.jsonindex 0fe92dc3..c133204f 100644--- a/client/src/i18n/locales/ml.json+++ b/client/src/i18n/locales/ml.json@@ -325,6 +325,7 @@"selectPlatform": "ഒരു ദാതാവിനെ തിരഞ്ഞെടുക്കുക","addKey": "കീ ചേർക്കുക","keyAdded": "കീ ചേർത്തു",+ "endpointKeysShareModels": "ഒരേ എൻഡ്പോയിന്റിന്റെ കീകൾ അതിന്റെ മോഡലുകൾ പങ്കിടുന്നു.","export": "കയറ്റുമതി","exportAll": "എല്ലാ കീകളും","exportHealthy": "ആരോഗ്യമുള്ളത് മാത്രം",diff --git a/client/src/i18n/locales/mr.json b/client/src/i18n/locales/mr.jsonindex d488eaab..2ee6221c 100644--- a/client/src/i18n/locales/mr.json+++ b/client/src/i18n/locales/mr.json@@ -325,6 +325,7 @@"selectPlatform": "प्रदाता निवडा","addKey": "की जोडा","keyAdded": "की जोडली",+ "endpointKeysShareModels": "एकाच एंडपॉइंटच्या की त्याचे मॉडेल सामायिक करतात.","export": "निर्यात करा","exportAll": "सर्व कळा","exportHealthy": "फक्त निरोगी",diff --git a/client/src/i18n/locales/ms.json b/client/src/i18n/locales/ms.jsonindex 06a95ad3..59d4d973 100644--- a/client/src/i18n/locales/ms.json+++ b/client/src/i18n/locales/ms.json@@ -325,6 +325,7 @@"selectPlatform": "Pilih penyedia","addKey": "Tambah kekunci","keyAdded": "Kunci ditambah",+ "endpointKeysShareModels": "Kunci untuk endpoint yang sama berkongsi modelnya.","export": "Eksport","exportAll": "Semua kekunci","exportHealthy": "Hanya sihat",diff --git a/client/src/i18n/locales/my.json b/client/src/i18n/locales/my.jsonindex 2a455558..be296bf5 100644--- a/client/src/i18n/locales/my.json+++ b/client/src/i18n/locales/my.json@@ -325,6 +325,7 @@"selectPlatform": "ပံ့ပိုးသူတစ်ဦးကို ရွေးချယ်ပါ","addKey": "သော့ထည့်ပါ","keyAdded": "သော့ချက် ထည့်သွင်းပြီးပါပြီ",+ "endpointKeysShareModels": "တူညီသောအဆုံးမှတ်၏ သော့များသည် ၎င်း၏မော်ဒယ်များကို မျှဝေသုံးသည်။","export": "တင်ပို့ခြင်း","exportAll": "သော့အားလုံး","exportHealthy": "ကျန်းမာသက်သာသော",diff --git a/client/src/i18n/locales/ne.json b/client/src/i18n/locales/ne.jsonindex a8536774..fcc85628 100644--- a/client/src/i18n/locales/ne.json+++ b/client/src/i18n/locales/ne.json@@ -325,6 +325,7 @@"selectPlatform": "प्रदायक चयन गर्नुहोस्","addKey": "कुञ्जी थप्नुहोस्","keyAdded": "कुञ्जी थपियो",+ "endpointKeysShareModels": "एउटै एन्डपोइन्टका कुञ्जीहरूले त्यसका मोडेलहरू साझा गर्छन्।","export": "निर्यात गर्नुहोस्","exportAll": "सबै कुञ्जीहरू","exportHealthy": "स्वस्थ मात्र",diff --git a/client/src/i18n/locales/nl.json b/client/src/i18n/locales/nl.jsonindex 11660e88..49f1a10d 100644--- a/client/src/i18n/locales/nl.json+++ b/client/src/i18n/locales/nl.json@@ -325,6 +325,7 @@"selectPlatform": "Selecteer een aanbieder","addKey": "Voeg sleutel toe","keyAdded": "Sleutel toegevoegd",+ "endpointKeysShareModels": "Sleutels voor hetzelfde endpoint delen de modellen ervan.","export": "Export","exportAll": "Alle sleutels","exportHealthy": "Alleen gezond",diff --git a/client/src/i18n/locales/no.json b/client/src/i18n/locales/no.jsonindex 4782d826..80237dc0 100644--- a/client/src/i18n/locales/no.json+++ b/client/src/i18n/locales/no.json@@ -325,6 +325,7 @@"selectPlatform": "Velg en leverandør","addKey": "Legg til nøkkel","keyAdded": "Nøkkel lagt til",+ "endpointKeysShareModels": "Nøkler for det samme endepunktet deler modellene dets.","export": "Eksport","exportAll": "Alle nøkler","exportHealthy": "Kun sunt",diff --git a/client/src/i18n/locales/or.json b/client/src/i18n/locales/or.jsonindex 447b515b..e9071523 100644--- a/client/src/i18n/locales/or.json+++ b/client/src/i18n/locales/or.json@@ -325,6 +325,7 @@"selectPlatform": "ଏକ ପ୍ରଦାନକାରୀ ଚୟନ କରନ୍ତୁ","addKey": "କୀ ଯୋଡନ୍ତୁ","keyAdded": "କୀ ଯୋଡାଯାଇଛି",+ "endpointKeysShareModels": "ସମାନ ଏଣ୍ଡପଏଣ୍ଟର କୀଗୁଡିକ ଏହାର ମଡେଲ ସେୟାର କରନ୍ତି।","export": "ରପ୍ତାନୀ","exportAll": "ସମସ୍ତ ଚାବି","exportHealthy": "କେବଳ ସୁସ୍ଥ",diff --git a/client/src/i18n/locales/pa.json b/client/src/i18n/locales/pa.jsonindex 84dc9392..b4574470 100644--- a/client/src/i18n/locales/pa.json+++ b/client/src/i18n/locales/pa.json@@ -325,6 +325,7 @@"selectPlatform": "ਇੱਕ ਪ੍ਰਦਾਤਾ ਚੁਣੋ","addKey": "ਕੁੰਜੀ ਸ਼ਾਮਲ ਕਰੋ","keyAdded": "ਕੁੰਜੀ ਸ਼ਾਮਲ ਕੀਤੀ ਗਈ",+ "endpointKeysShareModels": "ਇੱਕੋ ਐਂਡਪੌਇੰਟ ਦੀਆਂ ਕੁੰਜੀਆਂ ਇਸਦੇ ਮਾਡਲ ਸਾਂਝੇ ਕਰਦੀਆਂ ਹਨ।","export": "ਨਿਰਯਾਤ","exportAll": "ਸਾਰੀਆਂ ਕੁੰਜੀਆਂ","exportHealthy": "ਸਿਰਫ਼ ਸਿਹਤਮੰਦ",diff --git a/client/src/i18n/locales/pl.json b/client/src/i18n/locales/pl.jsonindex 6718948a..5162b336 100644--- a/client/src/i18n/locales/pl.json+++ b/client/src/i18n/locales/pl.json@@ -325,6 +325,7 @@"selectPlatform": "Wybierz dostawcę","addKey": "Dodaj klucz","keyAdded": "Dodano klucz",+ "endpointKeysShareModels": "Klucze tego samego punktu końcowego współdzielą jego modele.","export": "Eksportuj","exportAll": "Wszystkie klucze","exportHealthy": "Tylko zdrowe",diff --git a/client/src/i18n/locales/pt-BR.json b/client/src/i18n/locales/pt-BR.jsonindex aed390e3..0d59d614 100644--- a/client/src/i18n/locales/pt-BR.json+++ b/client/src/i18n/locales/pt-BR.json@@ -325,6 +325,7 @@"selectPlatform": "Selecione um provedor","addKey": "Adicionar chave","keyAdded": "Chave adicionada",+ "endpointKeysShareModels": "As chaves do mesmo endpoint compartilham seus modelos.","export": "Exportar","exportAll": "All keys","exportHealthy": "Healthy only",diff --git a/client/src/i18n/locales/pt-PT.json b/client/src/i18n/locales/pt-PT.jsonindex cdc678f4..d5d6431c 100644--- a/client/src/i18n/locales/pt-PT.json+++ b/client/src/i18n/locales/pt-PT.json@@ -325,6 +325,7 @@"selectPlatform": "Selecione um fornecedor","addKey": "Adicionar a tecla","keyAdded": "Chave adicionada",+ "endpointKeysShareModels": "As chaves do mesmo endpoint partilham os seus modelos.","export": "Exportação","exportAll": "Todas as tonalidades","exportHealthy": "Apenas saudável",diff --git a/client/src/i18n/locales/ro.json b/client/src/i18n/locales/ro.jsonindex 305c3238..d175df55 100644--- a/client/src/i18n/locales/ro.json+++ b/client/src/i18n/locales/ro.json@@ -325,6 +325,7 @@"selectPlatform": "Alege un furnizor","addKey": "Tonul de adăugare","keyAdded": "Cheia adăugată",+ "endpointKeysShareModels": "Cheile aceluiași endpoint partajează modelele acestuia.","export": "Export","exportAll": "Toate cheile","exportHealthy": "Doar sănătos",diff --git a/client/src/i18n/locales/ru.json b/client/src/i18n/locales/ru.jsonindex 072f7b9f..c66e9802 100644--- a/client/src/i18n/locales/ru.json+++ b/client/src/i18n/locales/ru.json@@ -325,6 +325,7 @@"selectPlatform": "Выберите провайдера","addKey": "Добавить ключ","keyAdded": "Ключ добавлен",+ "endpointKeysShareModels": "Ключи одной точки доступа используют одни и те же модели.","export": "Экспорт","exportAll": "Все ключи","exportHealthy": "Только здоровый",diff --git a/client/src/i18n/locales/si.json b/client/src/i18n/locales/si.jsonindex 5f008651..10ceedf4 100644--- a/client/src/i18n/locales/si.json+++ b/client/src/i18n/locales/si.json@@ -325,6 +325,7 @@"selectPlatform": "සපයන්නෙකු තෝරන්න","addKey": "යතුර එකතු කරන්න","keyAdded": "යතුර එකතු කරන ලදී",+ "endpointKeysShareModels": "එකම අන්තයේ යතුරු එහි ආකෘති බෙදා ගනී.","export": "අපනයනය කරන්න","exportAll": "සියලුම යතුරු","exportHealthy": "සෞඛ්ය සම්පන්න පමණි",diff --git a/client/src/i18n/locales/sk.json b/client/src/i18n/locales/sk.jsonindex 34c8fa53..15de3ad9 100644--- a/client/src/i18n/locales/sk.json+++ b/client/src/i18n/locales/sk.json@@ -325,6 +325,7 @@"selectPlatform": "Vyberte si poskytovateľa","addKey": "Pridať kľúč","keyAdded": "Kľúč pridaný",+ "endpointKeysShareModels": "Kľúče toho istého endpointu zdieľajú jeho modely.","export": "Export","exportAll": "Všetky tóniny","exportHealthy": "Len zdravé",diff --git a/client/src/i18n/locales/sr.json b/client/src/i18n/locales/sr.jsonindex b3838061..afa80af2 100644--- a/client/src/i18n/locales/sr.json+++ b/client/src/i18n/locales/sr.json@@ -325,6 +325,7 @@"selectPlatform": "Изаберите провајдера","addKey": "Додај кључ","keyAdded": "Кључ је додат",+ "endpointKeysShareModels": "Кључеви исте крајње тачке деле њене моделе.","export": "Извоз","exportAll": "Сви кључеви","exportHealthy": "Само здраво",diff --git a/client/src/i18n/locales/sv.json b/client/src/i18n/locales/sv.jsonindex 5b1b5f40..61529759 100644--- a/client/src/i18n/locales/sv.json+++ b/client/src/i18n/locales/sv.json@@ -325,6 +325,7 @@"selectPlatform": "Välj en leverantör","addKey": "Lägg till nyckel","keyAdded": "Nyckel tillagd",+ "endpointKeysShareModels": "Nycklar för samma endpoint delar dess modeller.","export": "Export","exportAll": "Alla nycklar","exportHealthy": "Endast hälsosamt",diff --git a/client/src/i18n/locales/sw.json b/client/src/i18n/locales/sw.jsonindex 998e6374..863d7be0 100644--- a/client/src/i18n/locales/sw.json+++ b/client/src/i18n/locales/sw.json@@ -325,6 +325,7 @@"selectPlatform": "Chagua mtoaji","addKey": "Ongeza ufunguo","keyAdded": "Ufunguo umeongezwa",+ "endpointKeysShareModels": "Vitufe vya mwisho huo huo hushiriki modeli zake.","export": "Hamisha","exportAll": "Vifunguo vyote","exportHealthy": "Afya tu",diff --git a/client/src/i18n/locales/ta.json b/client/src/i18n/locales/ta.jsonindex 016b6945..e3bd992a 100644--- a/client/src/i18n/locales/ta.json+++ b/client/src/i18n/locales/ta.json@@ -325,6 +325,7 @@"selectPlatform": "வழங்குநரைத் தேர்ந்தெடுக்கவும்","addKey": "விசையைச் சேர்க்கவும்","keyAdded": "விசை சேர்க்கப்பட்டது",+ "endpointKeysShareModels": "ஒரே எண்ட்பாயிண்டின் விசைகள் அதன் மாதிரிகளைப் பகிர்ந்து கொள்கின்றன.","export": "ஏற்றுமதி","exportAll": "அனைத்து விசைகளும்","exportHealthy": "ஆரோக்கியமானது மட்டுமே",diff --git a/client/src/i18n/locales/te.json b/client/src/i18n/locales/te.jsonindex b40c6192..8d221a59 100644--- a/client/src/i18n/locales/te.json+++ b/client/src/i18n/locales/te.json@@ -325,6 +325,7 @@"selectPlatform": "ప్రొవైడర్ను ఎంచుకోండి","addKey": "కీని జోడించండి","keyAdded": "కీ జోడించబడింది",+ "endpointKeysShareModels": "ఒకే ఎండ్పాయింట్ కీలు దాని మోడల్లను పంచుకుంటాయి.","export": "ఎగుమతి చేయండి","exportAll": "అన్ని కీలు","exportHealthy": "ఆరోగ్యకరమైనది మాత్రమే",diff --git a/client/src/i18n/locales/th.json b/client/src/i18n/locales/th.jsonindex 44d13528..a8966365 100644--- a/client/src/i18n/locales/th.json+++ b/client/src/i18n/locales/th.json@@ -325,6 +325,7 @@"selectPlatform": "เลือกผู้ให้บริการ","addKey": "เพิ่มรหัส","keyAdded": "เพิ่มคีย์แล้ว",+ "endpointKeysShareModels": "คีย์ของเอนด์พอยต์เดียวกันใช้โมเดลร่วมกัน","export": "ส่งออก","exportAll": "กุญแจทั้งหมด","exportHealthy": "ดีต่อสุขภาพเท่านั้น",diff --git a/client/src/i18n/locales/tl.json b/client/src/i18n/locales/tl.jsonindex f54207da..6d1c1fa3 100644--- a/client/src/i18n/locales/tl.json+++ b/client/src/i18n/locales/tl.json@@ -325,6 +325,7 @@"selectPlatform": "Pumili ng provider","addKey": "Add key","keyAdded": "Idinagdag ang susi",+ "endpointKeysShareModels": "Ang mga susi ng parehong endpoint ay nagbabahagi ng mga modelo nito.","export": "Pag-export","exportAll": "Lahat ng susi","exportHealthy": "Malusog lamang",diff --git a/client/src/i18n/locales/tr.json b/client/src/i18n/locales/tr.jsonindex 5538003f..34748263 100644--- a/client/src/i18n/locales/tr.json+++ b/client/src/i18n/locales/tr.json@@ -325,6 +325,7 @@"selectPlatform": "Bir sağlayıcı seçin","addKey": "Anahtar ekle","keyAdded": "Anahtar eklendi",+ "endpointKeysShareModels": "Aynı uç noktanın anahtarları onun modellerini paylaşır.","export": "İhracat","exportAll": "Tüm tuşlar","exportHealthy": "Yalnızca sağlıklı",diff --git a/client/src/i18n/locales/uk.json b/client/src/i18n/locales/uk.jsonindex 61796158..397e47c2 100644--- a/client/src/i18n/locales/uk.json+++ b/client/src/i18n/locales/uk.json@@ -325,6 +325,7 @@"selectPlatform": "Виберіть провайдера","addKey": "Додати ключ","keyAdded": "Ключ додано",+ "endpointKeysShareModels": "Ключі однієї кінцевої точки спільно використовують її моделі.","export": "Експорт","exportAll": "Всі ключі","exportHealthy": "Тільки здорові",diff --git a/client/src/i18n/locales/ur.json b/client/src/i18n/locales/ur.jsonindex b0454b93..e3af23ec 100644--- a/client/src/i18n/locales/ur.json+++ b/client/src/i18n/locales/ur.json@@ -325,6 +325,7 @@"selectPlatform": "ایک فراہم کنندہ کو منتخب کریں۔","addKey": "کلید شامل کریں۔","keyAdded": "کلید شامل کی گئی۔",+ "endpointKeysShareModels": "ایک ہی اینڈ پوائنٹ کی کلیدیں اس کے ماڈلز میں شریک ہوتی ہیں۔","export": "برآمد کریں۔","exportAll": "تمام چابیاں","exportHealthy": "صرف صحت مند",diff --git a/client/src/i18n/locales/uz.json b/client/src/i18n/locales/uz.jsonindex d23e0b0f..ed6014ee 100644--- a/client/src/i18n/locales/uz.json+++ b/client/src/i18n/locales/uz.json@@ -325,6 +325,7 @@"selectPlatform": "Provayderni tanlang","addKey": "Kalit qo'shing","keyAdded": "Kalit qo'shildi",+ "endpointKeysShareModels": "Bir xil endpoint kalitlari uning modellarini baham ko'radi.","export": "Eksport","exportAll": "Barcha kalitlar","exportHealthy": "Faqat sog'lom",diff --git a/client/src/i18n/locales/vi.json b/client/src/i18n/locales/vi.jsonindex 98285c2f..a723578d 100644--- a/client/src/i18n/locales/vi.json+++ b/client/src/i18n/locales/vi.json@@ -325,6 +325,7 @@"selectPlatform": "Chọn nhà cung cấp","addKey": "Thêm khóa","keyAdded": "Đã thêm khóa",+ "endpointKeysShareModels": "Các khóa của cùng một endpoint dùng chung các mô hình của nó.","export": "Xuất khẩu","exportAll": "Tất cả các phím","exportHealthy": "Chỉ khỏe mạnh",diff --git a/client/src/i18n/locales/yo.json b/client/src/i18n/locales/yo.jsonindex 3fd407c9..be9ad043 100644--- a/client/src/i18n/locales/yo.json+++ b/client/src/i18n/locales/yo.json@@ -325,6 +325,7 @@"selectPlatform": "Yan olupese kan","addKey": "Fi bọtini kun","keyAdded": "Bọtini kun",+ "endpointKeysShareModels": "Àwọn bọtini ibùdó kan náà pín àwọn àwòṣe rẹ̀.","export": "Si ilẹ okeere","exportAll": "Gbogbo awọn bọtini","exportHealthy": "Ni ilera nikan",diff --git a/client/src/i18n/locales/zh-CN.json b/client/src/i18n/locales/zh-CN.jsonindex 6e335563..57eeef90 100644--- a/client/src/i18n/locales/zh-CN.json+++ b/client/src/i18n/locales/zh-CN.json@@ -325,6 +325,7 @@"selectPlatform": "选择提供方","addKey": "添加密钥","keyAdded": "密钥已添加",+ "endpointKeysShareModels": "同一端点的密钥共用它的模型。","export": "导出","exportAll": "所有密钥","exportHealthy": "仅良好状态",diff --git a/client/src/i18n/locales/zh-TW.json b/client/src/i18n/locales/zh-TW.jsonindex 8c7b93ce..45a9f703 100644--- a/client/src/i18n/locales/zh-TW.json+++ b/client/src/i18n/locales/zh-TW.json@@ -325,6 +325,7 @@"selectPlatform": "選擇提供者","addKey": "新增金鑰","keyAdded": "金鑰已新增",+ "endpointKeysShareModels": "同一端點的金鑰共用其模型。","export": "匯出","exportAll": "所有金鑰","exportHealthy": "僅健康",diff --git a/server/src/__tests__/routes/custom-provider-multikey.test.ts b/server/src/__tests__/routes/custom-provider-multikey.test.tsindex 01d19edc..5c174e59 100644--- a/server/src/__tests__/routes/custom-provider-multikey.test.ts+++ b/server/src/__tests__/routes/custom-provider-multikey.test.ts@@ -193,4 +193,106 @@ describe('multiple keys per custom endpoint (#619)', () => {expect(secrets(other)).toEqual(['shared-secret']);expect(routePinnedModel(chatModel('other-model')!.id)!.provider).toMatchObject({ baseUrl: other });});++ // #702: every route into POST /custom demanded a model alongside the key, so+ // an endpoint whose models were all registered had no way left to take a+ // second credential. The reporter got past it by registering a throwaway+ // model id and deleting it afterwards, which silently took the new key too.+ describe('adding a key without naming a model (#702)', () => {+ const modelSettings = (modelId: string) => getDb().prepare(+ "SELECT key_id, enabled, display_name, supports_tools, supports_vision FROM models WHERE platform = 'custom' AND model_id = ?",+ ).get(modelId) as { key_id: number; enabled: number; display_name: string; supports_tools: number; supports_vision: number };++ it('adds a second credential to an endpoint that is fully registered', async () => {+ await post(app, '/api/keys/custom', { baseUrl: ENDPOINT, model: 'relay-model', apiKey: 'first-secret' });++ const res = await post(app, '/api/keys/custom', { baseUrl: ENDPOINT, apiKey: 'second-secret', label: 'Relay B' });++ expect(res.status).toBe(201);+ expect((res.body as any).models).toEqual([]);+ expect(secrets()).toEqual(['first-secret', 'second-secret']);+ expect(customKeys()[1]!.label).toBe('Relay B');+ });++ it('leaves the models of the endpoint exactly as they were', async () => {+ await post(app, '/api/keys/custom', {+ baseUrl: ENDPOINT, model: 'relay-model', apiKey: 'first-secret', supportsTools: true, supportsVision: true,+ });+ const before = modelSettings('relay-model');+ // Whatever the operator tuned afterwards has to survive the key add: going+ // through the model form instead resets all of this.+ getDb().prepare("UPDATE models SET enabled = 0, display_name = 'Tuned name' WHERE platform = 'custom' AND model_id = 'relay-model'").run();++ await post(app, '/api/keys/custom', { baseUrl: ENDPOINT, apiKey: 'second-secret' });++ expect(modelSettings('relay-model')).toEqual({+ key_id: before.key_id,+ enabled: 0,+ display_name: 'Tuned name',+ supports_tools: 1,+ supports_vision: 1,+ });+ });++ it('puts the new credential straight into the rotation pool', async () => {+ await post(app, '/api/keys/custom', { baseUrl: ENDPOINT, model: 'relay-model', apiKey: 'first-secret' });+ await post(app, '/api/keys/custom', { baseUrl: ENDPOINT, apiKey: 'second-secret' });++ const modelDbId = chatModel('relay-model')!.id;+ const usedSecrets = new Set<string>();+ for (let i = 0; i < 6; i++) {+ const route = routePinnedModel(modelDbId);+ usedSecrets.add(route!.apiKey);+ route!.release?.();+ }++ expect([...usedSecrets].sort()).toEqual(['first-secret', 'second-secret']);+ });++ it('upgrades a keyless endpoint in place rather than adding a row', async () => {+ await post(app, '/api/keys/custom', { baseUrl: ENDPOINT, model: 'relay-model' });++ const res = await post(app, '/api/keys/custom', { baseUrl: ENDPOINT, apiKey: 'first-secret' });++ // 'no-key' is a placeholder, not a credential, so nothing is lost.+ expect(res.status).toBe(200);+ expect(secrets()).toEqual(['first-secret']);+ });++ it('rejects a secret the endpoint already holds', async () => {+ await post(app, '/api/keys/custom', { baseUrl: ENDPOINT, model: 'relay-model', apiKey: 'first-secret' });++ const res = await post(app, '/api/keys/custom', { baseUrl: ENDPOINT, apiKey: 'first-secret' });++ expect(res.status).toBe(409);+ expect(secrets()).toEqual(['first-secret']);+ });++ it('still requires a model for an endpoint that does not exist yet', async () => {+ const res = await post(app, '/api/keys/custom', { baseUrl: ENDPOINT, apiKey: 'first-secret' });++ expect(res.status).toBe(400);+ expect(customKeys()).toHaveLength(0);+ });++ it('still requires a model when no key is submitted either', async () => {+ await post(app, '/api/keys/custom', { baseUrl: ENDPOINT, model: 'relay-model', apiKey: 'first-secret' });++ const res = await post(app, '/api/keys/custom', { baseUrl: ENDPOINT });++ expect(res.status).toBe(400);+ expect((res.body as any).error.message).toBe('model or models is required');+ });++ it('keeps a spare key when the model it arrived with is deleted', async () => {+ await post(app, '/api/keys/custom', { baseUrl: ENDPOINT, model: 'relay-model', apiKey: 'first-secret' });+ await post(app, '/api/keys/custom', { baseUrl: ENDPOINT, model: 'placeholder', apiKey: 'second-secret' });+ expect(secrets()).toEqual(['first-secret', 'second-secret']);++ expect((await del(app, `/api/models/custom/${chatModel('placeholder')!.id}`)).status).toBe(200);++ // The endpoint still serves relay-model, so neither key is dead weight.+ expect(secrets()).toEqual(['first-secret', 'second-secret']);+ });+ });});diff --git a/server/src/lib/custom-provider-cleanup.ts b/server/src/lib/custom-provider-cleanup.tsindex d8b5d1d2..2b002d0c 100644--- a/server/src/lib/custom-provider-cleanup.ts+++ b/server/src/lib/custom-provider-cleanup.ts@@ -7,23 +7,41 @@ function boundModelCount(db: Db, keyId: number): number {return chat.n + embeddings.n + media.n;}+/** Everything still registered against an endpoint, across every key of its pool. */+function endpointModelCount(db: Db, baseUrl: string): number {+ const count = (table: string) => (db.prepare(`+ SELECT COUNT(*) AS n+ FROM ${table} m+ JOIN api_keys k ON k.id = m.key_id+ WHERE m.platform = 'custom' AND k.platform = 'custom' AND k.base_url = ?+ `).get(baseUrl) as { n: number }).n;+ return count('models') + count('embedding_models') + count('media_models');+}++/**+ * Drop the api_keys row(s) of a custom endpoint that nothing is registered+ * against any more, called after a custom model is deleted.+ *+ * The unit of "unused" is the ENDPOINT, not the single key. An endpoint holds a+ * pool of credentials (#619) and each model binds to just one of them, so a key+ * with nothing bound to it is usually a spare the operator added for rotation,+ * not dead weight. Reaping on the key's own count deleted such a spare as soon+ * as the model it happened to arrive with was removed (#702).+ */export function deleteUnusedCustomEndpointKey(db: Db, keyId: number | null | undefined) {if (keyId == null) return;- if (boundModelCount(db, keyId) > 0) return;const row = db.prepare("SELECT base_url FROM api_keys WHERE id = ? AND platform = 'custom'").get(keyId) as { base_url: string | null } | undefined;- db.prepare("DELETE FROM api_keys WHERE id = ? AND platform = 'custom'").run(keyId);- if (!row?.base_url) return;- // An endpoint can hold several credentials (#619). Once nothing is registered- // against it any more, its other keys are dead weight too — but a sibling that- // still carries models of its own stays.- const siblings = db.prepare("SELECT id FROM api_keys WHERE platform = 'custom' AND base_url = ?")- .all(row.base_url) as { id: number }[];- for (const sibling of siblings) {- if (boundModelCount(db, sibling.id) === 0) {- db.prepare('DELETE FROM api_keys WHERE id = ?').run(sibling.id);- }+ // No base_url means no pool to belong to, so the key answers for itself.+ if (!row?.base_url) {+ if (boundModelCount(db, keyId) > 0) return;+ db.prepare("DELETE FROM api_keys WHERE id = ? AND platform = 'custom'").run(keyId);+ return;}++ if (endpointModelCount(db, row.base_url) > 0) return;++ db.prepare("DELETE FROM api_keys WHERE platform = 'custom' AND base_url = ?").run(row.base_url);}diff --git a/server/src/routes/keys.ts b/server/src/routes/keys.tsindex 7a36deee..64476fbb 100644--- a/server/src/routes/keys.ts+++ b/server/src/routes/keys.ts@@ -11,7 +11,7 @@ import { assessProviderUrl } from '../lib/url-guard.js';import { verifyCredentials } from '../services/auth.js';import { ensureModelInProfiles } from '../services/profile-models.js';import { getActiveCooldownsForKeys, clearCooldownsForKey } from '../services/ratelimit.js';-import { resolveCustomEndpointKey, customEndpointKeyIds, siblingEndpointKeyId } from '../services/custom-endpoint.js';+import { resolveCustomEndpointKey, customEndpointKeyIds, siblingEndpointKeyId, endpointHasCredential } from '../services/custom-endpoint.js';import { customModelSeed } from '../services/custom-model-seed.js';import { discoverEndpointModels, ModelDiscoveryError } from '../services/model-discovery.js';import { endpointScopeForBaseUrl, normalizeBaseUrl } from '../lib/endpoint-scope.js';@@ -502,12 +502,14 @@ const customProviderSchema = z.object({supportsTools: z.boolean().optional(),supportsVision: z.boolean().optional(),}).refine(- d => (d.model && d.model.trim().length > 0) || (d.models && d.models.length > 0),- { message: 'model or models is required' },-).refine(d => d.baseUrl !== undefined || d.keyId !== undefined,{ message: 'baseUrl or keyId is required' },);+// Naming no model at all is the credential-only add: a second key for an+// endpoint already registered (#702). It needs the endpoint to exist and a key+// to actually add, so those two checks live in the handler where the DB is in+// reach; a submit that is neither that nor a registration still gets the old+// 'model or models is required'.interface CustomEndpointRef {baseUrl: string;@@ -692,12 +694,40 @@ keysRouter.post('/custom', async (req: Request, res: Response) => {else addEntry(m.model, m.displayName, m.supportsTools, m.supportsVision);}+ const db = getDb();++ // Credential-only add (#702): a relay hands out one key per plan, and pooling+ // them is the point of #619, but every route into this handler used to demand+ // a model alongside the key. On an endpoint whose models are all registered+ // there was nothing left to name, so operators invented a throwaway model id+ // to get past the check, and deleting it afterwards took the new key with it.if (entries.length === 0) {- res.status(400).json({ error: { message: 'model or models is required' } });+ if (!providedKey) {+ res.status(400).json({ error: { message: 'model or models is required' } });+ return;+ }+ if (endpoint.keyId === null) {+ res.status(400).json({ error: { message: 'model or models is required to register a new endpoint' } });+ return;+ }+ if (endpointHasCredential(db, baseUrl, providedKey)) {+ res.status(409).json({ error: { message: 'this endpoint already has that key' } });+ return;+ }+ const added = resolveCustomEndpointKey(db, baseUrl, providedKey, label, endpoint.keyId);+ res.status(added.created ? 201 : 200).json({+ success: true,+ keyId: added.keyId,+ platform: 'custom',+ baseUrl,+ models: [],+ created: 0,+ alreadyRegistered: 0,+ maskedKey: maskKey(added.storedKey),+ });return;}- const db = getDb();const upsert = db.transaction(() => {// Key rows are matched on (base_url, secret): a new secret for a known// endpoint is a SECOND credential for it, not a replacement (#619), and adiff --git a/server/src/services/custom-endpoint.ts b/server/src/services/custom-endpoint.tsindex dbb14642..6053cb7f 100644--- a/server/src/services/custom-endpoint.ts+++ b/server/src/services/custom-endpoint.ts@@ -119,6 +119,13 @@ export function resolveCustomEndpointKey(return insertKey(db, baseUrl, providedKey, label);}+/** True when this endpoint already stores this exact secret. Lets a caller tell+ * a genuinely new credential from a re-submit of one already in the pool, which+ * `resolveCustomEndpointKey` deliberately treats the same way. */+export function endpointHasCredential(db: Db, baseUrl: string, secret: string): boolean {+ return endpointKeyRows(db, baseUrl).some(row => plaintextOf(row) === secret);+}+/*** Every api_keys id that serves the SAME custom endpoint as `keyId` — i.e. the* credential pool a model bound to `keyId` may rotate across. Falls back to the