Skip to main content
mistral-core-workflow-a Execute Mistral AI chat completions with streaming, multi-turn, and guardrails.
Use when implementing chat interfaces, building conversational AI,
or integrating Mistral for text generation.
Trigger with phrases like "mistral chat", "mistral completion",
"mistral streaming", "mistral conversation", "mistral guardrails".
설치로 이동 Skills Marketplace 커뮤니티가 만든 AI 스킬을 발견하고 탐색하세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/jeremylongshore/claude-code-plugins-plus-skills --skill mistral-core-workflow-a명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Zip 다운로드 다운로드 중... 이 저장소의 다른 Skills Implement user sign-up and sign-in flows with Clerk.
Use when building authentication UI, customizing sign-in experience,
or implementing OAuth social login.
Trigger with phrases like "clerk sign-in", "clerk sign-up",
"clerk login flow", "clerk OAuth", "clerk social login".
Implement session management and middleware with Clerk.
Use when managing user sessions, configuring route protection,
or implementing token refresh and custom JWT templates.
Trigger with phrases like "clerk session", "clerk middleware",
"clerk route protection", "clerk token", "clerk JWT".
Configure enterprise SSO, role-based access control, and organization management.
Use when implementing SSO integration, configuring role-based permissions,
or setting up organization-level controls.
Trigger with phrases like "clerk SSO", "clerk RBAC",
"clerk enterprise", "clerk roles", "clerk permissions", "clerk organizations".
jeremylongshore
jeremylongshore/claude-code-plugins-plus-skills
GitHub 저장소 열기 name mistral-core-workflow-a description Execute Mistral AI chat completions with streaming, multi-turn, and guardrails.
Use when implementing chat interfaces, building conversational AI,
or integrating Mistral for text generation.
Trigger with phrases like "mistral chat", "mistral completion",
"mistral streaming", "mistral conversation", "mistral guardrails".
allowed-tools Read, Write, Edit, Bash(npm:*), Grep version 1.12.0 license MIT author Jeremy Longshore <jeremy@intentsolutions.io> tags ["saas","mistral","workflow"] compatibility Designed for Claude Code, also compatible with Codex and OpenClaw
Mistral AI Core Workflow A: Chat Completions
Overview
Production chat completion patterns for Mistral AI: multi-turn conversations, streaming responses, JSON mode structured output, guardrails/moderation, and model selection. Uses the @mistralai/mistralai SDK.
Prerequisites
Completed mistral-install-auth setup
MISTRAL_API_KEY environment variable set
Understanding of Mistral model tiers
Instructions
Step 1: Basic Chat Completion
import { Mistral } from '@mistralai/mistralai' ;
const client = new Mistral ({ apiKey : process.env .MISTRAL_API_KEY });
async function chat (userMessage : string ): Promise <string > {
const response = await client.chat .complete ({
model : 'mistral-small-latest' ,
messages : [
{ role : 'system' , content : 'You are a helpful assistant.' },
{ role : 'user' , content : userMessage },
],
});
return response.choices ?.[0 ]?.message ?.content ?? '' ;
}
Step 2: Multi-Turn Conversation Manager
{
: | | ;
: ;
}
{
: [] = [];
: ;
: ;
( ) {
. = ({ : process. . });
. = model;
. . ({ : , : systemPrompt });
}
( : ): < > {
. . ({ : , : userMessage });
response = . . . ({
: . ,
: . ,
});
reply = response. ?.[ ]?. ?. ?? ;
. . ({ : , : reply });
reply;
}
(maxTurns = ): {
system = . [ ];
recent = . . ( ). (-maxTurns * );
. = [system, ...recent];
}
}
conv = ( );
conv. ( );
conv. ( );
interface
Message
role
'system'
'user'
'assistant'
content
string
class
MistralConversation
private
messages
Message
private
client
Mistral
private
model
string
constructor
systemPrompt : string , model = 'mistral-small-latest'
this
client
new
Mistral
apiKey
env
MISTRAL_API_KEY
this
model
this
messages
push
role
'system'
content
async
send
userMessage
string
Promise
string
this
messages
push
role
'user'
content
const
await
this
client
chat
complete
model
this
model
messages
this
messages
const
choices
0
message
content
''
this
messages
push
role
'assistant'
content
return
trimHistory
20
void
const
this
messages
0
const
this
messages
slice
1
slice
2
this
messages
const
new
MistralConversation
'You are a coding tutor.'
await
send
'How do I reverse a list in Python?'
await
send
'What about in-place?'
Step 3: Streaming Responses async function streamChat (
messages : Message [],
onChunk : (text: string ) => void ,
): Promise <string > {
const stream = await client.chat .stream ({
model : 'mistral-small-latest' ,
messages,
});
let full = '' ;
for await (const event of stream) {
const text = event.data ?.choices ?.[0 ]?.delta ?.content ;
if (text) {
full += text;
onChunk (text);
}
}
return full;
}
app.post ('/chat/stream' , async (req, res) => {
res.setHeader ('Content-Type' , 'text/event-stream' );
res.setHeader ('Cache-Control' , 'no-cache' );
res.setHeader ('Connection' , 'keep-alive' );
const stream = await client.chat .stream ({
model : 'mistral-small-latest' ,
messages : req.body .messages ,
});
for await (const event of stream) {
const content = event.data ?.choices ?.[0 ]?.delta ?.content ;
if (content) {
res.write (`data: ${JSON .stringify({ content })} \n\n` );
}
}
res.write ('data: [DONE]\n\n' );
res.end ();
});
Step 4: JSON Mode and JSON Schema Mode
const jsonResponse = await client.chat .complete ({
model : 'mistral-small-latest' ,
messages : [
{ role : 'user' , content : 'List 3 countries with capitals as JSON array.' },
],
responseFormat : { type : 'json_object' },
});
const data = JSON .parse (jsonResponse.choices ?.[0 ]?.message ?.content ?? '{}' );
const schemaResponse = await client.chat .complete ({
model : 'mistral-small-latest' ,
messages : [
{ role : 'user' , content : 'Classify this ticket: "Login page crashes on mobile"' },
],
responseFormat : {
type : 'json_schema' ,
jsonSchema : {
name : 'ticket_classification' ,
schema : {
type : 'object' ,
properties : {
category : { type : 'string' , enum : ['bug' , 'feature' , 'question' ] },
severity : { type : 'string' , enum : ['low' , 'medium' , 'high' , 'critical' ] },
summary : { type : 'string' },
},
required : ['category' , 'severity' , 'summary' ],
},
},
},
});
Step 5: Guardrails and Moderation
const safeResponse = await client.chat .complete ({
model : 'mistral-small-latest' ,
messages : [{ role : 'user' , content : userInput }],
safePrompt : true ,
});
const moderation = await client.classifiers .moderate ({
model : 'mistral-moderation-latest' ,
inputs : [userInput],
});
const flagged = moderation.results [0 ].categories ;
if (Object .values (flagged).some (Boolean )) {
throw new Error ('Content flagged by moderation' );
}
Step 6: Model Selection Guide type UseCase = 'realtime' | 'analysis' | 'code' | 'vision' | 'embedding' ;
const MODEL_MAP : Record <UseCase , { model : string ; note : string }> = {
realtime : { model : 'mistral-small-latest' , note : '256k ctx, fast, $0.1/M in' },
analysis : { model : 'mistral-large-latest' , note : '256k ctx, reasoning, $0.5/M in' },
code : { model : 'codestral-latest' , note : '256k ctx, code + FIM, $0.3/M in' },
vision : { model : 'pixtral-large-latest' , note : '128k ctx, multimodal' },
embedding : { model : 'mistral-embed' , note : '1024-dim vectors, $0.1/M in' },
};
function selectModel (use : UseCase ): string {
return MODEL_MAP [use].model ;
}
Output
Chat completions with configurable parameters
Multi-turn conversation management with history trimming
Real-time streaming responses
JSON and JSON Schema structured output
Content moderation via guardrails
Error Handling Error Cause Solution 401 UnauthorizedInvalid API key Verify MISTRAL_API_KEY 429 Rate LimitedRPM or TPM exceeded Implement backoff (see mistral-rate-limits) 400 Bad RequestInvalid model or params Check model ID and message format Context exceeded Too many tokens Trim conversation history Empty JSON response Missing instruction Tell model to respond in JSON in prompt
Resources
Next Steps For embeddings and function calling, see mistral-core-workflow-b.