ai-mistral-text
ai-mistral-text — Generate text using Mistral Chat Completion
Description
- step: ai-mistral-text
args:
- '${PROMPT}'
- '${REASONING_EFFORT}' # optional
context:
SYSTEM_PROMPT: '${SYSTEM_PROMPT}' # optional
The ai-mistral-text step generates text using Mistral’s Chat Completion API.
- Uses the
MISTRAL_API_KEYin context for authentication. - Accepts an optional
SYSTEM_PROMPTto guide the model. - Optional
reasoning_effortcontrols the depth of reasoning:"minimal","low","medium","high"(default:"low"). - Output is stored in
${prev}by default or a custom context key viaset_context.
Usage in a workflow YAML:
workflow:
- step: ai-mistral-text
args:
- "Explain the benefits of renewable energy."
- "medium"
context:
SYSTEM_PROMPT: "You are a friendly, clear, and concise assistant."
Parameters
| Parameter | Type | Description |
|---|---|---|
prompt |
string |
The text prompt to send to Mistral. |
reasoning_effort |
string |
Optional. One of "minimal", "low", "medium", "high". Controls depth of reasoning. |
Context requirements:
| Context Key | Type | Description |
|---|---|---|
MISTRAL_API_KEY |
string |
Required. Mistral API key. |
SYSTEM_PROMPT |
string |
Optional. System prompt to guide the model. |
Return Values
- Returns
0on success,1on failure. - On success, context (
${prev}by default, or custom viaset_context) contains the generated text:
"This is the text generated by Mistral based on your prompt."
- On failure, context contains an error message:
{
"error": "Description of the error or API failure"
}
- If no arguments are provided, usage instructions are set in
context['ai-mistral-text::usage'].
Behavior
- Sends the prompt (and optional system prompt) to the Mistral Chat Completion API.
- Stores the generated message content in context under
${prev}(default) orset_context. - Handles network errors, missing API key, and HTTP errors gracefully, storing errors in context.
- Reasoning effort affects how detailed the response is; not all Mistral models may support it directly.
Examples
Example #1 — Basic text generation
workflow:
- step: ai-mistral-text
args:
- "Summarize the latest AI news."
Stores the generated summary in ${prev}.
Example #2 — Specifying reasoning effort
workflow:
- step: ai-mistral-text
args:
- "Explain black holes for beginners."
- "medium"
Example #3 — Using system prompt
workflow:
- step: ai-mistral-text
args:
- "Write a professional email draft."
context:
SYSTEM_PROMPT: "You are a polite and concise assistant."
Notes
- Ensure
MISTRAL_API_KEYis set in the workflow context. reasoning_effortdefaults to"low"if not provided.- Use
set_contextto store output in a custom key instead of overwriting${prev}. - Generated text is returned as a string. Structured output must be parsed in a downstream step.
See Also
-
ai-mistral-classifier — Generate a classification score using Mistral Chat Completion
-
ai-openai-text: Generate text using OpenAI GPT-5.
-
ai-openai-image-gen: Generate images from text prompts.
-
nyno-file-write / nyno-file-read: Save or read generated text.