Customization

Models and Providers

Switch between different models and providers.

Chat SDK ships with xAI as the default model provider. Since Chat SDK is powered by the AI SDK, which supports multiple providers out of the box, you can always switch to a different provider of your choice, anytime.

To update the models, you will need to update the custom provider called myProvider at /lib/ai/models.ts shown below.

import { customProvider } from "ai";
import { xai } from "@ai-sdk/xai";
 
export const myProvider = customProvider({
  languageModels: {
    "chat-model": xai("grok-2-1212"),
    "chat-model-reasoning": wrapLanguageModel({
      model: xai('grok-3-mini-beta'),
      middleware: extractReasoningMiddleware({ tagName: "think" }),
    }),
    "title-model": xai("grok-2-1212"),
    "artifact-model": xai("grok-2-1212"),
  },
  imageModels: {
    "small-model": xai.image("grok-2-image"),
  },
});

You can replace the xai models with any other provider of your choice. You will need to install the provider library and switch the models accordingly.

For example, if you want to use Anthropic's claude-3-5-sonnet model for chat-model-large, you can replace the xai model with the anthropic model as shown below.

import { customProvider } from "ai";
import { xai } from "@ai-sdk/xai";
import { anthropic } from "@ai-sdk/anthropic";
 
export const myProvider = customProvider({
  languageModels: {
    "chat-model": anthropic("claude-3-5-sonnet"), // Replace with anthropic model
    "chat-model-reasoning": wrapLanguageModel({
      model: xai('grok-3-mini-beta'),
      middleware: extractReasoningMiddleware({ tagName: "think" }),
    }),
    "title-model": xai("grok-2-1212"),
    "artifact-model": xai("grok-2-1212"),
  },
  imageModels: {
    "small-model": xai.image("grok-2-image"),
  },
});

You can find the provider library and model names in the provider's documentation. Once you have updated the models, you should be able to use the new models in your chatbot.