@metreeca/llms
    Preparing search index...

    Function createOpenAI

    • Creates an OpenAI API client paced against the published rate quotas.

      The client exposes the full OpenAI surface, with overloads, streaming and response helpers unaltered. Every request naming a model is paced by a per-model adaptive throttle, so a long run keeps within the published rate quota instead of failing on the 429 errors the SDK neither paces nor recovers from.

      Parameters

      • options: ClientOptions = {}

        The client options, as accepted by the OpenAI constructor; if omitted, the SDK defaults apply, reading the API key from the environment. A custom fetch is retained and issues every request, paced or not, so transport customisations keep applying

      Returns OpenAI

      A client sharing throttling and logging among all requests naming the same model. Models are told apart by their exact id, so variant spellings of a model are paced independently

      Error If options supplies no credentials and none is published by the environment, as signalled by the SDK through an OpenAIError

      A client is meant to be configured once by the consumer binding it, so that credentials and endpoint are settled for a whole execution rather than repeated by each job that draws on the same models.

      Quota control covers every request naming a model, whichever resource issues it and whatever the SDK version offers. A request rejected over the rate quota is resumed after the retry-after-ms or retry-after delay the API advertises, or at the pace the throttle settles on if no delay is advertised. A rejection reporting an exhausted account is returned as it stands, as no delay recovers from it. Requests naming no model, such as listing files or models, and requests whose payload cannot be sent twice, such as streamed uploads, are issued unpaced.

      The SDK bypasses pacing when X.509 workload identity credentials are supplied: a client authenticated that way is served through the SDK transport and left unpaced. Retrying is left to the SDK for everything but the rate quota, so maxRetries still governs recovery from network failures and server errors.