io.enterpriseai.resources.GatewayClient
Source: sdks/java/enterprise-ai-java/src/main/java/io/enterpriseai/resources/GatewayClient.java. Back to the Java SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Class GatewayClient
AI Gateway, the only path agents use to call models (OpenAI compatible bodies plus the eai extension).
Constructor GatewayClient
GatewayClient(Transport transport)
Creates the client on the shared transport; EnterpriseAIClient builds it and exposes it through the accessor of the same name.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
transport | Transport | yes | Transport shared by the sub-clients of one client. |
GatewayClient.audioSpeech
byte[] audioSpeech(Object body)
Synthesize speech from text. Text to speech through the TTS adapter, in the OpenAI audio/speech format; the audio comes back as is (audio/*). The tenant kill switch, data classification and caller clearance, secret isolation and audit apply, and the cost is reserved from the quotas by number of characters. Requires a tenant principal with the scope models:invoke. Without a configured adapter: 501 adapter_not_available; adapter unreachable: 502 upstream_error.
Route: /v1/gateway/audio/speech (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | OpenAI speech request (model, input, voice, response_format...) plus the optional eai object (data_classification, agent_id, run_id). |
Returns: byte[]. Decoded JSON answer of the operation "Synthesize speech from text".
Raises: the typed errors of the transport (Errors).
GatewayClient.audioTranscriptions
JsonNode audioTranscriptions(Object body)
Transcribe an audio file. Speech to text through the STT adapter, in the OpenAI audio/transcriptions format. Requires a tenant principal with the scope models:invoke.
Route: /v1/gateway/audio/transcriptions (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Multipart file plus model, language, prompt, response_format (json, text, srt, verbose_json, vtt), temperature (0 to 1), timestamp_granularities (word, segment) and eai (a JSON object as text); or JSON with content_base64, mime_type, filename and the same fields. |
Returns: JsonNode. Decoded JSON answer of the operation "Transcribe an audio file".
Raises: the typed errors of the transport (Errors).
GatewayClient.audioTranscriptions
JsonNode audioTranscriptions(Object body, RequestOptions options)
Transcribe an audio file. Speech to text through the STT adapter, in the OpenAI audio/transcriptions format. Requires a tenant principal with the scope models:invoke.
Route: /v1/gateway/audio/transcriptions (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Multipart file plus model, language, prompt, response_format (json, text, srt, verbose_json, vtt), temperature (0 to 1), timestamp_granularities (word, segment) and eai (a JSON object as text); or JSON with content_base64, mime_type, filename and the same fields. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Transcribe an audio file".
Raises: the typed errors of the transport (Errors).
GatewayClient.chatCompletions
ChatResponse chatCompletions(ChatRequest request)
Call a chat model. OpenAI compatible chat completion through every control of the gateway; with stream: true the answer is Server-Sent Events, with the cost guardrails checked during the stream. Requires a tenant principal (403 platform_only) whose credential carries the scope models:invoke.
Route: /v1/gateway/chat/completions (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
request | ChatRequest | yes | OpenAI chat request (model is the registry id, messages, stream, max_tokens, tools...) plus the optional eai object: data_classification (public, internal by default, confidential, restricted, secret), agent_id, session_id, run_id, purpose, project_id, effort, max_cost, fallback_policy and allow lists that can only narrow the tenant ones (provider_allow, model_allow, region_allow). |
Returns: ChatResponse. A ChatResponse: Chat completion response with the gateway headers.
Raises: the typed errors of the transport (Errors).
GatewayClient.chatCompletions
ChatResponse chatCompletions(ChatRequest request, RequestOptions options)
Call a chat model. OpenAI compatible chat completion through every control of the gateway; with stream: true the answer is Server-Sent Events, with the cost guardrails checked during the stream. Requires a tenant principal (403 platform_only) whose credential carries the scope models:invoke.
Route: /v1/gateway/chat/completions (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
request | ChatRequest | yes | OpenAI chat request (model is the registry id, messages, stream, max_tokens, tools...) plus the optional eai object: data_classification (public, internal by default, confidential, restricted, secret), agent_id, session_id, run_id, purpose, project_id, effort, max_cost, fallback_policy and allow lists that can only narrow the tenant ones (provider_allow, model_allow, region_allow). | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: ChatResponse. A ChatResponse: Chat completion response with the gateway headers.
Raises: the typed errors of the transport (Errors).
GatewayClient.chatCompletionsRaw
JsonNode chatCompletionsRaw(Object body)
Call a chat model. OpenAI compatible chat completion through every control of the gateway; with stream: true the answer is Server-Sent Events, with the cost guardrails checked during the stream. Requires a tenant principal (403 platform_only) whose credential carries the scope models:invoke.
Route: /v1/gateway/chat/completions (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | OpenAI chat request (model is the registry id, messages, stream, max_tokens, tools...) plus the optional eai object: data_classification (public, internal by default, confidential, restricted, secret), agent_id, session_id, run_id, purpose, project_id, effort, max_cost, fallback_policy and allow lists that can only narrow the tenant ones (provider_allow, model_allow, region_allow). |
Returns: JsonNode. Decoded JSON answer of the operation "Call a chat model".
Raises: the typed errors of the transport (Errors).
GatewayClient.chatCompletionsRaw
JsonNode chatCompletionsRaw(Object body, RequestOptions options)
Call a chat model. OpenAI compatible chat completion through every control of the gateway; with stream: true the answer is Server-Sent Events, with the cost guardrails checked during the stream. Requires a tenant principal (403 platform_only) whose credential carries the scope models:invoke.
Route: /v1/gateway/chat/completions (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | OpenAI chat request (model is the registry id, messages, stream, max_tokens, tools...) plus the optional eai object: data_classification (public, internal by default, confidential, restricted, secret), agent_id, session_id, run_id, purpose, project_id, effort, max_cost, fallback_policy and allow lists that can only narrow the tenant ones (provider_allow, model_allow, region_allow). | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Call a chat model".
Raises: the typed errors of the transport (Errors).
GatewayClient.chatCompletionsStream
ChatStream chatCompletionsStream(ChatRequest request)
Call a chat model. OpenAI compatible chat completion through every control of the gateway; with stream: true the answer is Server-Sent Events, with the cost guardrails checked during the stream. Requires a tenant principal (403 platform_only) whose credential carries the scope models:invoke.
Route: /v1/gateway/chat/completions (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
request | ChatRequest | yes | OpenAI chat request (model is the registry id, messages, stream, max_tokens, tools...) plus the optional eai object: data_classification (public, internal by default, confidential, restricted, secret), agent_id, session_id, run_id, purpose, project_id, effort, max_cost, fallback_policy and allow lists that can only narrow the tenant ones (provider_allow, model_allow, region_allow). |
Returns: ChatStream. A ChatStream: Streamed chat completion: an Iterator of chunks, a Stream or a Flow.Publisher.
Raises: the typed errors of the transport (Errors).
GatewayClient.chatCompletionsStream
ChatStream chatCompletionsStream(ChatRequest request, RequestOptions options)
Call a chat model. OpenAI compatible chat completion through every control of the gateway; with stream: true the answer is Server-Sent Events, with the cost guardrails checked during the stream. Requires a tenant principal (403 platform_only) whose credential carries the scope models:invoke.
Route: /v1/gateway/chat/completions (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
request | ChatRequest | yes | OpenAI chat request (model is the registry id, messages, stream, max_tokens, tools...) plus the optional eai object: data_classification (public, internal by default, confidential, restricted, secret), agent_id, session_id, run_id, purpose, project_id, effort, max_cost, fallback_policy and allow lists that can only narrow the tenant ones (provider_allow, model_allow, region_allow). | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: ChatStream. A ChatStream: Streamed chat completion: an Iterator of chunks, a Stream or a Flow.Publisher.
Raises: the typed errors of the transport (Errors).
GatewayClient.embeddings
JsonNode embeddings(Object body)
Compute embeddings. OpenAI compatible embeddings through the same controls as chat (kill switches, allow lists, classification, DLP on each input, cost guardrails, policy decision, audit). The model must declare the embeddings capability and, when dimensions is given, support it (422 capability_not_supported, 422 embedding_dimensions_invalid). Requires a tenant principal with the scope models:invoke.
Route: /v1/gateway/embeddings (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | OpenAI embeddings request (model, input as a text or a list, optional dimensions) plus the optional eai object. |
Returns: JsonNode. Decoded JSON answer of the operation "Compute embeddings".
Raises: the typed errors of the transport (Errors).
GatewayClient.embeddings
JsonNode embeddings(Object body, RequestOptions options)
Compute embeddings. OpenAI compatible embeddings through the same controls as chat (kill switches, allow lists, classification, DLP on each input, cost guardrails, policy decision, audit). The model must declare the embeddings capability and, when dimensions is given, support it (422 capability_not_supported, 422 embedding_dimensions_invalid). Requires a tenant principal with the scope models:invoke.
Route: /v1/gateway/embeddings (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | OpenAI embeddings request (model, input as a text or a list, optional dimensions) plus the optional eai object. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Compute embeddings".
Raises: the typed errors of the transport (Errors).
GatewayClient.estimate
JsonNode estimate(Object body)
Estimate a gateway call. Runs every preflight control of the gateway without calling the model and returns the resolved model, decision id, input tokens, maximum output tokens, estimator, estimated cost, cost limit, fallbacks, warnings and context plan. A request refused by a control answers with the same error as the real call. Requires a tenant principal with the scope models:invoke.
Route: /v1/gateway/estimate (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | The body of the call to estimate, with optional kind (chat, embeddings or rerank); without kind it is guessed from input (embeddings) or query (rerank), else chat. |
Returns: JsonNode. Decoded JSON answer of the operation "Estimate a gateway call".
Raises: the typed errors of the transport (Errors).
GatewayClient.estimate
JsonNode estimate(Object body, RequestOptions options)
Estimate a gateway call. Runs every preflight control of the gateway without calling the model and returns the resolved model, decision id, input tokens, maximum output tokens, estimator, estimated cost, cost limit, fallbacks, warnings and context plan. A request refused by a control answers with the same error as the real call. Requires a tenant principal with the scope models:invoke.
Route: /v1/gateway/estimate (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | The body of the call to estimate, with optional kind (chat, embeddings or rerank); without kind it is guessed from input (embeddings) or query (rerank), else chat. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Estimate a gateway call".
Raises: the typed errors of the transport (Errors).
GatewayClient.imageGenerations
JsonNode imageGenerations(Object body)
Generate images. Image generation through the image adapter in the OpenAI format. The prompt goes through the DLP of the tenant (422 dlp_blocked), the kill switch, classification, secret isolation and audit apply, and the cost is reserved by number of images; text fields of the answer (revised_prompt) are scanned too. Requires a tenant principal with the scope models:invoke. Without a configured adapter: 501 adapter_not_available.
Route: /v1/gateway/images/generations (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | OpenAI image request (model, prompt, n, size...) plus the optional eai object. |
Returns: JsonNode. Decoded JSON answer of the operation "Generate images".
Raises: the typed errors of the transport (Errors).
GatewayClient.imageGenerations
JsonNode imageGenerations(Object body, RequestOptions options)
Generate images. Image generation through the image adapter in the OpenAI format. The prompt goes through the DLP of the tenant (422 dlp_blocked), the kill switch, classification, secret isolation and audit apply, and the cost is reserved by number of images; text fields of the answer (revised_prompt) are scanned too. Requires a tenant principal with the scope models:invoke. Without a configured adapter: 501 adapter_not_available.
Route: /v1/gateway/images/generations (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | OpenAI image request (model, prompt, n, size...) plus the optional eai object. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Generate images".
Raises: the typed errors of the transport (Errors).
GatewayClient.rerank
JsonNode rerank(Object body)
Rerank documents. Reranks documents against a query through the same controls as chat (DLP on the query, cost guardrails, policy decision, audit). The model must declare the rerank capability (422 capability_not_supported). Requires a tenant principal with the scope models:invoke.
Route: /v1/gateway/rerank (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Rerank request: model, query, documents (texts or objects), optional top_n, plus the optional eai object. |
Returns: JsonNode. Decoded JSON answer of the operation "Rerank documents".
Raises: the typed errors of the transport (Errors).
GatewayClient.rerank
JsonNode rerank(Object body, RequestOptions options)
Rerank documents. Reranks documents against a query through the same controls as chat (DLP on the query, cost guardrails, policy decision, audit). The model must declare the rerank capability (422 capability_not_supported). Requires a tenant principal with the scope models:invoke.
Route: /v1/gateway/rerank (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Rerank request: model, query, documents (texts or objects), optional top_n, plus the optional eai object. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Rerank documents".
Raises: the typed errors of the transport (Errors).
GatewayClient.videoGeneration
JsonNode videoGeneration(String id)
Read a video generation job. State and result of a video generation job, read from the video adapter with the same kill switch and audit as the other adapter calls. Requires a tenant principal (403 platform_only otherwise) whose credential carries the scope models:invoke. Without a configured video adapter: 501 adapter_not_available.
Route: /v1/gateway/video/generations/{job_id} (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
id | String | yes | Identifier of the job returned by POST /v1/gateway/video/generations. |
Returns: JsonNode. Decoded JSON answer of the operation "Read a video generation job".
Raises: the typed errors of the transport (Errors).
GatewayClient.videoGenerations
JsonNode videoGenerations(Object body)
Start a video generation. Starts a video generation job on the video adapter, with the same kill switch, classification, DLP of the prompt, cost reservation and audit as the other adapters; read the job with GET /v1/gateway/video/generations/{job_id}. Requires a tenant principal with the scope models:invoke. Without a configured adapter: 501 adapter_not_available.
Route: /v1/gateway/video/generations (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Video generation request of the adapter (model, prompt and its options) plus the optional eai object. |
Returns: JsonNode. Decoded JSON answer of the operation "Start a video generation".
Raises: the typed errors of the transport (Errors).
GatewayClient.videoGenerations
JsonNode videoGenerations(Object body, RequestOptions options)
Start a video generation. Starts a video generation job on the video adapter, with the same kill switch, classification, DLP of the prompt, cost reservation and audit as the other adapters; read the job with GET /v1/gateway/video/generations/{job_id}. Requires a tenant principal with the scope models:invoke. Without a configured adapter: 501 adapter_not_available.
Route: /v1/gateway/video/generations (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
body | Object | yes | Video generation request of the adapter (model, prompt and its options) plus the optional eai object. | |
options | RequestOptions | yes | Per call options (idempotency key, traceparent, headers, abort signal). |
Returns: JsonNode. Decoded JSON answer of the operation "Start a video generation".
Raises: the typed errors of the transport (Errors).