nemo_gym.openai_utils

View as Markdown

Module Contents

Classes

NameDescription
NeMoGymAdditionalToolsAdditional tool definitions accepted in request input.
NeMoGymAsyncOpenAIThis is just a stub class that wraps around aiohttp
NeMoGymChatCompletion-
NeMoGymChatCompletionAssistantMessageForTrainingParam-
NeMoGymChatCompletionAssistantMessageParam-
NeMoGymChatCompletionContentPartFileParam-
NeMoGymChatCompletionContentPartImageParam-
NeMoGymChatCompletionContentPartInputAudioParam-
NeMoGymChatCompletionContentPartTextParam-
NeMoGymChatCompletionContentPartVideoUrlParam-
NeMoGymChatCompletionCreateParamsNonStreaming-
NeMoGymChatCompletionCustomToolParam-
NeMoGymChatCompletionDeveloperMessageParam-
NeMoGymChatCompletionMessage-
NeMoGymChatCompletionMessageCustomToolCall-
NeMoGymChatCompletionMessageCustomToolCallParam-
NeMoGymChatCompletionMessageForTraining-
NeMoGymChatCompletionMessageToolCall-
NeMoGymChatCompletionMessageToolCallFunctionParam-
NeMoGymChatCompletionMessageToolCallParam-
NeMoGymChatCompletionSystemMessageParam-
NeMoGymChatCompletionToolMessageParam-
NeMoGymChatCompletionToolParam-
NeMoGymChatCompletionUserMessageParam-
NeMoGymChoice-
NeMoGymCompactionTriggerA request for the provider to compact the context (compaction_trigger item).
NeMoGymComputerCallOutputA computer-use result accepted in request input (computer_call_output item).
NeMoGymEasyInputMessage-
NeMoGymEasyInputMessageForTraining-
NeMoGymFunction-
NeMoGymFunctionCallOutputWe copy openai.types.responses.response_input_param.FunctionCallOutput, originally a TypedDict, as a BaseModel here
NeMoGymFunctionDefinition-
NeMoGymFunctionToolParam-
NeMoGymImageGenerationCallA hosted image-generation call (OpenAI Responses image_generation_call output item).
NeMoGymInputVideoPartVideo content accepted by the Responses-compatible Gym API.
NeMoGymLocalShellCallA local-shell command for the client to execute (local_shell_call output item).
NeMoGymLocalShellCallOutputThe client’s result of a local shell command (local_shell_call_output item).
NeMoGymMcpApprovalResponseThe client’s answer to a hosted-MCP approval request (mcp_approval_response item).
NeMoGymMessage-
NeMoGymMessageForTraining-
NeMoGymResponse-
NeMoGymResponseAdditionalToolsAdditional tool definitions returned by the provider.
NeMoGymResponseApplyPatchToolCallA patch the model wants applied (apply_patch_call output item).
NeMoGymResponseApplyPatchToolCallOutputThe client’s result of applying a patch (apply_patch_call_output item).
NeMoGymResponseCodeInterpreterToolCallA hosted code-interpreter call (OpenAI Responses code_interpreter_call output item).
NeMoGymResponseCompactionItemAn opaque context-compaction record the provider emits (compaction item).
NeMoGymResponseComputerCallOutputProvider output for a computer-use action, including status="failed".
NeMoGymResponseComputerToolCallA computer-use action for the client to execute (computer_call output item).
NeMoGymResponseCreateParamsNonStreamingThis class is a copy of openai.types.responses.response_create_params.ResponseCreateParamsNonStreaming
NeMoGymResponseCustomToolCallA client-executed custom tool call (OpenAI Responses custom_tool_call output item).
NeMoGymResponseCustomToolCallOutputThe client’s result of a custom tool call (custom_tool_call_output item).
NeMoGymResponseCustomToolCallOutputItemProvider output for a custom tool call.
NeMoGymResponseFileSearchToolCallA hosted file-search call (OpenAI Responses file_search_call output item).
NeMoGymResponseFunctionCallOutputProvider output for a function call result.
NeMoGymResponseFunctionShellToolCallA shell command the model wants run (shell_call output item).
NeMoGymResponseFunctionShellToolCallOutputThe client’s result of running a shell command (shell_call_output item).
NeMoGymResponseFunctionToolCall-
NeMoGymResponseFunctionToolCallForTraining-
NeMoGymResponseFunctionWebSearchA hosted web-search call (OpenAI Responses web_search_call output item).
NeMoGymResponseInputText-
NeMoGymResponseInputTokensDetails-
NeMoGymResponseLocalShellCallOutputProvider output for a local shell command.
NeMoGymResponseMcpApprovalRequestA hosted-MCP approval request (OpenAI Responses mcp_approval_request item).
NeMoGymResponseMcpApprovalResponseProvider output carrying an answer to a hosted-MCP approval request.
NeMoGymResponseMcpCallA hosted-MCP tool call (OpenAI Responses mcp_call output item).
NeMoGymResponseMcpListToolsA hosted-MCP tool listing (OpenAI Responses mcp_list_tools output item).
NeMoGymResponseOutputMessage-
NeMoGymResponseOutputMessageForTraining-
NeMoGymResponseOutputRefusal-
NeMoGymResponseOutputText-
NeMoGymResponseOutputTokensDetails-
NeMoGymResponseReasoningItem-
NeMoGymResponseReasoningItemForTraining-
NeMoGymResponseToolSearchCallA tool-search call (tool_search_call output item).
NeMoGymResponseToolSearchOutputItemThe result of a tool search (tool_search_output item).
NeMoGymResponseUsage-
NeMoGymSummary-
TokenIDLogProbMixin-
TokenIDLogProbTypedDictMixin-

