MODEL_ID: the model ID you defined when registering the model endpoint.
REQUEST_BODY: the parameters to the prediction function, in JSON format.
Examples
This section includes some examples for invoking predictions using registered model endpoints.
To generate predictions for a registered gemini-1.5-pro:streamGenerateContent model endpoint, run the following statement:
SELECTjson_array_elements(google_ml.predict_row(model_id=>'gemini-1.5-pro:streamGenerateContent',request_body=>'{ "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 all supplier names which are located in the India nation." } ] } ] }'))->'candidates'->0->'content'->'parts'->0->'text';
To generate predictions for a registered facebook/bart-large-mnli model endpoint on Hugging Face, run the following statement:
SELECTgoogle_ml.predict_row(model_id=>'facebook/bart-large-mnli',request_body=>
'{ "inputs": "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!", "parameters": {"candidate_labels": ["refund", "legal", "faq"]} }');
To generate predictions for a registered Anthropic claude-3-opus-20240229 model endpoint, run the following statement:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eThis page outlines how to use the \u003ccode\u003egoogle_ml.predict_row()\u003c/code\u003e SQL function to invoke predictions from registered model endpoints.\u003c/p\u003e\n"],["\u003cp\u003eBefore invoking predictions, you must first register your model endpoint with the Model endpoint management, as detailed in the linked documentation.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egoogle_ml.predict_row()\u003c/code\u003e function requires two parameters: the \u003ccode\u003eMODEL_ID\u003c/code\u003e representing your registered endpoint, and the \u003ccode\u003eREQUEST_BODY\u003c/code\u003e in JSON format specifying the prediction input.\u003c/p\u003e\n"],["\u003cp\u003eExamples are provided demonstrating how to generate predictions for different registered model endpoints, including \u003ccode\u003egemini-1.5-pro:streamGenerateContent\u003c/code\u003e, \u003ccode\u003efacebook/bart-large-mnli\u003c/code\u003e, and \u003ccode\u003eclaude-3-opus-20240229\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Invoke predictions with model endpoint management\n\nSelect a documentation version: 15.7.0keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/ai/model-endpoint-predictions)\n- [16.8.0](/alloydb/omni/16.8.0/docs/ai/model-endpoint-predictions)\n- [16.3.0](/alloydb/omni/16.3.0/docs/ai/model-endpoint-predictions)\n- [15.12.0](/alloydb/omni/15.12.0/docs/ai/model-endpoint-predictions)\n- [15.7.1](/alloydb/omni/15.7.1/docs/ai/model-endpoint-predictions)\n- [15.7.0](/alloydb/omni/15.7.0/docs/ai/model-endpoint-predictions)\n\n\u003cbr /\u003e\n\nThis page describes how to invoke predictions using the model endpoints registered in the Model endpoint management.\n\n\u003cbr /\u003e\n\nBefore you begin\n----------------\n\nMake sure that you have registered your model endpoint with Model endpoint management.\nFor more information, see [Register and call remote AI models in AlloyDB Omni](/alloydb/omni/15.7.0/docs/ai/register-model-endpoint).\n\nInvoke predictions for generic models\n-------------------------------------\n\nUse the `google_ml.predict_row()` SQL function to call a registered generic model endpoint to invoke\npredictions. \n\n SELECT\n google_ml.predict_row(\n model_id =\u003e '\u003cvar translate=\"no\"\u003eMODEL_ID\u003c/var\u003e',\n request_body =\u003e '\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\nThis section includes some examples for invoking predictions using registered model endpoints.\n\nTo generate predictions for a registered `gemini-1.5-pro:streamGenerateContent` model endpoint, run the following statement: \n\n SELECT\n json_array_elements( google_ml.predict_row( model_id =\u003e 'gemini-1.5-pro:streamGenerateContent',\n request_body =\u003e '{ \"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 all supplier names which are located in the India nation.\" } ] } ] }'))-\u003e 'candidates' -\u003e 0 -\u003e 'content' -\u003e 'parts' -\u003e 0 -\u003e 'text';\n\nTo generate predictions for a registered `facebook/bart-large-mnli` model endpoint on Hugging Face, run the following statement: \n\n SELECT\n google_ml.predict_row(\n model_id =\u003e 'facebook/bart-large-mnli',\n request_body =\u003e\n '{\n \"inputs\": \"Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!\",\n \"parameters\": {\"candidate_labels\": [\"refund\", \"legal\", \"faq\"]}\n }'\n );\n\nTo generate predictions for a registered Anthropic `claude-3-opus-20240229` model endpoint, run the following statement: \n\n SELECT\n google_ml.predict_row('anthropic-opus', '{\n \"model\": \"claude-3-opus-20240229\",\n \"max_tokens\": 1024,\n \"messages\": [\n {\"role\": \"user\", \"content\": \"Hello, world\"}\n ]\n }');"]]