Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Wikedhart18/nextjs-ai-chatbot/llms.txt

Use this file to discover all available pages before exploring further.

All model configuration lives in lib/ai/models.ts. The app uses a custom provider built on top of the Vercel AI SDK to group models under stable internal identifiers, decoupling the rest of the codebase from specific upstream model names.

Model registry

The myProvider object registers every model the app can use:
lib/ai/models.ts
import { openai } from '@ai-sdk/openai';
import { fireworks } from '@ai-sdk/fireworks';
import {
  customProvider,
  extractReasoningMiddleware,
  wrapLanguageModel,
} from 'ai';

export const DEFAULT_CHAT_MODEL: string = 'chat-model-small';

export const myProvider = customProvider({
  languageModels: {
    'chat-model-small': openai('gpt-4o-mini'),
    'chat-model-large': openai('gpt-4o'),
    'chat-model-reasoning': wrapLanguageModel({
      model: fireworks('accounts/fireworks/models/deepseek-r1'),
      middleware: extractReasoningMiddleware({ tagName: 'think' }),
    }),
    'title-model': openai('gpt-4-turbo'),
    'artifact-model': openai('gpt-4o-mini'),
  },
  imageModels: {
    'small-model': openai.image('dall-e-2'),
    'large-model': openai.image('dall-e-3'),
  },
});

Language models

Internal IDUpstream modelPurpose
chat-model-smallgpt-4o-miniDefault model for everyday conversations. Fast and cost-efficient.
chat-model-largegpt-4oFull-size model for complex, multi-step tasks.
chat-model-reasoningdeepseek-r1 (via Fireworks)Step-by-step reasoning for problems that benefit from chain-of-thought.
title-modelgpt-4-turboAuto-generates a short title for each new chat. Not user-selectable.
artifact-modelgpt-4o-miniGenerates documents and code artifacts in the artifact panel. Not user-selectable.
The three models exposed in the chat UI (chat-model-small, chat-model-large, chat-model-reasoning) are defined in the chatModels array, which drives the model selector component:
lib/ai/models.ts
export const chatModels: Array<ChatModel> = [
  {
    id: 'chat-model-small',
    name: 'Small model',
    description: 'Small model for fast, lightweight tasks',
  },
  {
    id: 'chat-model-large',
    name: 'Large model',
    description: 'Large model for complex, multi-step tasks',
  },
  {
    id: 'chat-model-reasoning',
    name: 'Reasoning model',
    description: 'Uses advanced reasoning',
  },
];

Image models

Internal IDUpstream modelCharacteristics
small-modeldall-e-2Faster generation, lower cost.
large-modeldall-e-3Higher quality, supports more detailed prompts.

Reasoning middleware

The chat-model-reasoning model wraps DeepSeek R1 with extractReasoningMiddleware. This middleware strips the model’s internal <think>...</think> chain-of-thought from the streamed output before it reaches the UI, while still making the reasoning trace available separately.
'chat-model-reasoning': wrapLanguageModel({
  model: fireworks('accounts/fireworks/models/deepseek-r1'),
  middleware: extractReasoningMiddleware({ tagName: 'think' }),
}),
Using chat-model-reasoning requires a valid FIREWORKS_API_KEY in your environment. See Environment variables.

Changing the default model

The DEFAULT_CHAT_MODEL constant controls which model is pre-selected when a user starts a new chat:
lib/ai/models.ts
export const DEFAULT_CHAT_MODEL: string = 'chat-model-small';
To change the default, replace 'chat-model-small' with any other user-facing model ID:
export const DEFAULT_CHAT_MODEL: string = 'chat-model-large';
Valid values are 'chat-model-small', 'chat-model-large', and 'chat-model-reasoning'.

Swapping to a different upstream model

To point an internal ID at a different upstream model, edit the corresponding entry in myProvider. For example, to upgrade chat-model-small to a newer OpenAI model:
'chat-model-small': openai('gpt-4o'),
The rest of the codebase references only the internal ID, so no other files need to change.
Swapping models may affect response quality, latency, and API costs. Test thoroughly before deploying to production.

Build docs developers (and LLMs) love