Functions

NameDescription
_add_optional_token_countsAdd reported token counts without turning an unknown count into a measurement.
_normalize_response_item_for_inputConvert a provider output item to the request input schema.
_require_response_output_item_typePrevent an untagged output item from being coerced into the wrong union member.
_validate_atomic_token_metadataRequire complete token metadata when any token field is present.
_validate_input_video_partRequire one non-empty source without changing the TypedDict representation.
accumulate_response_usageAccumulate top-level and detailed response token counts.
training_variant_ofReturn the ForTraining subclass that carries token IDs for item_cls.

Data

NeMoGymChatCompletionContentPartParam

NeMoGymChatCompletionMessageParam

NeMoGymChatCompletionMessageToolCallUnion

NeMoGymChatCompletionMessageToolCallUnionParam

NeMoGymChatCompletionOutputMessage

NeMoGymChatCompletionToolUnionParam

NeMoGymContent

NeMoGymResponseInput

NeMoGymResponseInputContentList

NeMoGymResponseInputContentPart

NeMoGymResponseInputItem

NeMoGymResponseOutputItem

RATE_LIMIT_ERROR_CODES

REQUIRED_TOKEN_METADATA_FIELDS

RESPONSES_TO_TRAIN

RETRY_ERROR_CODES

RoutedExperts

TOKEN_METADATA_FIELDS

API

class nemo_gym.openai_utils.NeMoGymAdditionalTools()

Bases: InputAdditionalTools

Additional tool definitions accepted in request input.

class nemo_gym.openai_utils.NeMoGymAsyncOpenAI()

Bases: BaseModel

This is just a stub class that wraps around aiohttp

api_key
str
base_url
str
default_headers
Dict[str, str]
internal
bool
max_connection_retries
Optional[int]
nemo_gym.openai_utils.NeMoGymAsyncOpenAI._raise_for_status(
response: nemo_gym.server_utils.ClientResponse,
request_kwargs: typing.Dict[str, typing.Any]
) -> None
async
nemo_gym.openai_utils.NeMoGymAsyncOpenAI._request(
request_kwargs: typing.Dict = {}
) -> nemo_gym.server_utils.ClientResponse
async
nemo_gym.openai_utils.NeMoGymAsyncOpenAI._request_with_retry(
request_kwargs: typing.Dict = {}
) -> nemo_gym.server_utils.ClientResponse
async
nemo_gym.openai_utils.NeMoGymAsyncOpenAI.create_chat_completion(
kwargs = {}
)
async
nemo_gym.openai_utils.NeMoGymAsyncOpenAI.create_completion(
kwargs = {}
)
async
nemo_gym.openai_utils.NeMoGymAsyncOpenAI.create_models()
async
nemo_gym.openai_utils.NeMoGymAsyncOpenAI.create_response(
kwargs = {}
)
async
nemo_gym.openai_utils.NeMoGymAsyncOpenAI.create_tokenize(
kwargs = {}
)
async
class nemo_gym.openai_utils.NeMoGymChatCompletion()

