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).
Methods
Section titled “Methods”absoluteUri
Section titled “absoluteUri”ai.absoluteUri(uri: string) → string
A base URI with no scheme is https, as OpenAI\ValueObjects\Transporter\BaseUri reads it.
isGuarded
Section titled “isGuarded”ai.isGuarded(client: object) → bool
Whether make() built this client (and so every request it sends is guarded).
ai.make() → Client
No description yet.
withApiKey
Section titled “withApiKey”ai.withApiKey(apiKey: string) → OpenAIFactory
No description yet.
withBaseUri
Section titled “withBaseUri”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.
withHttpClient
Section titled “withHttpClient”ai.withHttpClient(args?: mixed)
Refused: the transport is what carries the destination guard.
withHttpHeader
Section titled “withHttpHeader”ai.withHttpHeader(name: string, value: string) → OpenAIFactory
No description yet.
withOrganization
Section titled “withOrganization”ai.withOrganization(organization: string) → OpenAIFactory
No description yet.
withProject
Section titled “withProject”ai.withProject(project: string) → OpenAIFactory
No description yet.
withQueryParam
Section titled “withQueryParam”ai.withQueryParam(name: string, value: string) → OpenAIFactory
No description yet.
withStreamHandler
Section titled “withStreamHandler”ai.withStreamHandler(args?: mixed)
Refused: a stream handler would send streamed requests without the guard.