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, Codestral, Ministral, Z.ai GLM)
- Full function calling (tools) support
- Reasoning in Mistral Small 4
- 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 web credential in your APEX workspace. You can use the APEX user interface or PL/SQL.
Go to Workspace Utilities â Web Credentials and create a web credential 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.
Connect to the schema that holds UC AI, then run this block. Replace <your_api_key> with your API key. The p_allowed_urls parameter limits the credential to the Mistral API.
Outside an APEX session, for example in SQLcl, uncomment the apex_util.set_workspace call. Replace MY_WORKSPACE with the name of the APEX workspace associated with your schema.
begin -- apex_util.set_workspace(p_workspace => 'MY_WORKSPACE');
apex_credential.create_credential( p_credential_name => 'MISTRAL', p_credential_static_id => 'MISTRAL', p_authentication_type => apex_credential.C_TYPE_HTTP_HEADER, p_allowed_urls => apex_t_varchar2('https://api.mistral.ai/'), p_prompt_on_install => false, p_credential_comment => 'Credential for Mistral' );
apex_credential.set_persistent_credentials( p_credential_static_id => 'MISTRAL', p_key => 'Authorization', p_value => 'Bearer <your_api_key>' );
commit;end;/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_3_flash- Z.ai GLM 5.3 Flash, a smaller and cheaper model, served on the Mistral platformuc_ai_mistral.c_model_zai_glm_5_3- Z.ai GLM 5.3, served on the Mistral platform
Edge Models
Section titled âEdge Modelsâuc_ai_mistral.c_model_ministral_3_14b- Ministral 3 14B
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 constants use an alias ending in -latest, such as mistral-small-latest. Mistral maps this alias to the newest version of that model family.
The two embedding constants use fixed model IDs. So do c_model_ministral_3_14b, c_model_zai_glm_5_3, and c_model_zai_glm_5_3_flash, because Mistral documents no -latest alias for them.
This list shows the newest model of each family. The package keeps the constants of older models for code that still references them.
Retired Models
Section titled âRetired ModelsâMistral retired the Magistral, Devstral, Pixtral, Ministral 8B, and Ministral 3B models. Requests to them fail. The package keeps the constants c_model_magistral_medium, c_model_magistral_small, c_model_devstral_medium, c_model_devstral_small, c_model_pixtral_large, c_model_ministral_8b, and c_model_ministral_3b for code that still references them.
Mistral deprecated Z.ai GLM 5.2 on 2026-09-29 and retires it on 2026-10-31. Use c_model_zai_glm_5_3 instead of c_model_zai_glm_5_2.
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;/PDF Analysis
Section titled âPDF AnalysisâA chat model reads a PDF that you attach to a message. UC AI sends the PDF to Mistral as a document_url content part with a Base64 data:application/pdf URL. Use create_file_content with the media type application/pdf, as in the image example above.
declare l_messages json_array_t := json_array_t(); l_content json_array_t := json_array_t(); l_result json_object_t; l_pdf blob;begin select blob_content into l_pdf from your_table where id = 1;
l_messages.append(uc_ai_message_api.create_system_message( 'You are an assistant answering trivia questions about TV shows. Answer in one short sentence.'));
l_content.append(uc_ai_message_api.create_file_content( p_media_type => 'application/pdf', p_data_blob => l_pdf, p_filename => 'characters.pdf' ));
l_content.append(uc_ai_message_api.create_text_content( 'What is the TV show of the characters in the attached PDF?' ));
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('Answer: ' || l_result.get_clob('final_message'));end;/For a PDF with a table of TV show characters, a call on 2026-09-30 with mistral-small-latest printed Answer: The characters are from the TV show "The Office.". The wording of the answer can differ between calls.
See the file analysis guide for more file examples. To get the text and the structure of a document instead of an answer, use OCR.
Reasoning / Thinking
Section titled âReasoning / ThinkingâUC AI does not send a reasoning effort parameter to Mistral. The variables uc_ai.g_enable_reasoning and uc_ai.g_reasoning_level have no effect for this provider. Mistral retired the dedicated Magistral reasoning models. Mistral Small 4 supports instruction tasks, reasoning, and coding.
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_mistral_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;/uc_ai.ocr reads PDFs and images with the Mistral OCR models. The result holds the text as Markdown, the pages, and the blocks with their positions. The constant uc_ai_mistral.c_model_mistral_ocr holds mistral-ocr-latest. This model is the default for uc_ai.ocr. The constant uc_ai_mistral.c_model_mistral_ocr_4_1 holds mistral-ocr-4-1.
OCR models do not work with generate_text. Use them only with uc_ai.ocr and uc_ai.ocr_text.
declare l_text clob;begin l_text := uc_ai.ocr_text( p_document => your_pdf_blob, p_media_type => 'application/pdf', p_provider => uc_ai.c_provider_mistral );end;/The OCR requests use the same credential as the chat requests. See the OCR reference for the result, the options and the URL overload.