-
Book Overview & Buying
-
Table Of Contents
AI-Ready PostgreSQL 18
By :
Once you've seen embeddings created from a simple Python script, the next natural question is: can the database create embeddings directly? Next, we'll do exactly that, by teaching PostgreSQL how to call the OpenAI embeddings API from inside the database using PL/PythonU.
A quick recap of what we discussed in Chapter 6, Functions and Stored Procedures: The U in PL/PythonU stands for untrusted. It is considered untrusted because it grants full access to the underlying OS, network, and files. That's why it typically requires elevated privileges and is best used in a controlled demo or a carefully governed capability. For learning and clarity, it's perfect. For production, you'll often move this call into a service layer. But for now, we want something simple, direct, and runnable.
The embedding API expects three things:
text-embedding-3-small)