If you imagine it, envision it, create it... Teradata makes it Possible. Join us. Register now.

Teradata makes it Possible. Join us. Register now.

  1. Developer Portal ...
  2. Downloads
  3. extensibility
  4. Open AI API connectivity functions
  1. Developer Portal
  2. Downloads
  3. extensibility
  4. Open AI API connectivity functions

Open AI API connectivity functions

Open AI API connectivity functions

Details

Teradata Table Operators for OpenAI-Compatible Inference Servers (v1.1.1)

This package ships two Java Table Operators (TO) that let Teradata SQL call OpenAI-compatible APIs directly from queries:

  • ChatCompletion – generates text via /v1/chat/completions
  • Embeddings – produces numeric embeddings via /v1/embeddings

Both are suitable for:

  • Enrichment data stored in Teradata with results of AI models running on inference servers
  • Feature engineering workflows
  • Operational pipelines requiring HTTP 429 rate-control resilience, custom headers, and optional TLS overrides

They are provider-agnostic (OpenAI, Azure OpenAI, NVIDIA Triton Inference Server, Ollama, etc.) so long as the service exposes OpenAI-compatible endpoints.


ChatCompletion and Embeddings: what they do, inputs, outputs

ChatCompletion

  • What/why: Calls a chat model to transform or generate text (summaries, answers, classifications).
  • Inputs:
    • Data input: table with txt column (VARCHAR or CLOB) as the prompt.
    • Optional TLS input: single-row BLOB cert for custom CA; cannot be used with IgnoreHTTPSVerification=True.
  • Outputs:
    • response_txt (VARCHAR(OutputTextLength))
    • Optional diagnostics: retries_made, last_attempt_duration, rate_limit_exceeded, rate_limit_exceeded_error_details

Embeddings

  • What/why: Calls an embeddings model to convert text into a numeric vector for search, RAG, clustering, etc.
  • Inputs:
    • Data input: table with txt column (VARCHAR or CLOB) as the input text.
    • Optional TLS input: single-row BLOB cert for custom CA; cannot be used with IgnoreHTTPSVerification=True.
  • Outputs (choose format with OutputFormat):
    • COLUMNAR (default): one FLOAT column per dimension, named by EmbeddingPrefix (default emb_0, emb_1, …).
    • BLOB: single BLOB column named embeddings with float32 bytes.
    • VARBYTE: single VARBYTE column named embeddings with float32 bytes.
    • Optional diagnostics as above.
  • Notes:
    • EmbeddingLength is required and defines vector length.
    • The client enforces that the API returns at least EmbeddingLength values; otherwise it errors.
    • EmbeddingPrefix is only valid for COLUMNAR output format; providing it for BLOB/VARBYTE errors.

Parameter availability (overview)

ParameterChatCompletionEmbeddings
BaseURLYesYes
ApiKeyYesYes
IgnoreHTTPSVerificationYesYes
HTTPProxyYesYes
CustomHeadersYesYes
BodyParametersYesYes
DelaysYesYes
RetriesNumberYesYes
ThrowErrorOnRateLimitYesYes
OutputProcessingDetailsYesYes
SystemMessageYesNo
OutputTextLengthYesNo
RemoveDeepSeekThinkingYesNo
EmbeddingLengthNoYes
OutputFormatNoYes
EmbeddingPrefixNoYes (COLUMNAR only)

Parameters (detailed)

Connection (both ChatCompletion and Embeddings)

ParameterMandatory?DefaultDescription
BaseURLYesBase URL of the inference server (root; not including /v1/chat/completions or /v1/embeddings).
ApiKeyNoIf provided, sent as Authorization: Bearer <APIKEY>. If omitted, no Authorization header is added.
IgnoreHTTPSVerificationNoFalseIf True, disables hostname and certificate verification (dev/test only). Cannot be used together with the TLS certificate table input.
HTTPProxyNo-HTTP proxy server address in host:port format (e.g., proxy.example.com:8080). If only the host is provided, port defaults to 80. If omitted, no proxy is used

Request (both ChatCompletion and Embeddings)

ParameterMandatory?DefaultDescription
ModelYesTarget model name.
BodyParametersNoNoneList of <name>:<value> pairs added directly into the JSON body. Values may be integers, floats, booleans, strings (must be wrapped in double quotes), arrays, or JSON objects.
Example: BodyParameters('temperature:0.1','max_tokens:100','response_format:{"type":"json_object"}','stop:["END"]','metadata:"abc"')
Notes: strings must be quoted; numbers/booleans/objects/arrays should be unquoted JSON. Unknown names pass through as-is.

Headers (both ChatCompletion and Embeddings)

ParameterMandatory?DefaultDescription
CustomHeadersNoNoneList of Key:Value headers to add to the HTTP request.

Rate control (both ChatCompletion and Embeddings)

ParameterMandatory?DefaultDescription
DelaysNo500Comma-separated list of retry delays in ms for HTTP 429. If RetriesNumber exceeds the list, the last delay is reused.
RetriesNumberNo0Number of retries after hitting rate control (HTTP 429).
ThrowErrorOnRateLimitNoFalseIf True and still rate-limited after retries, the function throws an error; if False, the response is NULL/empty and diagnostics indicate rate limit.

Diagnostics (both ChatCompletion and Embeddings)

