Enable Mistral models on Google Cloud Vertex AI and query them as serverless endpoints for chat and fill-in-the-middle completion.
Mistral AI's open and commercial models can be deployed on the Google Cloud Vertex AI platform as fully managed endpoints. Mistral models on Vertex AI are serverless services, so you don't have to manage any infrastructure.
As of today, the following models are available:
Mistral Medium 3 (25.05)
Codestral 2 (25.08)
Mistral OCR (25.05)
Mistral Small (25.03)
Getting Started
The following sections outline the steps to deploy and query a Mistral model on the Vertex AI platform.
Requesting access to the model
The following items are required:
Access to a Google Cloud Project with the Vertex AI API enabled.
Relevant IAM permissions to enable the model and query endpoints through the following roles:
To enable the model of your choice, navigate to its card in the Vertex Model Garden catalog, then click on "Enable".
Querying the model (chat completion)
Available models expose a REST API that you can query using Mistral's SDKs or plain HTTP calls.
To run the examples below:
Install the gcloud CLI to authenticate against the Google Cloud APIs. Refer to this page for more details.
Set the following environment variables:
VERTEX_MODEL_NAME: The name of the model to query (e.g., mistral-large).
VERTEX_MODEL_VERSION: The version of the model to query (e.g., 2407).
(V1 only)GOOGLE_CLOUD_REGION: The target cloud region.
(V1 only)GOOGLE_CLOUD_PROJECT_ID: The name of your project.
# This code requires the following packages: mistralai[gcp] (version >= `1.0.0`)import osfrom mistralai_gcp import MistralGoogleCloudregion = os.environ.get("GOOGLE_CLOUD_REGION")project_id = os.environ.get("GOOGLE_CLOUD_PROJECT_ID")model_name = os.environ.get("VERTEX_MODEL_NAME")model_version = os.environ.get("VERTEX_MODEL_VERSION")client = MistralGoogleCloud(region=region, project_id=project_id)resp = client.chat.complete( model=f"{model_name}-{model_version}", messages=[ { "role": "user", "content": "Who is the best French painter? Answer in one short sentence.", } ],)print(resp.choices[0].message.content)
# This code requires the following packages: mistralai>=2.0.0import osfrom mistralai.gcp.client import MistralGCPmodel_name = os.environ.get("VERTEX_MODEL_NAME")model_version = os.environ.get("VERTEX_MODEL_VERSION")# Auth is automatic via google.auth.default(); region defaults to "europe-west4"# You can still override: MistralGCP(region="us-central1", project_id="my-project")client = MistralGCP()resp = client.chat.complete( model=f"{model_name}-{model_version}", messages=[ { "role": "user", "content": "Who is the best French painter? Answer in one short sentence.", } ],)print(resp.choices[0].message.content)
// This code requires the following package: @mistralai/mistralai-gcp (version >= `1.0.0`)import { MistralGoogleCloud } from "@mistralai/mistralai-gcp";const client = new MistralGoogleCloud({ region: process.env.GOOGLE_CLOUD_REGION || "", projectId: process.env.GOOGLE_CLOUD_PROJECT_ID || "",});const modelName = process.env.VERTEX_MODEL_NAME || "";const modelVersion = process.env.VERTEX_MODEL_VERSION || "";async function chatCompletion(user_msg: string) { const resp = await client.chat.complete({ model: modelName + "-" + modelVersion, messages: [ { content: user_msg, role: "user", }, ], }); if (resp.choices && resp.choices.length > 0) { console.log(resp.choices[0]); }}chatCompletion("Who is the best French painter? Answer in one short sentence.");
base_url="https://\$GOOGLE_CLOUD_REGION-aiplatform.googleapis.com/v1/projects/\$GOOGLE_CLOUD_PROJECT_ID/locations/\$GOOGLE_CLOUD_REGION/publishers/mistralai/models"model_version="\$VERTEX_MODEL_NAME@\$VERTEX_MODEL_VERSION"url="\$base_url/\$model_version\:rawPredict"curl --location $url\ --header "Content-Type: application/json" \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ --data '{ "model": "'"\$VERTEX_MODEL_NAME"'", "temperature": 0, "messages": [ {"role": "user", "content": "Who is the best French painter? Answer in one short sentence."} ], "stream": false }'
Querying the model (FIM completion)
Codestral can be queried using an additional completion mode called fill-in-the-middle (FIM).