Skip to content

Testing GoldenGate AI Service without a replicat

In a previous blog, I set up the AI Service with a free Gemini key. I wrote that nothing tells you whether a provider and a model work until a replicat processes a row. After a bit of research, I found that this is only partially true. The AI Service has an embed endpoint that can be called directly without creating a replicat. This blog shows how to call it.

Calling the AI Service with Python or curl

The AI Service listens on a unix socket in the var/run directory of the Service Manager deployment. The replicat sends its requests to POST /api/v1/embed on this socket, and Python or curl can send the same request. The http://localhost part of the URL is only a placeholder, since the socket decides where the request goes.

In Python, the requests library does not speak to unix sockets by itself. A small adapter, saved as aiservice.py, mounts the socket on a session, and the Python examples below use it:

import socket

import requests
from requests.adapters import HTTPAdapter
from urllib3.connection import HTTPConnection
from urllib3.connectionpool import HTTPConnectionPool


class UnixConnection(HTTPConnection):
    def __init__(self, *args, socket_path, **kwargs):
        super().__init__("localhost", *args, **kwargs)
        self.socket_path = socket_path

    def connect(self):
        self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        self.sock.settimeout(self.timeout)
        self.sock.connect(self.socket_path)


class UnixPool(HTTPConnectionPool):
    def __init__(self, socket_path, **kwargs):
        super().__init__("localhost", **kwargs)
        self.socket_path = socket_path

    def _new_conn(self):
        return UnixConnection(socket_path=self.socket_path, timeout=self.timeout.connect_timeout)


class UnixAdapter(HTTPAdapter):
    def __init__(self, socket_path, **kwargs):
        self.socket_path = socket_path
        super().__init__(**kwargs)

    def get_connection_with_tls_context(self, request, verify, proxies=None, cert=None):
        return UnixPool(self.socket_path)


def session(socket_path):
    s = requests.Session()
    s.mount("http://", UnixAdapter(socket_path))
    return s

Listing the registered models first shows what can be called:

>>> from aiservice import session
>>> s = session("/u01/ogg/deployments/ogg26sm/var/run/AIService.sock")
>>> models = s.get("http://localhost/api/v1/models").json()["response"]["models"]
>>> [{k: m[k] for k in ("id", "type", "enabled", "capabilities", "providerId", "remoteModelName", "limits")} for m in models if m["id"] == "gemini_embed"]
[{'id': 'gemini_embed', 'type': 'remote', 'enabled': True, 'capabilities': ['embed'], 'providerId': 'gemini', 'remoteModelName': 'gemini-embedding-001', 'limits': {'maxInputCharacters': 6000}}]

The same listing with curl and jq:

Questions about your own setup? A dbi services consultant can look at your case.

Talk to an expert (opens in a new tab)
$ S=/u01/ogg/deployments/ogg26sm/var/run/AIService.sock
$ curl -s --unix-socket $S http://localhost/api/v1/models | jq -c '.response.models[] | select(.id=="gemini_embed") | {id,type,enabled,capabilities,providerId,remoteModelName,limits}'
{"id":"gemini_embed","type":"remote","enabled":true,"capabilities":["embed"],"providerId":"gemini","remoteModelName":"gemini-embedding-001","limits":{"maxInputCharacters":6000}}

A working embed call

The body of the request names the model and gives a list of items, each with an id and a text. This is the call a replicat makes for each row with an @AISERVICE mapping:

>>> body = {"model": "gemini_embed", "items": [{"id": "0", "text": "GoldenGate AI Service test"}]}
>>> r = s.post("http://localhost/api/v1/embed", json=body).json()["response"]
>>> {"modelUsed": r["modelUsed"], "processedCount": r["processedCount"], "errorCount": r["errorCount"], "errors": r["errors"], "dimensions": r["data"][0]["dimensions"]}
{'modelUsed': 'gemini_embed', 'processedCount': 1, 'errorCount': 0, 'errors': [], 'dimensions': 3072}

The full response contains the 3072 floats of the vector, which is why jq reduces it here. Two fields tell whether the call worked: processedCount and errorCount. The dimensions value is the size of the VECTOR column the target table needs, so this call also gives the dimension for the column definition.