Bases: ChatCompletion

choices
List[NeMoGymChoice]
class nemo_gym.openai_utils.NeMoGymChatCompletionAssistantMessageForTrainingParam

Bases: typing.TypedDict

class nemo_gym.openai_utils.NeMoGymChatCompletionAssistantMessageParam()

Bases: ChatCompletionAssistantMessageParam

content
Union[str, List[ContentArrayOfContentPart], None]
tool_calls
Optional[List[NeMoGymChatCompletionMessageToolCallUnionParam]] = None
class nemo_gym.openai_utils.NeMoGymChatCompletionContentPartFileParam()

Bases: ChatCompletionContentPartFileParam

class nemo_gym.openai_utils.NeMoGymChatCompletionContentPartImageParam()

Bases: ChatCompletionContentPartImageParam

class nemo_gym.openai_utils.NeMoGymChatCompletionContentPartInputAudioParam()

Bases: ChatCompletionContentPartInputAudioParam

class nemo_gym.openai_utils.NeMoGymChatCompletionContentPartTextParam()

Bases: ChatCompletionContentPartTextParam

class nemo_gym.openai_utils.NeMoGymChatCompletionContentPartVideoUrlParam

Bases: typing.TypedDict

type
Required[Literal['video_url']]
video_url
Required[Union[str, Dict[str, Any]]]
class nemo_gym.openai_utils.NeMoGymChatCompletionCreateParamsNonStreaming()

Bases: BaseModel

audio
Optional[ChatCompletionAudioParam] = None
frequency_penalty
Optional[float] = None
logit_bias
Optional[Dict[str, int]] = None
logprobs
Optional[bool] = None
max_completion_tokens
Optional[int] = None
max_tokens
Optional[int] = None
messages
List[NeMoGymChatCompletionMessageParam]
metadata
Optional[Metadata] = None
modalities
Optional[List[Literal['text', 'audio']]] = None
model
Optional[Union[str, ChatModel]] = None
model_config
= ConfigDict(extra='forbid')
moderation
Optional[ChatCompletionModeration] = None
n
Optional[int] = None
parallel_tool_calls
bool = True
prediction
Optional[ChatCompletionPredictionContentParam] = None
presence_penalty
Optional[float] = None
prompt_cache_key
Optional[str] = None
prompt_cache_retention
Optional[Literal['in_memory', '24h']] = None
reasoning_effort
Optional[ReasoningEffort] = None
response_format
Optional[ResponseFormat] = None
safety_identifier
Optional[str] = None
seed
Optional[int] = None
service_tier
Optional[Literal['auto', 'default', 'flex', 'scale', 'priority']] = None
stop
Union[Optional[str], List[str], None] = None
store
Optional[bool] = None
stream
Optional[Literal[False]] = None
stream_options
Optional[ChatCompletionStreamOptionsParam] = None
temperature
Optional[float] = None
tool_choice
Optional[ChatCompletionToolChoiceOptionParam] = None
tools
Optional[List[NeMoGymChatCompletionToolUnionParam]] = None
top_logprobs
Optional[int] = None
top_p
Optional[float] = None
user
Optional[str] = None
verbosity
Optional[Literal['low', 'medium', 'high']] = None
web_search_options
Optional[WebSearchOptions] = None
class nemo_gym.openai_utils.NeMoGymChatCompletionCustomToolParam()

Bases: ChatCompletionCustomToolParam

class nemo_gym.openai_utils.NeMoGymChatCompletionDeveloperMessageParam()

Bases: ChatCompletionDeveloperMessageParam