ParameterMandatory?DefaultDescription
OutputProcessingDetailsNoFalseAdds diagnostic columns: retries_made (INT), last_attempt_duration (INT, ms), rate_limit_exceeded (INT; 0/1), rate_limit_exceeded_error_details (VARCHAR(3000)).

ChatCompletion-only

ParameterMandatory?DefaultDescription
SystemMessageYesSystem role instruction for the assistant’s behavior.
OutputTextLengthNo16000Size of VARCHAR field for response_txt (2–32000).
RemoveDeepSeekThinkingNoFalseIf True, strips <think>...</think> blocks from responses.

Embeddings-only

ParameterMandatory?DefaultDescription
EmbeddingLengthYesPositive integer specifying the vector length the function outputs. The client enforces that the API returns at least this many values.
OutputFormatNoCOLUMNAROne of COLUMNAR, BLOB, VARBYTE.
- COLUMNAR: one FLOAT column per dimension (EmbeddingPrefix0..N-1).
- BLOB: single embeddings BLOB with float32 bytes.
- VARBYTE: single embeddings VARBYTE with float32 bytes.
EmbeddingPrefixNoemb_Column name prefix for COLUMNAR format (e.g., emb_0, emb_1, ...). If provided with BLOB or VARBYTE, an error is thrown.

Example usage

Example Usage - Embeddings

SELECT *
FROM openai_client.Embeddings(
    ON (SELECT id, txt FROM emails.emails)
    ON (SELECT cert FROM sasha.pem_files WHERE id = 'cert') DIMENSION
    USING
        BaseURL('http://192.168.178.32:11434')
        Model('qwen2.5-coder:7b')
        ApiKey('FAKE-API-KEY')

        Delays('200,400,800')
        RetriesNumber(5)
        OutputProcessingDetails('True')
        ThrowErrorOnRateLimit('False')

        OutputFormat('BLOB')
        EmbeddingPrefix('superemb_')
        BodyParameters('metadata:{"activity": "embeddings function test"}')
) AS a;

Output

idtxtembeddingsretries_madelast_attempt_durationrate_limit_exceededrate_limit_exceeded_error_details
19I recently had a discussion...BINARY DATA21500NULL

Example Usage - CompleteChat

SELECT *
FROM openai_client.CompleteChat(
    ON (SELECT id, txt FROM emails.emails)
    ON (SELECT cert FROM sasha.pem_files WHERE id = 'cert') DIMENSION
    USING
        BaseURL('http://192.168.178.32:11434')
        SystemMessage('You are the text summarizer. Summarize in ≤10 words.')
        Model('qwen2.5-coder:7b')
        ApiKey('FAKE-API-KEY')

        BodyParameters(
            'temperature:0.1',
            'max_tokens:100',
            'response_format:{"type":"json_object"}',
            'metadata:"summary_job"'
        )

        Delays('200,400,800')
        RetriesNumber(5)
        OutputProcessingDetails('True')
        ThrowErrorOnRateLimit('False')

        CustomHeaders(
            'tachyon_x: XXXXXXX',
            'tachyon_y: YYYYY'
        )
) AS a;

Output

idtxtresponse_txtretries_madelast_attempt_durationrate_limit_exceededrate_limit_exceeded_error_details
19I recently had a discussion...{"date":"July 7th","location":"Berlin","to...21500NULL

Installation

  1. Create database and grant permissions:
CREATE DATABASE openai_client AS PERM = <8000000 * number of AMPs>;
DATABASE openai_client;
GRANT CREATE EXTERNAL PROCEDURE ON openai_client TO dbc;
GRANT CREATE FUNCTION ON openai_client TO dbc;
  1. Install the JAR:
CALL SQLJ.INSTALL_JAR(
  'cj!<path to openai.client-1.1.1.jar on a client machine including file name>',
  'OPENAI_CLIENT',
  0
);
  1. Create/replace the functions:
REPLACE FUNCTION openai_client.CompleteChat()
RETURNS TABLE VARYING USING FUNCTION OpenAIClientTO_contract
LANGUAGE JAVA
NO SQL
PARAMETER STYLE SQLTable
EXTERNAL NAME 'OPENAI_CLIENT:com.teradata.openai.client.ChatCompletionTO.execute()';

REPLACE FUNCTION openai_client.Embeddings()
RETURNS TABLE VARYING USING FUNCTION EmbeddingsTO_contract
LANGUAGE JAVA
NO SQL
PARAMETER STYLE SQLTable
EXTERNAL NAME 'OPENAI_CLIENT:com.teradata.openai.client.EmbeddingsTO.execute()';       
  1. Grant execution rights:
GRANT EXECUTE FUNCTION ON openai_client TO <desired_user>;

Notes

  • TLS certificates: Provide via the optional cert input table if your server requires a custom CA. Cannot be used with IgnoreHTTPSVerification=True.
  • Rate limiting: Retries are handled using Delays and RetriesNumber. Diagnostics are available with OutputProcessingDetails.
  • DeepSeek: Use RemoveDeepSeekThinking('True') to strip <think> blocks.
  • Embeddings length: EmbeddingLength must match your planned output size; the client enforces that the API returns at least that many values.
  • Output choice for embeddings:
    • COLUMNAR: best for SQL analytics, direct filtering/aggregation.
    • BLOB/VARBYTE: compact binary storage (float32) in a single column named embeddings; ideal for storage or external tooling.
Not available
OS version
1.1.1
Release version

Specifications

  • Version
  • Released
  • TTU
  • OS
  • Teradata

Open AI API connectivity functions