One-shot text generation
Generate a complete response from a prompt with generateText.
AI Tools · Const
mistral is the default Mistral provider from @ai-sdk/mistral. Call it with a model ID to create a model for AI SDK text generation and streaming.
mistral is the default provider instance exported by @ai-sdk/mistral. Calling it with a model ID returns a model that targets Mistral's chat API, which can then be passed to AI SDK functions such as generateText or streamText.
mistral(modelId)| Name | Type | Description |
|---|---|---|
modelId | string | Mistral model identifier, for example mistral-large-latest. |
A language model configured to call Mistral's chat API.
@ai-sdk/mistral package.mistral.import { mistral } from '@ai-sdk/mistral';
import { generateText } from 'ai';
const result = await generateText({
model: mistral('mistral-large-latest'),
prompt: 'Explain dependency injection in one sentence.',
});
console.log(result.text);This creates a Mistral chat model by ID and uses it with generateText to produce text.
Generate a complete response from a prompt with generateText.
Produce incremental output with streamText for responsive interfaces.
Use a custom endpoint or provider configuration with createMistral.
Import the default mistral provider from @ai-sdk/mistral, call it with a model ID, and pass the resulting model to generateText or streamText. This keeps model invocation aligned with the AI SDK interface.
Follow-up: How would you customize the provider? Import createMistral and create a provider instance with the required settings, then call that instance with a model ID.
The package is @ai-sdk/mistral, and the default instance is imported as mistral. A model is created by calling mistral(modelId), such as mistral('mistral-large-latest').
Follow-up: What API does the resulting model call? It targets Mistral's chat API through the provider implementation.
createMistral instead of mistral?Use createMistral when the default provider instance is insufficient. It creates a provider with custom settings, while the default mistral instance provides the standard setup.
Follow-up: Which endpoint does the standard provider use? Its default prefix is https://api.mistral.ai/v1.
createMistralgenerateTextstreamText@ai-sdk/mistral