content
Required[Union[str, List[NeMoGymChatCompletionContentPartTextParam]]]
class nemo_gym.openai_utils.NeMoGymChatCompletionMessage()

Bases: ChatCompletionMessage

tool_calls
Optional[List[NeMoGymChatCompletionMessageToolCallUnion]] = None
class nemo_gym.openai_utils.NeMoGymChatCompletionMessageCustomToolCall()

Bases: ChatCompletionMessageCustomToolCall

class nemo_gym.openai_utils.NeMoGymChatCompletionMessageCustomToolCallParam()

Bases: ChatCompletionMessageCustomToolCallParam

class nemo_gym.openai_utils.NeMoGymChatCompletionMessageForTraining()
class nemo_gym.openai_utils.NeMoGymChatCompletionMessageToolCall()

Bases: ChatCompletionMessageToolCall

function
NeMoGymFunction
class nemo_gym.openai_utils.NeMoGymChatCompletionMessageToolCallFunctionParam

Bases: typing.TypedDict

arguments
Required[str]
name
Required[str]
class nemo_gym.openai_utils.NeMoGymChatCompletionMessageToolCallParam()

Bases: ChatCompletionMessageToolCallParam

function
NeMoGymChatCompletionMessageToolCallFunctionParam
class nemo_gym.openai_utils.NeMoGymChatCompletionSystemMessageParam()

Bases: ChatCompletionSystemMessageParam

content
Required[Union[str, List[NeMoGymChatCompletionContentPartTextParam]]]
class nemo_gym.openai_utils.NeMoGymChatCompletionToolMessageParam()

Bases: ChatCompletionToolMessageParam

content
Required[Union[str, List[NeMoGymChatCompletionContentPartTextParam]]]
class nemo_gym.openai_utils.NeMoGymChatCompletionToolParam()

Bases: ChatCompletionToolParam

function
Required[NeMoGymFunctionDefinition]
class nemo_gym.openai_utils.NeMoGymChatCompletionUserMessageParam()

Bases: ChatCompletionUserMessageParam

content
Required[Union[str, List[NeMoGymChatCompletionContentPartParam]]]
class nemo_gym.openai_utils.NeMoGymChoice()

Bases: Choice

message
NeMoGymChatCompletionOutputMessage
class nemo_gym.openai_utils.NeMoGymCompactionTrigger()

Bases: CompactionTrigger

A request for the provider to compact the context (compaction_trigger item).

Gym preserves this input item when replaying the transcript.

class nemo_gym.openai_utils.NeMoGymComputerCallOutput()

Bases: ComputerCallOutput

A computer-use result accepted in request input (computer_call_output item).

class nemo_gym.openai_utils.NeMoGymEasyInputMessage()

Bases: BaseModel

content
Union[str, NeMoGymResponseInputContentList]
phase
Optional[Literal['commentary', 'final_answer']] = None
role
Literal['user', 'assistant', 'system', 'developer']
type
Literal['message'] = 'message'
class nemo_gym.openai_utils.NeMoGymEasyInputMessageForTraining()
class nemo_gym.openai_utils.NeMoGymFunction()

Bases: BaseModel

arguments
str
name
str
class nemo_gym.openai_utils.NeMoGymFunctionCallOutput()

Bases: BaseModel

We copy openai.types.responses.response_input_param.FunctionCallOutput, originally a TypedDict, as a BaseModel here so that we can use it in the NeMoGymResponseOutputItem below and be consistent with the other ResponseOutputItem types.

call_id
str
id
Optional[str] = None
output
Union[str, ResponseFunctionCallOutputItemListParam]
status
Optional[Literal['in_progress', 'completed', 'incomplete']] = None
type
Literal['function_call_output'] = 'function_call_output'
class nemo_gym.openai_utils.NeMoGymFunctionDefinition()

Bases: FunctionDefinition

class nemo_gym.openai_utils.NeMoGymFunctionToolParam()

Bases: FunctionToolParam

class nemo_gym.openai_utils.NeMoGymImageGenerationCall()

Bases: ImageGenerationCall

A hosted image-generation call (OpenAI Responses image_generation_call output item).

class nemo_gym.openai_utils.NeMoGymInputVideoPart

