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 registeredgemini-1.5-pro:streamGenerateContentmodel endpoint, run the following statement:
SELECTjson_array_elements(google_ml.predict_row(model_id=>'gemini-1.5-pro:streamGenerateContent',reques>t_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 s>upplier names w>hich> are located> in the In>dia >nation." } ] } ] }'))-'candidates'-0-'content'-'parts'-0-'text';
To generate predictions for a registeredfacebook/bart-large-mnlimodel endpoint on Hugging Face, run the following statement:
SELECTgoogle_ml.predict_row(model_id=>'facebook/bart-large-mnli',reques>t_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 Anthropicclaude-3-opus-20240229model 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-09-04 UTC."],[],[],null,["Select a documentation version: 16-nextkeyboard_arrow_down\n\n- [17-next](/alloydb/omni/containers/17-next/docs/ai/model-endpoint-predictions)\n- [16-next](/alloydb/omni/containers/16-next/docs/ai/model-endpoint-predictions)\n- [Current (16.8.0)](/alloydb/omni/containers/current/docs/ai/model-endpoint-predictions)\n- [16.8.0](/alloydb/omni/containers/16.8.0/docs/ai/model-endpoint-predictions)\n- [16.3.0](/alloydb/omni/containers/16.3.0/docs/ai/model-endpoint-predictions)\n- [15-next](/alloydb/omni/containers/15-next/docs/ai/model-endpoint-predictions)\n- [15.12.0](/alloydb/omni/containers/15.12.0/docs/ai/model-endpoint-predictions)\n- [15.7.1](/alloydb/omni/containers/15.7.1/docs/ai/model-endpoint-predictions)\n- [15.7.0](/alloydb/omni/containers/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\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/containers/16-next/docs/ai/register-model-endpoint).\n\nInvoke predictions for generic models\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\"\u003e#39;MODE\u003c/var\u003eL_ID',\n reques\u003et_\u003cvar translate=\"no\"\u003ebody\u003c/var\u003e = 'REQUEST_BODY');\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\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 reques\u003et_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 s\u003eupplier names w\u003ehich\u003e are located\u003e in the In\u003edia \u003enation." } ] } ] }'))- 'candidates' - 0 - 'content' - 'parts' - 0 - '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 reques\u003et_body =\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 }');"]]