Gateway reference
Method signatures, parameters, responses and examples for gateway.
Use a configured server-side nirmos client from the quickstart. See the gateway guide for prerequisites and workflows. Example IDs and configured model names are placeholders; replace them with organization-visible resources before executing. Mutating calls change live resources.
HTTP calls reject with APIError subclasses on unsuccessful HTTP responses and may throw NetworkError, TimeoutError or RequestAbortedError. Signatures describe SDK values after response decoding; they are not raw HTTP envelopes. Backend validation, permissions and feature availability remain authoritative.
| Method | Transport |
|---|---|
gateway.chat.create | Runtime |
gateway.chat.stream | Runtime |
gateway.embeddings.create | Runtime |
gateway.images.generate | Runtime |
gateway.chat.create
Generate a normalized chat completion.
Runtime: POST /v1/chat/completions.
Credentials: Personal or service API key with the required grants.
Types: ChatCreateParams · RequestOptions · ChatCompletion
nirmos.gateway.chat.create(
params: ChatCreateParams,
options?: RequestOptions | undefined
): Promise<ChatCompletion>| Parameter | Required | Type / default |
|---|---|---|
params | Yes | ChatCreateParams |
options | No | RequestOptions | undefined |
Request fields
Choose one of these source-defined alternatives; requirements apply within each alternative.
Alternative 1
| Field | Required | Type |
|---|---|---|
conversation | No | { id: string; } | undefined |
memory | No | { enabled: false; } | undefined |
privacy | No | ChatCreateParams["privacy"] |
messages | No | readonly ChatMessage[] | undefined |
prompt | No | PromptReference | undefined |
temperature | No | number | undefined |
topP | No | number | undefined |
maxOutputTokens | No | number | undefined |
stop | No | string | readonly string[] | undefined |
tools | No | readonly FunctionTool[] | undefined |
toolChoice | No | ToolChoice | undefined |
responseFormat | No | ResponseFormat | undefined |
seed | No | number | undefined |
user | No | string | undefined |
provider | No | string | undefined |
providerOptions | No | Readonly<Record<string, Readonly<Record<string, JsonValue>>>> | undefined |
fallbackModels | No | readonly string[] | undefined |
routingStrategy | No | RoutingStrategy | undefined |
metadata | No | Readonly<Record<string, JsonValue>> | undefined |
model | Yes | string |
route | No | undefined |
Alternative 2
| Field | Required | Type |
|---|---|---|
conversation | No | { id: string; } | undefined |
memory | No | { enabled: false; } | undefined |
privacy | No | ChatCreateParams["privacy"] |
messages | No | readonly ChatMessage[] | undefined |
prompt | No | PromptReference | undefined |
temperature | No | number | undefined |
topP | No | number | undefined |
maxOutputTokens | No | number | undefined |
stop | No | string | readonly string[] | undefined |
tools | No | readonly FunctionTool[] | undefined |
toolChoice | No | ToolChoice | undefined |
responseFormat | No | ResponseFormat | undefined |
seed | No | number | undefined |
user | No | string | undefined |
provider | No | string | undefined |
providerOptions | No | Readonly<Record<string, Readonly<Record<string, JsonValue>>>> | undefined |
fallbackModels | No | readonly string[] | undefined |
routingStrategy | No | RoutingStrategy | undefined |
metadata | No | Readonly<Record<string, JsonValue>> | undefined |
route | Yes | string |
model | No | undefined |
Returns: ChatCompletion.
Behavior: Provide exactly one model or route and nonempty messages after prompt rendering. Tools are returned to your application; the SDK does not execute them. Provider capability checks remain server-side.
Example
const result = await nirmos.gateway.chat.create({
"model": "configured/chat-model",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
});gateway.chat.stream
Stream chat events and assemble a final completion.
Runtime: POST /v1/chat/completions.
Credentials: Personal or service API key with the required grants.
Types: ChatCreateParams · RequestOptions · ChatStream
nirmos.gateway.chat.stream(
params: ChatCreateParams,
options?: RequestOptions | undefined
): Promise<ChatStream>| Parameter | Required | Type / default |
|---|---|---|
params | Yes | ChatCreateParams |
options | No | RequestOptions | undefined |
Request fields
Choose one of these source-defined alternatives; requirements apply within each alternative.
Alternative 1
| Field | Required | Type |
|---|---|---|
conversation | No | { id: string; } | undefined |
memory | No | { enabled: false; } | undefined |
privacy | No | ChatCreateParams["privacy"] |
messages | No | readonly ChatMessage[] | undefined |
prompt | No | PromptReference | undefined |
temperature | No | number | undefined |
topP | No | number | undefined |
maxOutputTokens | No | number | undefined |
stop | No | string | readonly string[] | undefined |
tools | No | readonly FunctionTool[] | undefined |
toolChoice | No | ToolChoice | undefined |
responseFormat | No | ResponseFormat | undefined |
seed | No | number | undefined |
user | No | string | undefined |
provider | No | string | undefined |
providerOptions | No | Readonly<Record<string, Readonly<Record<string, JsonValue>>>> | undefined |
fallbackModels | No | readonly string[] | undefined |
routingStrategy | No | RoutingStrategy | undefined |
metadata | No | Readonly<Record<string, JsonValue>> | undefined |
model | Yes | string |
route | No | undefined |
Alternative 2
| Field | Required | Type |
|---|---|---|
conversation | No | { id: string; } | undefined |
memory | No | { enabled: false; } | undefined |
privacy | No | ChatCreateParams["privacy"] |
messages | No | readonly ChatMessage[] | undefined |
prompt | No | PromptReference | undefined |
temperature | No | number | undefined |
topP | No | number | undefined |
maxOutputTokens | No | number | undefined |
stop | No | string | readonly string[] | undefined |
tools | No | readonly FunctionTool[] | undefined |
toolChoice | No | ToolChoice | undefined |
responseFormat | No | ResponseFormat | undefined |
seed | No | number | undefined |
user | No | string | undefined |
provider | No | string | undefined |
providerOptions | No | Readonly<Record<string, Readonly<Record<string, JsonValue>>>> | undefined |
fallbackModels | No | readonly string[] | undefined |
routingStrategy | No | RoutingStrategy | undefined |
metadata | No | Readonly<Record<string, JsonValue>> | undefined |
route | Yes | string |
model | No | undefined |
Returns: ChatStream.
Behavior: Consume once. Wait for iteration to finish before finalResponse(). Early loop exit cancels the body and does not produce a final completion. Stream consumption is not retried.
Example
const result = await nirmos.gateway.chat.stream({
"route": "production-chat",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
});gateway.embeddings.create
Embed text with a directly selected physical model.
Runtime: POST /v1/embeddings.
Credentials: Personal or service API key with the required grants.
Types: EmbeddingCreateParams · RequestOptions · EmbeddingResponse
nirmos.gateway.embeddings.create(
params: EmbeddingCreateParams,
options?: RequestOptions | undefined
): Promise<EmbeddingResponse>| Parameter | Required | Type / default |
|---|---|---|
params | Yes | EmbeddingCreateParams |
options | No | RequestOptions | undefined |
Request fields
| Field | Required | Type |
|---|---|---|
model | Yes | string |
input | Yes | string | readonly string[] |
dimensions | No | number | undefined |
encoding | No | "float" | "base64" | undefined |
user | No | string | undefined |
provider | No | string | undefined |
providerOptions | No | Readonly<Record<string, Readonly<Record<string, JsonValue>>>> | undefined |
fallbackModels | No | readonly string[] | undefined |
routingStrategy | No | RoutingStrategy | undefined |
Returns: EmbeddingResponse.
Behavior: fallbackModels and routingStrategy remain in the type but are deprecated and rejected by runtime. Dimensions and encoding depend on provider support.
Example
const result = await nirmos.gateway.embeddings.create({
"model": "configured/embedding-model",
"input": [
"Support policy"
]
});gateway.images.generate
Generate images through the legacy normalized SDK interface.
Runtime: POST /v1/images/generations.
Credentials: Personal or service API key with the required grants.
Types: ImageGenerateParams · RequestOptions · ImageGeneration
nirmos.gateway.images.generate(
params: ImageGenerateParams,
options?: RequestOptions | undefined
): Promise<ImageGeneration>| Parameter | Required | Type / default |
|---|---|---|
params | Yes | ImageGenerateParams |
options | No | RequestOptions | undefined |
Request fields
| Field | Required | Type |
|---|---|---|
storage | No | { mode: "transient" | "temporary" | "persistent"; ttlSeconds?: number | undefined; } | undefined |
model | Yes | string |
prompt | Yes | string |
count | No | number | undefined |
outputCompression | No | number | undefined |
safetyIdentifier | No | string | undefined |
moderation | No | "auto" | "low" | undefined |
size | No | ImageSize | undefined |
quality | No | ExtensibleString<"auto" | "low" | "standard" | "hd" | "medium" | "high"> | undefined |
style | No | ExtensibleString<"natural" | "vivid"> | undefined |
format | No | ExtensibleString<"png" | "jpeg" | "webp"> | undefined |
responseFormat | No | "base64" | "url" | undefined |
background | No | ExtensibleString<"auto" | "transparent" | "opaque"> | undefined |
user | No | string | undefined |
provider | No | string | undefined |
providerOptions | No | Readonly<Record<string, Readonly<Record<string, JsonValue>>>> | undefined |
metadata | No | Readonly<Record<string, JsonValue>> | undefined |
Returns: ImageGeneration.
Behavior: Legacy camel-case parameters and normalized images remain supported. Use images.generate for the standard OpenAI response. Image POST requests never retry automatically.
Example
const result = await nirmos.gateway.images.generate({
"model": "openai/gpt-image-2.5-flare",
"prompt": "A modern electric motorcycle",
"count": 1
});