Bases: typing.TypedDict

Video content accepted by the Responses-compatible Gym API.

type
Required[Literal['input_video']]
video
Union[str, Dict[str, Any]]
video_url
Union[str, Dict[str, Any]]
class nemo_gym.openai_utils.NeMoGymLocalShellCall()

Bases: LocalShellCall

A local-shell command for the client to execute (local_shell_call output item).

class nemo_gym.openai_utils.NeMoGymLocalShellCallOutput()

Bases: LocalShellCallOutput

The client’s result of a local shell command (local_shell_call_output item).

class nemo_gym.openai_utils.NeMoGymMcpApprovalResponse()

Bases: McpApprovalResponse

The client’s answer to a hosted-MCP approval request (mcp_approval_response item).

class nemo_gym.openai_utils.NeMoGymMessage()

Bases: BaseModel

content
NeMoGymResponseInputContentList
role
Literal['user', 'system', 'developer']
status
Literal['in_progress', 'completed', 'incomplete'] = 'completed'
type
Literal['message'] = 'message'
class nemo_gym.openai_utils.NeMoGymMessageForTraining()
class nemo_gym.openai_utils.NeMoGymResponse()

Bases: Response

output
List[NeMoGymResponseOutputItem]
usage
Optional[NeMoGymResponseUsage] = None
class nemo_gym.openai_utils.NeMoGymResponseAdditionalTools()

Bases: OutputAdditionalTools

Additional tool definitions returned by the provider.

class nemo_gym.openai_utils.NeMoGymResponseApplyPatchToolCall()

Bases: ResponseApplyPatchToolCall

A patch the model wants applied (apply_patch_call output item).

class nemo_gym.openai_utils.NeMoGymResponseApplyPatchToolCallOutput()

Bases: ResponseApplyPatchToolCallOutput

The client’s result of applying a patch (apply_patch_call_output item).

class nemo_gym.openai_utils.NeMoGymResponseCodeInterpreterToolCall()

Bases: ResponseCodeInterpreterToolCall

A hosted code-interpreter call (OpenAI Responses code_interpreter_call output item).

class nemo_gym.openai_utils.NeMoGymResponseCompactionItem()

Bases: ResponseCompactionItem

An opaque context-compaction record the provider emits (compaction item).

class nemo_gym.openai_utils.NeMoGymResponseComputerCallOutput()

Bases: ResponseComputerToolCallOutputItem

Provider output for a computer-use action, including status="failed".

class nemo_gym.openai_utils.NeMoGymResponseComputerToolCall()

Bases: ResponseComputerToolCall

A computer-use action for the client to execute (computer_call output item).

class nemo_gym.openai_utils.NeMoGymResponseCreateParamsNonStreaming()

Bases: BaseModel

This class is a copy of openai.types.responses.response_create_params.ResponseCreateParamsNonStreaming We make a copy of it here since ResponseCreateParamsNonStreaming is a TypedDict with no strict validation. We need to do server side validation here.

background
Optional[bool] = None
context_management
Optional[List[ContextManagement]] = None
conversation
Union[str, ResponseConversationParamParam, None] = None
include
Optional[List[ResponseIncludable]] = None
input
Union[str, NeMoGymResponseInput]
instructions
Optional[str] = None
max_output_tokens
Optional[int] = None
max_tool_calls
Optional[int] = None
metadata
Optional[Metadata] = None
model
Optional[ResponsesModel] = None
model_config
= ConfigDict(extra='forbid')
moderation
Optional[Moderation] = None
parallel_tool_calls
bool = True
previous_response_id
Optional[str] = None
prompt
Optional[ResponsePromptParam] = None
prompt_cache_key
Optional[str] = None
prompt_cache_retention
Optional[Literal['in_memory', '24h']] = None
reasoning
Optional[Reasoning] = None
safety_identifier
Optional[str] = None
service_tier
Optional[Literal['auto', 'default', 'flex', 'scale', 'priority']] = None
store
Optional[bool] = None
stream
Optional[Literal[False]] = None
stream_options
Optional[StreamOptions] = None
temperature
Optional[float] = None
text
Optional[ResponseTextConfigParam] = None
tool_choice
ToolChoice = 'auto'
tools
List[ToolParam] = Field(default_factory=list)
top_logprobs
Optional[int] = None
top_p
Optional[float] = None
truncation
Optional[Literal['auto', 'disabled']] = None
user
Optional[str] = None
nemo_gym.openai_utils.NeMoGymResponseCreateParamsNonStreaming.normalize_output_items_for_replay(
value: typing.Any
) -> typing.Any
classmethod

