Questa pagina descrive la gestione degli endpoint del modello. La gestione degli endpoint dei modelli ti consente di sperimentare la registrazione di un endpoint di modello di AI e l'invocazione delle previsioni.
Per utilizzare i modelli di AI negli ambienti di produzione, consulta Richiamare le previsioni online dalle istanze Cloud SQL.
Dopo aver aggiunto e registrato gli endpoint del modello nella gestione degli endpoint del modello, puoi farvi riferimento utilizzando l'ID modello per richiamare le previsioni.
Utilizza la funzione SQL mysql.ml_predict_row() per chiamare un endpoint del modello generico registrato per richiamare
le previsioni. Puoi utilizzare la funzione mysql.ml_predict_row() con qualsiasi tipo di modello.
MODEL_ID: l'ID modello che hai definito durante la registrazione dell'endpoint del modello
REQUEST_BODY: i parametri della funzione di previsione, in formato JSON
Esempi
Per generare previsioni per un endpoint del modello gemini-flash registrato, esegui la seguente istruzione:
SELECTJSON_EXTRACT(mysql.ml_predict_row('gemini-2.5-flash','{ "contents": [ { "role": "user", "parts": [ { "text": "For TPCH database schema as mentioned here https://www.tpc.org/TPC_Documents_Current_Versions/pdf/TPC-H_v3.0.1.pdf , generate a SQL query to find allsupplier names which are located in the India nation." } ]}] }'),'$.candidates[0].content.parts[0].text');
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[],[],null,["# Invoke predictions with model endpoint management\n\n| **Preview**\n|\n|\n| This product is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nMySQL \\| [PostgreSQL](/sql/docs/postgres/model-endpoint-predictions \"View this page for the PostgreSQL database engine\") \\| SQL Server\n\n\u003cbr /\u003e\n\nThis page describes model endpoint management. Model endpoint management lets you experiment with registering an AI model endpoint and invoking predictions.\n\nTo use AI models in\nproduction environments, see\n[Invoke online predictions from Cloud SQL instances](/sql/docs/mysql/invoke-online-predictions).\n\n\nAfter the model endpoints are added and registered in model endpoint management, you can\nreference them using the model ID to invoke predictions.\n\nBefore you begin\n----------------\n\nMake sure that you complete the following actions:\n\n- Register your model endpoint with model endpoint management. For more information, see [Register and call remote AI models using model endpoint management](/sql/docs/mysql/model-endpoint-register-model).\n- Create or update your Cloud SQL instance so that the instance can integrate with Vertex AI. For more information, see [Enable database integration with Vertex AI](/sql/docs/mysql/integrate-cloud-sql-with-vertex-ai#enable-database-integration-with-vertex-ai).\n\nInvoke predictions for generic models\n-------------------------------------\n\nUse the `mysql.ml_predict_row()` SQL function to call a registered generic model endpoint to invoke\npredictions. You can use `mysql.ml_predict_row()` function with any model type. \n\n SELECT\n mysql.ml_predict_row(\n '\u003cvar translate=\"no\"\u003eMODEL_ID\u003c/var\u003e',\n '\u003cvar translate=\"no\"\u003eREQUEST_BODY\u003c/var\u003e');\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eMODEL_ID\u003c/var\u003e: the model ID you defined when registering the model endpoint\n- \u003cvar translate=\"no\"\u003eREQUEST_BODY\u003c/var\u003e: the parameters to the prediction function, in JSON format\n\nExamples\n--------\n\nTo generate predictions for a registered `gemini-flash` model endpoint, run the following statement: \n\n SELECT JSON_EXTRACT(\n mysql.ml_predict_row(\n 'gemini-2.5-flash',\n '{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"For TPCH database schema as mentioned here https://www.tpc.org/TPC_Documents_Current_Versions/pdf/TPC-H_v3.0.1.pdf , generate a SQL query to find allsupplier names which are located in the India nation.\"\n } ]}]\n }'\n ),\n '$.candidates[0].content.parts[0].text'\n );"]]