🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
import { describe, expect, it, vi } from 'vitest';
import { ModelProvider } from '../../const/modelProvider';
import { loadModels, LOBE_DEFAULT_MODEL_LIST } from '../index';
describe('loadModels', () => {
it('returns the static model list by default', async () => {
await expect(loadModels()).resolves.toBe(LOBE_DEFAULT_MODEL_LIST);
});
it('overrides provider models with injected async loaders', async () => {
const loader = vi.fn().mockResolvedValue([
{
enabled: true,
id: 'injected-lobehub-model',
type: 'chat',
},
]);
const models = await loadModels({
providerLoaders: {
[ModelProvider.LobeHub]: loader,
},
});
expect(loader).toHaveBeenCalledTimes(1);
expect(models).toEqual(
expect.arrayContaining([
expect.objectContaining({
enabled: true,
id: 'injected-lobehub-model',
providerId: ModelProvider.LobeHub,
source: 'builtin',
type: 'chat',
}),
]),
);
});
it('ignores undefined provider loaders', async () => {
await expect(
loadModels({
providerLoaders: {
[ModelProvider.LobeHub]: undefined,
},
}),
).resolves.toBe(LOBE_DEFAULT_MODEL_LIST);
});
it('propagates injected loader errors without falling back to static models', async () => {
const loader = vi.fn().mockRejectedValue(new Error('model config missing'));
await expect(
loadModels({
providerLoaders: {
[ModelProvider.LobeHub]: loader,
},
}),
).rejects.toThrow('model config missing');
});
});
describe('knowledgeCutoff backfill', () => {
it('fills knowledgeCutoff from the canonical map for builtin models', () => {
const fable = LOBE_DEFAULT_MODEL_LIST.find(
(m) => m.providerId === 'anthropic' && m.id === 'claude-fable-5',
);
expect(fable?.knowledgeCutoff).toBe('2026-01');
const opus = LOBE_DEFAULT_MODEL_LIST.find(
(m) => m.providerId === 'anthropic' && m.id === 'claude-opus-4-8',
);
expect(opus?.knowledgeCutoff).toBe('2026-01');
// aggregator spelling of the same model gets the same cutoff
const bedrockOpus = LOBE_DEFAULT_MODEL_LIST.find(
(m) => m.providerId === 'bedrock' && m.id === 'global.anthropic.claude-opus-4-7',
);
expect(bedrockOpus?.knowledgeCutoff).toBe('2026-01');
const vertexGemini3Pro = LOBE_DEFAULT_MODEL_LIST.find(
(m) => m.providerId === 'vertexai' && m.id === 'gemini-3-pro-preview',
);
expect(vertexGemini3Pro?.knowledgeCutoff).toBe('2025-01');
});
it('keeps an explicit knowledgeCutoff over the map value', async () => {
const loader = vi.fn().mockResolvedValue([
{ enabled: true, id: 'gpt-5', knowledgeCutoff: '2020-01', type: 'chat' },
{ enabled: true, id: 'gpt-5-mini', type: 'chat' },
]);
const models = await loadModels({
providerLoaders: { [ModelProvider.LobeHub]: loader },
});
const lobehubModels = models.filter((m) => m.providerId === ModelProvider.LobeHub);
expect(lobehubModels.find((m) => m.id === 'gpt-5')?.knowledgeCutoff).toBe('2020-01');
expect(lobehubModels.find((m) => m.id === 'gpt-5-mini')?.knowledgeCutoff).toBe('2024-05');
});
});
describe('ChatGPT subscription models', () => {
it('advertises reasoning replay support', () => {
const models = LOBE_DEFAULT_MODEL_LIST.filter(
(model) => model.providerId === ModelProvider.ChatGPT,
);
expect(models).toHaveLength(11);
expect(
models.every((model) => model.settings?.extendParams?.includes('preserveThinking')),
).toBe(true);
});
});
describe('OpenAI audio models', () => {
it('advertises native audio support for gpt-audio', () => {
const gptAudio = LOBE_DEFAULT_MODEL_LIST.find(
(model) => model.providerId === ModelProvider.OpenAI && model.id === 'gpt-audio',
);
expect(gptAudio?.abilities.audio).toBe(true);
});
});
describe('OpenCode Go models', () => {
it('registers the Muse Spark Contributor series', () => {
const models = LOBE_DEFAULT_MODEL_LIST.filter(
(model) =>
model.providerId === ModelProvider.OpenCodeCodingPlan && model.id.startsWith('muse-spark-'),
);
expect(models.map(({ id }) => id)).toEqual([
'muse-spark-1.2-contributor',
'muse-spark-1.3-contributor',
]);
expect(models.find(({ id }) => id === 'muse-spark-1.3-contributor')).toEqual(
expect.objectContaining({
abilities: expect.objectContaining({
functionCall: true,
reasoning: true,
structuredOutput: true,
vision: true,
}),
contextWindowTokens: 1_048_576,
enabled: true,
maxOutput: 131_072,
}),
);
});
});
describe('Moonshot models', () => {
it('advertises Kimi K3 reasoning effort controls', () => {
const kimiK3 = LOBE_DEFAULT_MODEL_LIST.find(
(model) => model.providerId === ModelProvider.Moonshot && model.id === 'kimi-k3',
);
expect(kimiK3?.settings?.extendParams).toContain('kimiK3ReasoningEffort');
});
});
describe('Hunyuan models', () => {
it('registers Hy3 with agent capabilities', () => {
const hy3 = LOBE_DEFAULT_MODEL_LIST.find(
(model) => model.providerId === ModelProvider.Hunyuan && model.id === 'hy3',
);
expect(hy3).toEqual(
expect.objectContaining({
abilities: expect.objectContaining({
functionCall: true,
reasoning: true,
structuredOutput: true,
}),
contextWindowTokens: 256_000,
enabled: true,
maxOutput: 128_000,
settings: {
extendParams: ['hy3ReasoningEffort'],
},
type: 'chat',
}),
);
});
});
describe('MiniMax video models', () => {
it('registers MiniMax-H3 with the official v2 parameter limits', () => {
const h3 = LOBE_DEFAULT_MODEL_LIST.find(
(model) => model.providerId === ModelProvider.Minimax && model.id === 'MiniMax-H3',
);
expect(h3).toEqual(
expect.objectContaining({
enabled: true,
parameters: expect.objectContaining({
aspectRatio: expect.objectContaining({ default: '16:9' }),
duration: expect.objectContaining({ max: 15, min: 4 }),
imageUrls: expect.objectContaining({ maxCount: 9 }),
resolution: expect.objectContaining({ default: '768P', enum: ['768P', '2K'] }),
}),
releasedAt: '2026-07-31',
type: 'video',
}),
);
});
it('lets References mode fill the whole MiniMax-H3 reference pool of 9', () => {
const h3 = LOBE_DEFAULT_MODEL_LIST.find(
(model) => model.providerId === ModelProvider.Minimax && model.id === 'MiniMax-H3',
);
// The UI's References mode clears the frame slots and submits only imageUrls, so the
// reference slot alone must allow the full pool the v2 API accepts.
expect((h3?.parameters as { imageUrls?: { maxCount?: number } })?.imageUrls?.maxCount).toBe(9);
});
});
describe('Google rolling model aliases', () => {
it('tracks the current Flash and Flash-Lite model versions', () => {
const googleModels = LOBE_DEFAULT_MODEL_LIST.filter((model) => model.providerId === 'google');
const flashLatest = googleModels.find((model) => model.id === 'gemini-flash-latest');
const flash = googleModels.find((model) => model.id === 'gemini-3.8-flash');
const flashLiteLatest = googleModels.find((model) => model.id === 'gemini-flash-lite-latest');
const flashLite = googleModels.find((model) => model.id === 'gemini-3.5-flash-lite');
expect(flashLatest).toEqual(
expect.objectContaining({
description: 'Points to gemini-3.8-flash',
knowledgeCutoff: '2026-03',
}),
);
expect(flashLatest?.pricing).toEqual(flash?.pricing);
expect(flashLatest?.settings?.disabledParams).toEqual(['temperature', 'top_p']);
expect(flashLiteLatest).toEqual(
expect.objectContaining({
description: 'Points to gemini-3.5-flash-lite',
knowledgeCutoff: '2026-03',
}),
);
expect(flashLiteLatest?.pricing).toEqual(flashLite?.pricing);
expect(flashLiteLatest?.settings?.disabledParams).toEqual(['temperature', 'top_p']);
});
});
describe('Google Gemini 3.1 Flash Image models', () => {
it('registers stable IDs without removing the preview compatibility cards', () => {
const googleModels = LOBE_DEFAULT_MODEL_LIST.filter(
(model) => model.providerId === ModelProvider.Google,
);
const stableImageModel = googleModels.find(
(model) => model.id === 'gemini-3.1-flash-image:image',
);
expect(googleModels).toEqual(
expect.arrayContaining([
expect.objectContaining({
enabled: true,
id: 'gemini-3.1-flash-image',
releasedAt: '2026-05-28',
type: 'chat',
}),
expect.objectContaining({
enabled: true,
id: 'gemini-3.1-flash-image:image',
releasedAt: '2026-05-28',
type: 'image',
}),
expect.objectContaining({
enabled: false,
id: 'gemini-3.1-flash-image-preview',
releasedAt: '2026-02-26',
type: 'chat',
}),
expect.objectContaining({
enabled: false,
id: 'gemini-3.1-flash-image-preview:image',
releasedAt: '2026-02-26',
type: 'image',
}),
]),
);
expect(stableImageModel?.pricing?.units).toEqual(
expect.arrayContaining([
expect.objectContaining({ name: 'textInput', rate: 0.5 }),
expect.objectContaining({ name: 'imageInput', rate: 0.5 }),
expect.objectContaining({ name: 'textOutput', rate: 3 }),
expect.objectContaining({ name: 'imageOutput', rate: 60 }),
]),
);
});
});
describe('vendor provider cards', () => {
it('advertises native search, image and video input for GLM-5.3-Flash', () => {
// Without `video: true` the chat pipeline falls back to media analysis instead of sending
// video to the model natively, even though the official card lists video input.
const glm53Flash = LOBE_DEFAULT_MODEL_LIST.find(
(m) => m.providerId === 'zhipu' && m.id === 'glm-5.3-flash',
);
expect(glm53Flash?.abilities).toEqual(
expect.objectContaining({ reasoning: true, search: true, video: true, vision: true }),
);
expect(glm53Flash?.settings?.searchImpl).toBe('params');
});
});
describe('recent direct-provider models', () => {
it.each([
{
cutoff: '2026-05',
id: 'gpt-6.2-astra',
rates: [
[8, 16],
[0.4, 0.8],
[10, 20],
[40, 60],
],
},
{
cutoff: '2026-06',
id: 'gpt-6.2-sol',
rates: [
[2, 4],
[0.1, 0.2],
[2.5, 5],
[10, 15],
],
},
])('registers OpenAI $id with its published limits and rates', ({ cutoff, id, rates }) => {
const model = LOBE_DEFAULT_MODEL_LIST.find(
(entry) => entry.providerId === ModelProvider.OpenAI && entry.id === id,
);
expect(model).toMatchObject({
abilities: {
functionCall: true,
reasoning: true,
search: true,
structuredOutput: true,
vision: true,
},
contextWindowTokens: 1_050_000,
enabled: true,
family: 'gpt',
generation: 'gpt-6.2',
isOfficial: true,
knowledgeCutoff: cutoff,
maxOutput: 128_000,
releasedAt: '2026-11-17',
settings: { extendParams: ['gpt6ReasoningEffort', 'textVerbosity'], searchImpl: 'params' },
type: 'chat',
});
expect(model?.pricing?.units).toEqual(
['textInput', 'textInput_cacheRead', 'textInput_cacheWrite', 'textOutput'].map(
(name, index) => ({
name,
strategy: 'tiered',
tiers: [
{ rate: rates[index][0], upTo: 272_000 },
{ rate: rates[index][1], upTo: 'infinity' },
],
unit: 'millionTokens',
}),
),
);
});
it('registers GPT-6.1 Sol with its published limits, pricing, and reasoning controls', () => {
const model = LOBE_DEFAULT_MODEL_LIST.find(
(entry) => entry.providerId === ModelProvider.OpenAI && entry.id === 'gpt-6.1-sol',
);
expect(model).toMatchObject({
contextWindowTokens: 1_050_000,
enabled: true,
generation: 'gpt-6.1',
knowledgeCutoff: '2026-04',
maxOutput: 128_000,
settings: { extendParams: ['gpt6ReasoningEffort', 'textVerbosity'] },
});
expect(model?.pricing?.units).toContainEqual({
name: 'textInput_cacheRead',
strategy: 'tiered',
tiers: [
{ rate: 0.1, upTo: 272_000 },
{ rate: 0.2, upTo: 'infinity' },
],
unit: 'millionTokens',
});
});
it.each(['qwen3.8-max', 'qwen3.8-max-0902'])(
'exposes exactly one %s card with effort and thinking preservation controls',
(id) => {
const models = LOBE_DEFAULT_MODEL_LIST.filter(
(entry) => entry.providerId === 'qwen' && entry.id === id,
);
expect(models).toHaveLength(1);
expect(models[0].settings?.extendParams).toEqual([
'qwen38ReasoningEffort',
'preserveThinking',
]);
},
);
it.each([
['openai', 'gpt-6-astra', 'gpt6ReasoningEffort'],
['azure', 'gpt-6.2-astra', 'gpt6ReasoningEffort'],
['azure', 'gpt-6.2-sol', 'gpt6ReasoningEffort'],
['openrouter', 'openai/gpt-6.2-astra', 'gpt6ReasoningEffort'],
['openrouter', 'openai/gpt-6.2-sol', 'gpt6ReasoningEffort'],
['google', 'gemini-3.8-flash', 'thinkingLevel3'],
['vertexai', 'gemini-3.8-flash', 'thinkingLevel3'],
['google', 'gemini-4-carbon', 'thinkingLevel3'],
['vertexai', 'gemini-4-carbon', 'thinkingLevel3'],
['openrouter', 'google/gemini-4-carbon', 'thinkingLevel3'],
['google', 'gemini-4-neon', 'thinkingLevel5'],
['vertexai', 'gemini-4-neon', 'thinkingLevel5'],
['openrouter', 'google/gemini-4-neon', 'thinkingLevel5'],
['xai', 'grok-4.6', 'grok4_6ReasoningEffort'],
['qwen', 'qwen3.8-max', 'qwen38ReasoningEffort'],
['qwen', 'qwen3.8-max-0902', 'qwen38ReasoningEffort'],
])('exposes %s/%s with its reasoning controls', (providerId, id, reasoningParam) => {
const model = LOBE_DEFAULT_MODEL_LIST.find(
(entry) => entry.providerId === providerId && entry.id === id,
);
expect(model).toMatchObject({
abilities: { functionCall: true, reasoning: true, vision: true },
enabled: true,
type: 'chat',
});
expect(model?.settings?.extendParams).toContain(reasoningParam);
});
});
describe('GPT-6.2 reseller cards', () => {
it.each([
['azure', 'gpt-6.2-astra', 'gpt-6.2-astra'],
['azure', 'gpt-6.2-sol', 'gpt-6.2-sol'],
['openrouter', 'openai/gpt-6.2-astra', 'gpt-6.2-astra'],
['openrouter', 'openai/gpt-6.2-sol', 'gpt-6.2-sol'],
])('prices %s/%s at the official OpenAI list price', (providerId, id, officialId) => {
const official = LOBE_DEFAULT_MODEL_LIST.find(
(entry) => entry.providerId === 'openai' && entry.id === officialId,
);
const model = LOBE_DEFAULT_MODEL_LIST.find(
(entry) => entry.providerId === providerId && entry.id === id,
);
expect(official?.isOfficial).toBe(true);
expect(model?.isOfficial).toBeUndefined();
expect(model?.pricing).toEqual(official?.pricing);
expect(model?.contextWindowTokens).toBe(official?.contextWindowTokens);
});
it.each(['gpt-6.2-astra', 'gpt-6.2-sol'])('deploys azure/%s under its model id', (id) => {
const model = LOBE_DEFAULT_MODEL_LIST.find(
(entry) => entry.providerId === 'azure' && entry.id === id,
);
expect(model?.config?.deploymentName).toBe(id);
});
});
describe('Gemini 3.8 introductory pricing', () => {
it.each(['google', 'vertexai'])('uses the published output rate for %s', (providerId) => {
const model = LOBE_DEFAULT_MODEL_LIST.find(
(entry) => entry.providerId === providerId && entry.id === 'gemini-3.8-flash',
);
expect(model?.pricing?.units).toContainEqual({
name: 'textOutput',
rate: 3.75,
strategy: 'fixed',
unit: 'millionTokens',
});
});
});
describe('Gemini 4 Carbon introductory pricing', () => {
it.each([
['google', 'gemini-4-carbon'],
['vertexai', 'gemini-4-carbon'],
['openrouter', 'google/gemini-4-carbon'],
])('bills %s/%s at $2 input and $10 output', (providerId, id) => {
const model = LOBE_DEFAULT_MODEL_LIST.find(
(entry) => entry.providerId === providerId && entry.id === id,
);
expect(model?.pricing?.units).toEqual(
expect.arrayContaining([
{ name: 'textInput', rate: 2, strategy: 'fixed', unit: 'millionTokens' },
{ name: 'textOutput', rate: 10, strategy: 'fixed', unit: 'millionTokens' },
]),
);
});
});
describe('subscription model catalogs', () => {
it.each([
['chatgpt', 'gpt-6.2-astra', 'gpt6ReasoningEffort'],
['chatgpt', 'gpt-6.2-sol', 'gpt6ReasoningEffort'],
['chatgpt', 'gpt-6-astra', 'gpt6ReasoningEffort'],
['chatgpt', 'gpt-6.1-sol', 'gpt6ReasoningEffort'],
['chatgpt', 'gpt-6.1-terra', 'gpt5_6ReasoningEffort'],
['supergrok', 'grok-4.6', 'grok4_6ReasoningEffort'],
])('exposes %s/%s without usage-based pricing', (providerId, id, reasoningParam) => {
const model = LOBE_DEFAULT_MODEL_LIST.find(
(entry) => entry.providerId === providerId && entry.id === id,
);
expect(model).toMatchObject({ enabled: true, type: 'chat' });
expect(model?.pricing).toBeUndefined();
expect(model?.settings?.extendParams).toContain(reasoningParam);
});
it.each(['gpt-6-astra', 'gpt-6.2-astra', 'gpt-6.2-sol'])(
'keeps the ChatGPT context cap and thinking preservation for %s',
(id) => {
const model = LOBE_DEFAULT_MODEL_LIST.find(
(entry) => entry.providerId === 'chatgpt' && entry.id === id,
);
expect(model?.contextWindowTokens).toBe(272_000);
expect(model?.settings?.extendParams).toContain('preserveThinking');
},
);
});
describe('Anthropic cache-write pricing', () => {
it('lists both the 5-minute and 1-hour cache-write prices for flat-priced models', () => {
// Official multipliers: a 5-minute write is 1.25x base input, a 1-hour write is 2x.
// https://platform.claude.com/docs/en/about-claude/pricing
const flatPriced = LOBE_DEFAULT_MODEL_LIST.filter(
(m) =>
m.providerId === ModelProvider.Anthropic &&
m.pricing?.units.find((u) => u.name === 'textInput')?.strategy === 'fixed',
);
expect(flatPriced.map((m) => m.id)).toContain('claude-fable-5-1');
for (const model of flatPriced) {
const units = model.pricing!.units;
const input = units.find((u) => u.name === 'textInput');
const cacheWrite = units.find((u) => u.name === 'textInput_cacheWrite');
const inputRate = input?.strategy === 'fixed' ? input.rate : NaN;
expect({ id: model.id, unit: cacheWrite }).toEqual({
id: model.id,
unit: {
lookup: {
prices: { '1h': inputRate * 2, '5m': inputRate * 1.25 },
pricingParams: ['ttl'],
},
name: 'textInput_cacheWrite',
strategy: 'lookup',
unit: 'millionTokens',
},
});
}
});
});
describe('Google context-caching pricing', () => {
// https://ai.google.dev/gemini-api/docs/pricing
const units = (id: string) =>
LOBE_DEFAULT_MODEL_LIST.find((m) => m.providerId === ModelProvider.Google && m.id === id)
?.pricing?.units;
const storage = {
lookup: { prices: { '1h': 1 }, pricingParams: ['ttl'] },
name: 'textInput_cacheWrite',
strategy: 'lookup',
unit: 'millionTokens',
};
const fixed = (name: string, rate: number) => ({
name,
rate,
strategy: 'fixed',
unit: 'millionTokens',
});
it('prices Gemini 2.5 Pro cache reads by prompt length', () => {
expect(units('gemini-2.5-pro')).toContainEqual({
name: 'textInput_cacheRead',
strategy: 'tiered',
tiers: [
{ rate: 0.125, upTo: 200_000 },
{ rate: 0.25, upTo: 'infinity' },
],
unit: 'millionTokens',
});
});
it.each([
['gemini-2.5-flash', 0.03, 0.1],
['gemini-2.5-flash-lite', 0.01, 0.03],
])('lists text and audio cache reads plus storage for %s', (id, text, audio) => {
expect(units(id)).toEqual(
expect.arrayContaining([
fixed('textInput_cacheRead', text),
fixed('audioInput_cacheRead', audio),
storage,
]),
);
});
it('lists the audio cache read for Gemini 3 Flash Preview', () => {
expect(units('gemini-3-flash-preview')).toContainEqual(fixed('audioInput_cacheRead', 0.1));
});
});
describe('Gemini 4 Neon pricing', () => {
it.each([
['google', 'gemini-4-neon'],
['vertexai', 'gemini-4-neon'],
['openrouter', 'google/gemini-4-neon'],
])('bills %s/%s at $3 input and $15 output', (providerId, id) => {
const model = LOBE_DEFAULT_MODEL_LIST.find(
(entry) => entry.providerId === providerId && entry.id === id,
);
expect(model?.pricing?.units).toEqual(
expect.arrayContaining([
{ name: 'textInput', rate: 3, strategy: 'fixed', unit: 'millionTokens' },
{ name: 'textOutput', rate: 15, strategy: 'fixed', unit: 'millionTokens' },
]),
);
});
it('marks only the Gemini API card as the official price source', () => {
const official = LOBE_DEFAULT_MODEL_LIST.filter(
(entry) => entry.id === 'gemini-4-neon' && entry.isOfficial,
);
expect(official.map((entry) => entry.providerId)).toEqual(['google']);
});
});