Skip to content

AI client

AI client · Type

What mash.ai.client() returns: the OpenAI client builder, with the same methods scripts already call (withApiKey, withOrganization, withProject, withBaseUri, withHttpHeader, withQueryParam, make).

It used to return OpenAI\Factory itself. Its base URI is the script’s, and it takes any HTTP client or stream handler, so a script could send requests (with its API key) to loopback, the cluster network or a metadata address. Here the base URI is checked when it is set, the client make() builds sends every request through the run’s destination guard (SecurityProvider: no internal or reserved address unless an administrator allowed it, each redirect checked again, the address pinned), and supplying a transport of the script’s own is refused. Added 2026-09-30 (A11 audit, finding H3b).

ai.absoluteUri(uri: string) → string

A base URI with no scheme is https, as OpenAI\ValueObjects\Transporter\BaseUri reads it.

ai.isGuarded(client: object) → bool

Whether make() built this client (and so every request it sends is guarded).

ai.make() → Client

No description yet.

ai.withApiKey(apiKey: string) → OpenAIFactory

No description yet.

ai.withBaseUri(baseUri: string) → OpenAIFactory

The base URI, as OpenAI\Factory reads it: no scheme means https. The host is checked now, so a refused one fails where the script names it; every request is checked again when it is sent.

ai.withHttpClient(args?: mixed)

Refused: the transport is what carries the destination guard.

ai.withHttpHeader(name: string, value: string) → OpenAIFactory

No description yet.

ai.withOrganization(organization: string) → OpenAIFactory

No description yet.

ai.withProject(project: string) → OpenAIFactory

No description yet.

ai.withQueryParam(name: string, value: string) → OpenAIFactory

No description yet.

ai.withStreamHandler(args?: mixed)

Refused: a stream handler would send streamed requests without the guard.