[[["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-28 UTC."],[],[],null,["# Generate vector embeddings 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\n[MySQL](/sql/docs/mysql/model-endpoint-embeddings \"View this page for the MySQL database engine\") \\| PostgreSQL \\| SQL Server\n\n\u003cbr /\u003e\n\nThis page describes how to register an AI model endpoint\nand generate vector embeddings with model endpoint management.\n\nTo use AI models in\nproduction environments, see [Build generative AI applications using\nCloud SQL](/sql/docs/postgres/ai-overview) and [Work with vector embeddings](/sql/docs/postgres/work-with-vectors).\n\n\nAfter the model endpoints are added and registered in model endpoint management, you can\nreference them using the model ID to generate embeddings.\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/postgres/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/postgres/integrate-cloud-sql-with-vertex-ai#enable-database-integration-with-vertex-ai).\n\nGenerate embeddings\n-------------------\n\nUse the `google_ml.embedding()` SQL function to call the registered model endpoint with\nthe text embedding model type to generate embeddings.\n\nTo call the model and generate embeddings, use the following SQL query: \n\n SELECT\n google_ml.embedding(\n model_id =\u003e '\u003cvar translate=\"no\"\u003eMODEL_ID\u003c/var\u003e',\n content =\u003e '\u003cvar translate=\"no\"\u003eCONTENT\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\"\u003eCONTENT\u003c/var\u003e: the text to translate into a vector embedding\n\nExamples\n--------\n\nSome examples for generating embeddings using registered model endpoints are listed in this section.\n\n### Text embedding models with built-in support\n\nTo generate embeddings for a registered `textembedding-gecko@002` model endpoint,\nrun the following statement: \n\n SELECT\n google_ml.embedding(\n model_id =\u003e 'textembedding-gecko@002',\n content =\u003e 'Cloud SQL is a managed, cloud-hosted SQL database service');"]]