Skip to content

Mistral

The UC AI Mistral package integrates Mistral AI’s models (La Plateforme) into your Oracle database applications.

  • Support for the latest Mistral models (Mistral Large, Medium, Small, Magistral, Codestral, Ministral)
  • Full function calling (tools) support
  • Reasoning models (Magistral)
  • Multi-modal support (text, images)
  • Structured output support
  • Embeddings support (mistral-embed, codestral-embed)
  1. Mistral API key
  2. Oracle database with internet access to Mistral’s API endpoints (see Network Setup (ACL & Wallet))
  3. UC AI package installed
  4. Set up API key (guide)

You can get an API key by signing up at Mistral La Plateforme.

To use your Mistral key with APEX Web Credentials, create a new web credential in your APEX workspace (Workspace Utilities → Web Credentials) with the following configuration:

  • Authentication Type: HTTP Header
  • Credential Name: Authorization
  • Credential Secret: Bearer <your_api_key>

Also set Valid for URLs to the Mistral API (https://api.mistral.ai/) to limit the scope of the credential.

To use the web credential in your PL/SQL code, set the package variable uc_ai_mistral.g_apex_web_credential to the static ID of your web credential before calling any UC AI functions:

uc_ai_mistral.g_apex_web_credential := 'MISTRAL';

Mistral offers a range of models optimized for different use cases. The UC AI Mistral package provides constants for the current models:

  • uc_ai_mistral.c_model_mistral_large - Mistral Large
  • uc_ai_mistral.c_model_mistral_medium - Mistral Medium, a multimodal model
  • uc_ai_mistral.c_model_mistral_small - Mistral Small, a multimodal model
  • uc_ai_mistral.c_model_zai_glm_5_2 - Z.ai GLM 5.2, served on the Mistral platform
  • uc_ai_mistral.c_model_ministral_3_14b - Ministral 3 14B
  • uc_ai_mistral.c_model_ministral_8b - Ministral 8B
  • uc_ai_mistral.c_model_ministral_3b - Ministral 3B
  • uc_ai_mistral.c_model_codestral - Optimized for code generation tasks
  • uc_ai_mistral.c_model_mistral_embed - General purpose text embeddings
  • uc_ai_mistral.c_model_codestral_embed - Code-specific embeddings

Most of these constants hold a -latest name, such as mistral-small-latest. Mistral resolves such a name to the newest version of that model family. The two embedding constants hold a fixed name. c_model_ministral_3_14b and c_model_zai_glm_5_2 hold a fixed name too, because Mistral documents no -latest alias for them.

Mistral marks the Magistral, Devstral, and Pixtral models as deprecated. The package keeps the constants c_model_magistral_medium, c_model_magistral_small, c_model_devstral_medium, c_model_devstral_small, and c_model_pixtral_large for code that still references them.

See Mistral’s models documentation for the latest model information and capabilities.

declare
l_result json_object_t;
begin
l_result := uc_ai.generate_text(
p_user_prompt => 'What is Oracle APEX?',
p_provider => uc_ai.c_provider_mistral,
p_model => uc_ai_mistral.c_model_mistral_small
);
dbms_output.put_line('AI Response: ' || l_result.get_string('final_message'));
end;
/
declare
l_result json_object_t;
begin
l_result := uc_ai.generate_text(
p_user_prompt => 'I have tomatoes, salad, potatoes, olives, and cheese. What can I cook with that?',
p_system_prompt => 'You are an assistant helping users to get recipes. Please answer in short sentences.',
p_provider => uc_ai.c_provider_mistral,
p_model => uc_ai_mistral.c_model_mistral_small
);
dbms_output.put_line('Recipe: ' || l_result.get_string('final_message'));
end;
/

Mistral models support tools/function calling. You can define tools in your application and the model will call them as needed.

declare
l_result json_object_t;
begin
-- Ensure tools are set up in UC_AI_TOOLS table
uc_ai.g_enable_tools := true;
l_result := uc_ai.generate_text(
p_user_prompt => 'What is the email address of Jim?',
p_system_prompt => 'You are an assistant to a time tracking system. Your tools give you access to user, project and timetracking information. Answer concise and short.',
p_provider => uc_ai.c_provider_mistral,
p_model => uc_ai_mistral.c_model_mistral_small
);
dbms_output.put_line('AI Response: ' || l_result.get_string('final_message'));
end;
/

See the tools guide for details on how to set up and use tools.

Mistral’s multimodal models (Mistral Small/Medium, Pixtral) support vision capabilities for image analysis.

declare
l_messages json_array_t := json_array_t();
l_content json_array_t := json_array_t();
l_result json_object_t;
begin
l_messages.append(uc_ai_message_api.create_system_message(
'You are an image analysis assistant.'));
l_content.append(uc_ai_message_api.create_file_content(
p_media_type => 'image/webp',
p_data_blob => your_image_blob,
p_filename => 'image.webp'
));
l_content.append(uc_ai_message_api.create_text_content(
'What is depicted in the attached image?'
));
l_messages.append(uc_ai_message_api.create_user_message(l_content));
l_result := uc_ai.generate_text(
p_messages => l_messages,
p_provider => uc_ai.c_provider_mistral,
p_model => uc_ai_mistral.c_model_mistral_small
);
dbms_output.put_line('Analysis: ' || l_result.get_string('final_message'));
end;
/

Mistral handles reasoning through dedicated models instead of a request parameter: pick a Magistral model and it reasons by default. There is no reasoning effort setting for Mistral — uc_ai.g_enable_reasoning and uc_ai.g_reasoning_level are ignored for this provider.

declare
l_result json_object_t;
begin
l_result := uc_ai.generate_text(
p_user_prompt => 'Answer in one sentence. If there is a great filter, are we before or after it and why.',
p_provider => uc_ai.c_provider_mistral,
p_model => uc_ai_mistral.c_model_magistral_small
);
dbms_output.put_line('AI Response: ' || l_result.get_string('final_message'));
end;
/

Mistral supports structured output with JSON schemas:

declare
l_result json_object_t;
l_schema json_object_t;
l_final_message clob;
l_structured_output json_object_t;
begin
-- Define your JSON schema
l_schema := json_object_t('{
"name": "confidence_response",
"strict": true,
"schema": {
"type": "object",
"properties": {
"response": {
"type": "string",
"description": "The answer to the question"
},
"confidence": {
"type": "number",
"description": "Confidence level between 0 and 1"
}
},
"required": ["response", "confidence"],
"additionalProperties": false
}
}');
l_result := uc_ai.generate_text(
p_user_prompt => 'What is the capital of France? Please respond with confidence.',
p_system_prompt => 'You are a helpful assistant that provides accurate information.',
p_provider => uc_ai.c_provider_mistral,
p_model => uc_ai_mistral.c_model_mistral_small,
p_response_json_schema => l_schema
);
l_final_message := l_result.get_clob('final_message');
l_structured_output := json_object_t(l_final_message);
dbms_output.put_line('Response: ' || l_structured_output.get_string('response'));
dbms_output.put_line('Confidence: ' || l_structured_output.get_number('confidence'));
end;
/

Mistral offers embedding models for semantic search and retrieval use cases:

declare
l_result json_array_t;
begin
l_result := uc_ai.generate_embeddings(
p_input => json_array_t('["Oracle APEX is a low-code development platform."]'),
p_provider => uc_ai.c_provider_mistral,
p_model => uc_ai_mistral.c_model_mistral_embed
);
dbms_output.put_line('Embedding dimensions: ' ||
treat(l_result.get(0) as json_array_t).get_size);
end;
/