nemo_gym.client.openai_client
nemo_gym.client.openai_client
The OpenAI-compatible client that Gym servers use to call model endpoints, with retries.
The Responses API and Chat Completions types it sends and receives live in nemo_gym.core.responses_api_types.
Module Contents
Classes
Functions
Data
API
Bases: BaseModel
This is just a stub class that wraps around aiohttp
POST {base_url}/embeddings with kwargs as the JSON body and return the parsed response dict.
Bases: ClientResponseError
The upstream key is spent or unauthorized; further calls on this client skip the wire.
The failure an error reply’s failed body read is linked to: its observed attempt or the forwarded failure.
A forwarded Gym failure keeps its original ids; no local attempt is added for it.
True when a 401/403 body is a revoked or invalid key, not a one-off denial.
True when a 429 body is a spent key, not a transient rate limit.
The model boundary’s failure for one HTTP attempt of a model call (operation_id).
error.code / error.type tokens from an OpenAI-style error body.
raise_for_status for the last attempt; its error’s explicit cause is that attempt’s observed failure.
A cause raise_for_status set itself (a Gym server’s rebuilt failure) is kept.
Read an error reply’s body once; a failed read names the attempt that returned it as its explicit cause.
Seconds a Retry-After header asks for, as a number or an HTTP date; None without a usable one.
Full-jitter exponential backoff, or the provider’s Retry-After, both capped.
A request id that names the rollout, for calls made inside a rollout context.
vLLM takes its request id from X-Request-Id and records it as gen_ai.request.id on
the request’s span and in its request log, so an engine span or log line can be matched to a
rollout without walking the trace. The suffix keeps every call distinct, including across
server workers that cannot share a counter. A caller’s own header wins.
Whether the traceback places a timeout in aiohttp response processing.
This alone does not establish a completed upload; the caller must require that evidence separately.
With only a total timeout, aiohttp raises the same TimeoutError while connecting or waiting for a pooled
connection, so where it fired decides. Any other shape is not a response timeout.
The failure_reason of a model attempt that was sent and whose response did not arrive in time.