Mistral
The UC AI Mistral package integrates Mistral AIâs models (La Plateforme) into your Oracle database applications.
Features
Section titled âFeaturesâ- 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)
Prerequisites
Section titled âPrerequisitesâ- Mistral API key
- Oracle database with internet access to Mistralâs API endpoints (see Network Setup (ACL & Wallet))
- UC AI package installed
- Set up API key (guide)
You can get an API key by signing up at Mistral La Plateforme.
Creating a Web Credential
Section titled âCreating a Web Credentialâ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:
Generalist Models
Section titled âGeneralist Modelsâuc_ai_mistral.c_model_mistral_large- Mistral Largeuc_ai_mistral.c_model_mistral_medium- Mistral Medium, a multimodal modeluc_ai_mistral.c_model_mistral_small- Mistral Small, a multimodal modeluc_ai_mistral.c_model_zai_glm_5_2- Z.ai GLM 5.2, served on the Mistral platform
Edge Models
Section titled âEdge Modelsâuc_ai_mistral.c_model_ministral_3_14b- Ministral 3 14Buc_ai_mistral.c_model_ministral_8b- Ministral 8Buc_ai_mistral.c_model_ministral_3b- Ministral 3B
Specialized Models
Section titled âSpecialized Modelsâuc_ai_mistral.c_model_codestral- Optimized for code generation tasks
Embedding Models
Section titled âEmbedding Modelsâuc_ai_mistral.c_model_mistral_embed- General purpose text embeddingsuc_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.
Retired Models
Section titled âRetired Modelsâ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.
Usage Examples
Section titled âUsage ExamplesâBasic Text Generation
Section titled âBasic Text Generationâ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;/With System Prompt
Section titled âWith System Promptâ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;/Using Tools/Function Calling
Section titled âUsing Tools/Function Callingâ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.
Multi-modal Analysis
Section titled âMulti-modal AnalysisâMistralâs multimodal models (Mistral Small/Medium, Pixtral) support vision capabilities for image analysis.
Image Analysis
Section titled â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;/Reasoning / Thinking
Section titled âReasoning / Thinkingâ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;/Structured Output
Section titled âStructured Outputâ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;/Embeddings
Section titled âEmbeddingsâ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;/