Normalize fields whose OpenAI output and input schemas differ.

class nemo_gym.openai_utils.NeMoGymResponseCustomToolCall()

Bases: ResponseCustomToolCall

A client-executed custom tool call (OpenAI Responses custom_tool_call output item).

class nemo_gym.openai_utils.NeMoGymResponseCustomToolCallOutput()

Bases: ResponseCustomToolCallOutput

The client’s result of a custom tool call (custom_tool_call_output item).

class nemo_gym.openai_utils.NeMoGymResponseCustomToolCallOutputItem()

Bases: ResponseCustomToolCallOutputItem

Provider output for a custom tool call.

class nemo_gym.openai_utils.NeMoGymResponseFileSearchToolCall()

Bases: ResponseFileSearchToolCall

A hosted file-search call (OpenAI Responses file_search_call output item).

The provider executes the search and returns the call in response.output. Inherits the upstream typing unchanged.

class nemo_gym.openai_utils.NeMoGymResponseFunctionCallOutput()

Bases: ResponseFunctionToolCallOutputItem

Provider output for a function call result.

class nemo_gym.openai_utils.NeMoGymResponseFunctionShellToolCall()

Bases: ResponseFunctionShellToolCall

A shell command the model wants run (shell_call output item).

class nemo_gym.openai_utils.NeMoGymResponseFunctionShellToolCallOutput()

Bases: ResponseFunctionShellToolCallOutput

The client’s result of running a shell command (shell_call_output item).

class nemo_gym.openai_utils.NeMoGymResponseFunctionToolCall()

Bases: BaseModel

arguments
str
call_id
str
id
Optional[str] = None
name
str
namespace
Optional[str] = None
status
Optional[Literal['in_progress', 'completed', 'incomplete']] = None
type
Literal['function_call'] = 'function_call'
class nemo_gym.openai_utils.NeMoGymResponseFunctionToolCallForTraining()
class nemo_gym.openai_utils.NeMoGymResponseFunctionWebSearch()

Bases: ResponseFunctionWebSearch

A hosted web-search call (OpenAI Responses web_search_call output item).

class nemo_gym.openai_utils.NeMoGymResponseInputText()

Bases: ResponseInputTextParam

class nemo_gym.openai_utils.NeMoGymResponseInputTokensDetails()

Bases: ResponseInputTokensDetails

cached_tokens
Optional[int]
class nemo_gym.openai_utils.NeMoGymResponseLocalShellCallOutput()

Bases: OutputLocalShellCallOutput

Provider output for a local shell command.

class nemo_gym.openai_utils.NeMoGymResponseMcpApprovalRequest()

Bases: McpApprovalRequest

A hosted-MCP approval request (OpenAI Responses mcp_approval_request item).

Inherits the upstream McpApprovalRequest typing; id/server_label are relaxed to optional to tolerate endpoints that omit them.

id
Optional[str] = None
server_label
Optional[str] = None
type
Literal['mcp_approval_request'] = 'mcp_approval_request'
class nemo_gym.openai_utils.NeMoGymResponseMcpApprovalResponse()

Bases: OutputMcpApprovalResponse

Provider output carrying an answer to a hosted-MCP approval request.

class nemo_gym.openai_utils.NeMoGymResponseMcpCall()

Bases: McpCall

A hosted-MCP tool call (OpenAI Responses mcp_call output item).

Emitted when the upstream endpoint executes a tool server-side (e.g. NVIDIA-hosted gpt-oss surfacing its built-in python tool as MCP) instead of returning a client-executed function_call. The output/error fields are already populated by the server, so the agent parses and passes it through; there is no client-side execution and hence no training variant.