Several items can be sent in the same call, and each one comes back with its id:

>>> body = {"model": "gemini_embed", "items": [{"id": "a", "text": "first text"}, {"id": "b", "text": "second text"}]}
>>> r = s.post("http://localhost/api/v1/embed", json=body).json()["response"]
>>> {"processedCount": r["processedCount"], "errorCount": r["errorCount"], "ids": [d["id"] for d in r["data"]]}
{'processedCount': 2, 'errorCount': 0, 'ids': ['a', 'b']}

HTTP 200 can still be a failure

Before the certificates of Gemini were trusted by the Service Manager, the same call returned HTTP/1.1 200 OK. The failure was in the body, in errors, with processedCount at 0:

{"data":[],"errors":[{"id":"0","error":{"code":"REMOTE_INFERENCE_FAILED","message":"SSL connection unexpectedly closed","retriable":true}}],"processedCount":0,"errorCount":1}

The messages array of the same response gives the reason, which is more precise than the message of the error:

OGG-12984 The remote peer submitted a certificate that failed validation.
OGG-12983 Invalid certificate details:
Server Peer submitted Invalid Certificate:

Server Peer certificate info -
       Version: NZTTVERSION_X509v3
   Issuer Name: CN=WE2,O=Google Trust Services,C=US

A test of this endpoint has to check errorCount and data, never the HTTP status. The details list the trusted certificates as well. Only GTS Root R1 and WR2 were there, while Google now issues the certificate of the endpoint from WE2. The chain sent by the server shows it:

$ echo | openssl s_client -showcerts -connect generativelanguage.googleapis.com:443 2>/dev/null | grep -E "^ *[0-9] s:|^   i:"
 0 s:CN=upload.video.google.com
   i:C=US, O=Google Trust Services, CN=WE2
 1 s:C=US, O=Google Trust Services, CN=WE2
   i:C=US, O=Google Trust Services LLC, CN=GTS Root R4
 2 s:C=US, O=Google Trust Services LLC, CN=GTS Root R4
   i:C=BE, O=GlobalSign nv-sa, OU=Root CA, CN=GlobalSign Root CA

The fix is to register WE2 and GTS Root R4 as trusted certificates in the Service Manager, with the procedure to register certificates in GoldenGate. A chain registered from an older procedure stops working when the provider changes its issuer.

A wrong model name

An unknown model is refused before any provider is called, and this time the HTTP status is a real error:

>>> r = s.post("http://localhost/api/v1/embed", json={"model": "nope_embed", "items": [{"id": "0", "text": "x"}]})
>>> r.status_code
400
>>> {k: r.json()["messages"][0][k] for k in ("code", "severity", "title")}
{'code': 'OGG-12124', 'severity': 'ERROR', 'title': "The value of property 'model' is not valid"}

A model that is registered but cannot reach its provider is not refused at this step. It fails when the provider is called, as in the previous section.

Summary

To test the AI Service without a replicat:

  • Call POST /api/v1/embed on the AIService.sock socket of the Service Manager deployment, with Python.
  • Read processedCount, errorCount and errors in the response, never the HTTP status: a failed provider call still returns HTTP/1.1 200 OK.
  • Read the messages array for the cause. A certificate failure names the issuer that is not trusted.
  • Take the dimensions value of the response for the VECTOR column of the target table.
  • Expect an unknown model to return HTTP 400 with OGG-12124.

Let’s work together

Ready to operate at
the next level?

Tell us about your challenge. We’ll bring the depth, the expertise, and the Swiss precision.

Julien Delattre

Julien Delattre

Julien Delattre, member of the Oracle Team Zurich, has more than five years of experience specializing in Oracle databases, plus expertise in MariaDB and MongoDB. Prior to dbi services, he was a Database Administrator at Atos in Angers, France, and a Data Scientist at Air France in Paris and Apurata in Lima. Julien holds a Master's degree in Computer Science, Data Science, and Statistics from Centrale Paris / Université Paris-Saclay.View Author posts

89 posts since October 2025

Most read in Oracle

The Oracle posts our readers open most: the all-time favourites, and what is trending right now.

Leave a Comment

Your email address will not be published. Required fields are marked *