Skip to main content

Call a remote scoring model

Register an HTTP inference endpoint and verify the request, response, and numeric score.

The practical problem and model​

A team may already serve a model behind an HTTP API and want to call it from SQL without reimplementing inference inside the database. A remote model gives that endpoint a typed SQL signature. Gnok batches the calls, retries failures within the limits you set, and returns the scores like any other SQL function.

This tutorial calls a demo scorer that Gnok hosts for this tutorial. It takes three numeric inputs and applies a fixed formula, sigmoid(-1 + 0.5 × input1 + 2 × input2 − input3). It demonstrates real HTTP inference, but it is not a trained risk model, and you can't use it for your own data or models.

The Studio title mentions SageMaker and Vertex. The Studio script also contains commented-out SageMaker and Vertex AI templates (variants B and C). They need your own endpoints and credentials, and they are not part of this walkthrough.

Before you run​

Complete the shared setup. This walkthrough uses synthetic data and recreates its tutorial objects. Use a sandbox tenant or schema, and run the steps in order.

Studio: Tutorial: Remote Model (SageMaker / Vertex / Custom HTTP). Download the complete SQL.

The endpoint in Step 1 is the address of Gnok's demo scorer inside the hosted service. Run the SQL as written; you don't need to set up or host anything. The address is reachable only from Gnok's query service, not from your browser or network.

Your own remote models

Your own remote models must be reachable on the public internet; use HTTPS. Gnok refuses loopback, link-local, and private-network addresses, so a server on your laptop or inside your private network can't be called. The demo scorer is the one internal endpoint the service allows.

Step 1: Register the endpoint contract​

The declared three-argument signature must match the scorer's expected instance width. Timeout, retry, and batch options bound how Gnok calls the endpoint.

CREATE CATALOG IF NOT EXISTS tutorial;

CREATE SCHEMA IF NOT EXISTS tutorial.remote;

CREATE OR REPLACE REMOTE MODEL tutorial.remote.scoring_v1
(DOUBLE, DOUBLE, DOUBLE)
RETURNS DOUBLE
ENDPOINT 'http://demo-model-server.gnok-demo.svc.cluster.local:7799/score'
OPTIONS (
request_format = 'json',
timeout_ms = 3000,
max_retries = 3,
batch_size = 32
);

SHOW MODELS;

Step 2: Check a known input​

For (0.4, 0.91, 0.03), the formula's logit is 0.99. This lets you verify the returned value independently of HTTP success.

SELECT tutorial.remote.scoring_v1(0.4, 0.91, 0.03) AS p_score;

What to check in the results​

The scalar result should be approximately 0.729088 (0.7290879223), which is sigmoid(0.99). SHOW MODELS should list the qualified remote model.

With request_format = 'json', Gnok sends {"instances": [[0.4, 0.91, 0.03]]} and the demo scorer returns {"predictions": [0.7290879223493065]}: one prediction per instance, in order. A valid HTTP response with the wrong number of predictions is not a successful inference result.

Adapt it to real data​

Use an authenticated, public HTTPS endpoint for remote-model calls. Match its batch request/response shape, or use the sagemaker or vertex request format for those platforms. A timeout can leave the remote request running; keep inference idempotent and budget retries accordingly.

Measure latency, throughput, rate limits, and failure behavior with representative batches. Keep credentials out of SQL text, and authorize the data sent to the external service.

Model runtime reference

All tutorials · Setup and troubleshooting