Inherits the upstream McpCall typing and only relaxes the fields NVIDIA-hosted endpoints may omit or widen: id/server_label are made optional and status accepts any string (upstream pins it to a Literal).

id
Optional[str] = None
server_label
Optional[str] = None
status
Optional[str] = None
type
Literal['mcp_call'] = 'mcp_call'
class nemo_gym.openai_utils.NeMoGymResponseMcpListTools()

Bases: McpListTools

A hosted-MCP tool listing (OpenAI Responses mcp_list_tools output item).

Inherits the upstream McpListTools typing; only id/server_label are relaxed to optional (NVIDIA-hosted endpoints may omit them) and tools is widened to List[Any] so raw tool entries pass through without being coerced into the upstream McpListToolsTool schema.

id
Optional[str] = None
server_label
Optional[str] = None
tools
List[Any] = Field(default_factory=list)
type
Literal['mcp_list_tools'] = 'mcp_list_tools'
class nemo_gym.openai_utils.NeMoGymResponseOutputMessage()

Bases: BaseModel

content
List[NeMoGymContent]
id
str
phase
Optional[Literal['commentary', 'final_answer']] = None
role
Literal['assistant'] = 'assistant'
status
Literal['in_progress', 'completed', 'incomplete'] = 'completed'
type
Literal['message'] = 'message'
class nemo_gym.openai_utils.NeMoGymResponseOutputMessageForTraining()
class nemo_gym.openai_utils.NeMoGymResponseOutputRefusal()

Bases: BaseModel

refusal
str
type
Literal['refusal'] = 'refusal'
class nemo_gym.openai_utils.NeMoGymResponseOutputText()

Bases: BaseModel

annotations
List[Annotation]
logprobs
Optional[List[Logprob]] = None
text
str
type
Literal['output_text'] = 'output_text'
class nemo_gym.openai_utils.NeMoGymResponseOutputTokensDetails()

Bases: ResponseOutputTokensDetails

reasoning_tokens
Optional[int]
class nemo_gym.openai_utils.NeMoGymResponseReasoningItem()

Bases: BaseModel

content
Optional[List[ReasoningContent]] = None
encrypted_content
Optional[str] = None
id
str
summary
List[NeMoGymSummary]
type
Literal['reasoning'] = 'reasoning'
class nemo_gym.openai_utils.NeMoGymResponseReasoningItemForTraining()
class nemo_gym.openai_utils.NeMoGymResponseToolSearchCall()

Bases: ResponseToolSearchCall

A tool-search call (tool_search_call output item).

class nemo_gym.openai_utils.NeMoGymResponseToolSearchOutputItem()

Bases: ResponseToolSearchOutputItem

The result of a tool search (tool_search_output item).

class nemo_gym.openai_utils.NeMoGymResponseUsage()

Bases: ResponseUsage

input_tokens_details
NeMoGymResponseInputTokensDetails
output_tokens_details
NeMoGymResponseOutputTokensDetails
classmethod
class nemo_gym.openai_utils.NeMoGymSummary()

Bases: Summary

class nemo_gym.openai_utils.TokenIDLogProbMixin()

Bases: BaseModel

generation_log_probs
List[float]
generation_token_ids
List[int]
prompt_token_ids
List[int]
routed_experts
Optional[RoutedExperts] = None
class nemo_gym.openai_utils.TokenIDLogProbTypedDictMixin

Bases: typing.TypedDict

generation_log_probs
List[float]
generation_token_ids
List[int]
prompt_token_ids
List[int]
routed_experts
NotRequired[RoutedExperts]
nemo_gym.openai_utils._add_optional_token_counts(
left: typing.Optional[int],
right: typing.Optional[int]
) -> typing.Optional[int]

Add reported token counts without turning an unknown count into a measurement.

nemo_gym.openai_utils._normalize_response_item_for_input(
item: typing.Any
) -> typing.Any

Convert a provider output item to the request input schema.

nemo_gym.openai_utils._require_response_output_item_type(
value: typing.Any
) -> typing.Any

Prevent an untagged output item from being coerced into the wrong union member.

nemo_gym.openai_utils._validate_atomic_token_metadata(
value: typing.Any
) -> typing.Any

Require complete token metadata when any token field is present.

nemo_gym.openai_utils._validate_input_video_part(
value: typing.Any
) -> typing.Any

Require one non-empty source without changing the TypedDict representation.

nemo_gym.openai_utils.accumulate_response_usage(
total: typing.Optional[nemo_gym.openai_utils.NeMoGymResponseUsage],
additional: typing.Optional[nemo_gym.openai_utils.NeMoGymResponseUsage]
) -> typing.Optional[nemo_gym.openai_utils.NeMoGymResponseUsage]

Accumulate top-level and detailed response token counts.

nemo_gym.openai_utils.training_variant_of(
item_cls: type
) -> type

Return the ForTraining subclass that carries token IDs for item_cls.

Raises NotImplementedError rather than KeyError, so the message can name the class and the fix. Either register the pair in RESPONSES_TO_TRAIN, or stop attaching token IDs to that item.

nemo_gym.openai_utils.NeMoGymChatCompletionContentPartParam = Union[NeMoGymChatCompletionContentPartTextParam, NeMoGymChatCompletionContentPar...
nemo_gym.openai_utils.NeMoGymChatCompletionMessageParam: TypeAlias = Annotated[Union[NeMoGymChatCompletionDeveloperMessageParam, NeMoGymChatCompletio...
nemo_gym.openai_utils.NeMoGymChatCompletionMessageToolCallUnion = Annotated[Union[NeMoGymChatCompletionMessageToolCall, NeMoGymChatCompletionMessa...
nemo_gym.openai_utils.NeMoGymChatCompletionMessageToolCallUnionParam = Annotated[Union[NeMoGymChatCompletionMessageToolCallParam, NeMoGymChatCompletion...
nemo_gym.openai_utils.NeMoGymChatCompletionOutputMessage: TypeAlias = Annotated[Union[NeMoGymChatCompletionMessage, NeMoGymChatCompletionMessageForTra...
nemo_gym.openai_utils.NeMoGymChatCompletionToolUnionParam = Annotated[Union[NeMoGymChatCompletionToolParam, NeMoGymChatCompletionCustomToolP...
nemo_gym.openai_utils.NeMoGymContent: TypeAlias = Union[NeMoGymResponseOutputText, NeMoGymResponseOutputRefusal]
nemo_gym.openai_utils.NeMoGymResponseInput: TypeAlias = List[NeMoGymResponseInputItem]
nemo_gym.openai_utils.NeMoGymResponseInputContentList: TypeAlias = List[NeMoGymResponseInputContentPart]
nemo_gym.openai_utils.NeMoGymResponseInputContentPart: TypeAlias = Annotated[Union[ResponseInputContentParam, NeMoGymInputVideoPart], BeforeValidat...
nemo_gym.openai_utils.NeMoGymResponseInputItem = Annotated[Union[NeMoGymEasyInputMessage, NeMoGymMessage, NeMoGymResponseOutputMe...
nemo_gym.openai_utils.NeMoGymResponseOutputItem = Annotated[Union[NeMoGymResponseOutputMessage, NeMoGymResponseFunctionToolCall, N...
nemo_gym.openai_utils.RATE_LIMIT_ERROR_CODES = [429, 502, 503, 504, 520]
nemo_gym.openai_utils.REQUIRED_TOKEN_METADATA_FIELDS = frozenset({'prompt_token_ids', 'generation_token_ids', 'generation_log_probs'})
nemo_gym.openai_utils.RESPONSES_TO_TRAIN = {NeMoGymEasyInputMessage: NeMoGymEasyInputMessageForTraining, NeMoGymMessage: Ne...
nemo_gym.openai_utils.RETRY_ERROR_CODES = RATE_LIMIT_ERROR_CODES + [500]
nemo_gym.openai_utils.RoutedExperts: TypeAlias = Union[str, List[List[List[int]]]]
nemo_gym.openai_utils.TOKEN_METADATA_FIELDS = REQUIRED_TOKEN_METADATA_FIELDS | {'routed_experts'}