> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/gym/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/gym/_mcp/server.

# nemo_gym.openai_utils

## Module Contents

### Classes

| Name                                                                                                                                    | Description                                                                                                           |
| --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| [`ChatCompletionModeration`](#nemo_gym-openai_utils-ChatCompletionModeration)                                                           | Chat moderation shape omitted by some OpenAI SDK artifacts.                                                           |
| [`NeMoGymAdditionalTools`](#nemo_gym-openai_utils-NeMoGymAdditionalTools)                                                               | Additional tool definitions accepted in request input.                                                                |
| [`NeMoGymAsyncOpenAI`](#nemo_gym-openai_utils-NeMoGymAsyncOpenAI)                                                                       | This is just a stub class that wraps around aiohttp                                                                   |
| [`NeMoGymChatCompletion`](#nemo_gym-openai_utils-NeMoGymChatCompletion)                                                                 | -                                                                                                                     |
| [`NeMoGymChatCompletionAssistantMessageForTrainingParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionAssistantMessageForTrainingParam) | -                                                                                                                     |
| [`NeMoGymChatCompletionAssistantMessageParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionAssistantMessageParam)                       | -                                                                                                                     |
| [`NeMoGymChatCompletionContentPartFileParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionContentPartFileParam)                         | -                                                                                                                     |
| [`NeMoGymChatCompletionContentPartImageParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionContentPartImageParam)                       | -                                                                                                                     |
| [`NeMoGymChatCompletionContentPartInputAudioParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionContentPartInputAudioParam)             | -                                                                                                                     |
| [`NeMoGymChatCompletionContentPartTextParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionContentPartTextParam)                         | -                                                                                                                     |
| [`NeMoGymChatCompletionContentPartVideoUrlParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionContentPartVideoUrlParam)                 | -                                                                                                                     |
| [`NeMoGymChatCompletionCreateParamsNonStreaming`](#nemo_gym-openai_utils-NeMoGymChatCompletionCreateParamsNonStreaming)                 | -                                                                                                                     |
| [`NeMoGymChatCompletionCustomToolParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionCustomToolParam)                                   | -                                                                                                                     |
| [`NeMoGymChatCompletionDeveloperMessageParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionDeveloperMessageParam)                       | -                                                                                                                     |
| [`NeMoGymChatCompletionMessage`](#nemo_gym-openai_utils-NeMoGymChatCompletionMessage)                                                   | -                                                                                                                     |
| [`NeMoGymChatCompletionMessageCustomToolCall`](#nemo_gym-openai_utils-NeMoGymChatCompletionMessageCustomToolCall)                       | -                                                                                                                     |
| [`NeMoGymChatCompletionMessageCustomToolCallParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionMessageCustomToolCallParam)             | -                                                                                                                     |
| [`NeMoGymChatCompletionMessageForTraining`](#nemo_gym-openai_utils-NeMoGymChatCompletionMessageForTraining)                             | -                                                                                                                     |
| [`NeMoGymChatCompletionMessageToolCall`](#nemo_gym-openai_utils-NeMoGymChatCompletionMessageToolCall)                                   | -                                                                                                                     |
| [`NeMoGymChatCompletionMessageToolCallFunctionParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionMessageToolCallFunctionParam)         | -                                                                                                                     |
| [`NeMoGymChatCompletionMessageToolCallParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionMessageToolCallParam)                         | -                                                                                                                     |
| [`NeMoGymChatCompletionSystemMessageParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionSystemMessageParam)                             | -                                                                                                                     |
| [`NeMoGymChatCompletionToolMessageParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionToolMessageParam)                                 | -                                                                                                                     |
| [`NeMoGymChatCompletionToolParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionToolParam)                                               | -                                                                                                                     |
| [`NeMoGymChatCompletionUserMessageParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionUserMessageParam)                                 | -                                                                                                                     |
| [`NeMoGymChoice`](#nemo_gym-openai_utils-NeMoGymChoice)                                                                                 | -                                                                                                                     |
| [`NeMoGymCompactionTrigger`](#nemo_gym-openai_utils-NeMoGymCompactionTrigger)                                                           | A request for the provider to compact the context (`compaction_trigger` item).                                        |
| [`NeMoGymComputerCallOutput`](#nemo_gym-openai_utils-NeMoGymComputerCallOutput)                                                         | A computer-use result accepted in request input (`computer_call_output` item).                                        |
| [`NeMoGymEasyInputMessage`](#nemo_gym-openai_utils-NeMoGymEasyInputMessage)                                                             | -                                                                                                                     |
| [`NeMoGymEasyInputMessageForTraining`](#nemo_gym-openai_utils-NeMoGymEasyInputMessageForTraining)                                       | -                                                                                                                     |
| [`NeMoGymFunction`](#nemo_gym-openai_utils-NeMoGymFunction)                                                                             | -                                                                                                                     |
| [`NeMoGymFunctionCallOutput`](#nemo_gym-openai_utils-NeMoGymFunctionCallOutput)                                                         | We copy openai.types.responses.response\_input\_param.FunctionCallOutput, originally a TypedDict, as a BaseModel here |
| [`NeMoGymFunctionDefinition`](#nemo_gym-openai_utils-NeMoGymFunctionDefinition)                                                         | -                                                                                                                     |
| [`NeMoGymFunctionToolParam`](#nemo_gym-openai_utils-NeMoGymFunctionToolParam)                                                           | -                                                                                                                     |
| [`NeMoGymImageGenerationCall`](#nemo_gym-openai_utils-NeMoGymImageGenerationCall)                                                       | A hosted image-generation call (OpenAI Responses `image_generation_call` output item).                                |
| [`NeMoGymInputAudio`](#nemo_gym-openai_utils-NeMoGymInputAudio)                                                                         | `input_audio` payload of a chat content part, with an open `format` token.                                            |
| [`NeMoGymInputVideoPart`](#nemo_gym-openai_utils-NeMoGymInputVideoPart)                                                                 | Video content accepted by the Responses-compatible Gym API.                                                           |
| [`NeMoGymLocalShellCall`](#nemo_gym-openai_utils-NeMoGymLocalShellCall)                                                                 | A local-shell command for the client to execute (`local_shell_call` output item).                                     |
| [`NeMoGymLocalShellCallOutput`](#nemo_gym-openai_utils-NeMoGymLocalShellCallOutput)                                                     | The client's result of a local shell command (`local_shell_call_output` item).                                        |
| [`NeMoGymMcpApprovalResponse`](#nemo_gym-openai_utils-NeMoGymMcpApprovalResponse)                                                       | The client's answer to a hosted-MCP approval request (`mcp_approval_response` item).                                  |
| [`NeMoGymMessage`](#nemo_gym-openai_utils-NeMoGymMessage)                                                                               | -                                                                                                                     |
| [`NeMoGymMessageForTraining`](#nemo_gym-openai_utils-NeMoGymMessageForTraining)                                                         | -                                                                                                                     |
| [`NeMoGymResponse`](#nemo_gym-openai_utils-NeMoGymResponse)                                                                             | -                                                                                                                     |
| [`NeMoGymResponseAdditionalTools`](#nemo_gym-openai_utils-NeMoGymResponseAdditionalTools)                                               | Additional tool definitions returned by the provider.                                                                 |
| [`NeMoGymResponseApplyPatchToolCall`](#nemo_gym-openai_utils-NeMoGymResponseApplyPatchToolCall)                                         | A patch the model wants applied (`apply_patch_call` output item).                                                     |
| [`NeMoGymResponseApplyPatchToolCallOutput`](#nemo_gym-openai_utils-NeMoGymResponseApplyPatchToolCallOutput)                             | The client's result of applying a patch (`apply_patch_call_output` item).                                             |
| [`NeMoGymResponseCodeInterpreterToolCall`](#nemo_gym-openai_utils-NeMoGymResponseCodeInterpreterToolCall)                               | A hosted code-interpreter call (OpenAI Responses `code_interpreter_call` output item).                                |
| [`NeMoGymResponseCompactionItem`](#nemo_gym-openai_utils-NeMoGymResponseCompactionItem)                                                 | An opaque context-compaction record the provider emits (`compaction` item).                                           |
| [`NeMoGymResponseComputerCallOutput`](#nemo_gym-openai_utils-NeMoGymResponseComputerCallOutput)                                         | Provider output for a computer-use action, including `status="failed"`.                                               |
| [`NeMoGymResponseComputerToolCall`](#nemo_gym-openai_utils-NeMoGymResponseComputerToolCall)                                             | A computer-use action for the client to execute (`computer_call` output item).                                        |
| [`NeMoGymResponseCreateParamsNonStreaming`](#nemo_gym-openai_utils-NeMoGymResponseCreateParamsNonStreaming)                             | This class is a copy of openai.types.responses.response\_create\_params.ResponseCreateParamsNonStreaming              |
| [`NeMoGymResponseCustomToolCall`](#nemo_gym-openai_utils-NeMoGymResponseCustomToolCall)                                                 | A client-executed custom tool call (OpenAI Responses `custom_tool_call` output item).                                 |
| [`NeMoGymResponseCustomToolCallOutput`](#nemo_gym-openai_utils-NeMoGymResponseCustomToolCallOutput)                                     | The client's result of a custom tool call (`custom_tool_call_output` item).                                           |
| [`NeMoGymResponseCustomToolCallOutputItem`](#nemo_gym-openai_utils-NeMoGymResponseCustomToolCallOutputItem)                             | Provider output for a custom tool call.                                                                               |
| [`NeMoGymResponseFileSearchToolCall`](#nemo_gym-openai_utils-NeMoGymResponseFileSearchToolCall)                                         | A hosted file-search call (OpenAI Responses `file_search_call` output item).                                          |
| [`NeMoGymResponseFunctionCallOutput`](#nemo_gym-openai_utils-NeMoGymResponseFunctionCallOutput)                                         | Provider output for a function call result.                                                                           |
| [`NeMoGymResponseFunctionShellToolCall`](#nemo_gym-openai_utils-NeMoGymResponseFunctionShellToolCall)                                   | A shell command the model wants run (`shell_call` output item).                                                       |
| [`NeMoGymResponseFunctionShellToolCallOutput`](#nemo_gym-openai_utils-NeMoGymResponseFunctionShellToolCallOutput)                       | The client's result of running a shell command (`shell_call_output` item).                                            |
| [`NeMoGymResponseFunctionToolCall`](#nemo_gym-openai_utils-NeMoGymResponseFunctionToolCall)                                             | -                                                                                                                     |
| [`NeMoGymResponseFunctionToolCallForTraining`](#nemo_gym-openai_utils-NeMoGymResponseFunctionToolCallForTraining)                       | -                                                                                                                     |
| [`NeMoGymResponseFunctionWebSearch`](#nemo_gym-openai_utils-NeMoGymResponseFunctionWebSearch)                                           | A hosted web-search call (OpenAI Responses `web_search_call` output item).                                            |
| [`NeMoGymResponseInputText`](#nemo_gym-openai_utils-NeMoGymResponseInputText)                                                           | -                                                                                                                     |
| [`NeMoGymResponseInputTokensDetails`](#nemo_gym-openai_utils-NeMoGymResponseInputTokensDetails)                                         | -                                                                                                                     |
| [`NeMoGymResponseLocalShellCallOutput`](#nemo_gym-openai_utils-NeMoGymResponseLocalShellCallOutput)                                     | Provider output for a local shell command.                                                                            |
| [`NeMoGymResponseMcpApprovalRequest`](#nemo_gym-openai_utils-NeMoGymResponseMcpApprovalRequest)                                         | A hosted-MCP approval request (OpenAI Responses `mcp_approval_request` item).                                         |
| [`NeMoGymResponseMcpApprovalResponse`](#nemo_gym-openai_utils-NeMoGymResponseMcpApprovalResponse)                                       | Provider output carrying an answer to a hosted-MCP approval request.                                                  |
| [`NeMoGymResponseMcpCall`](#nemo_gym-openai_utils-NeMoGymResponseMcpCall)                                                               | A hosted-MCP tool call (OpenAI Responses `mcp_call` output item).                                                     |
| [`NeMoGymResponseMcpListTools`](#nemo_gym-openai_utils-NeMoGymResponseMcpListTools)                                                     | A hosted-MCP tool listing (OpenAI Responses `mcp_list_tools` output item).                                            |
| [`NeMoGymResponseOutputMessage`](#nemo_gym-openai_utils-NeMoGymResponseOutputMessage)                                                   | -                                                                                                                     |
| [`NeMoGymResponseOutputMessageForTraining`](#nemo_gym-openai_utils-NeMoGymResponseOutputMessageForTraining)                             | -                                                                                                                     |
| [`NeMoGymResponseOutputRefusal`](#nemo_gym-openai_utils-NeMoGymResponseOutputRefusal)                                                   | -                                                                                                                     |
| [`NeMoGymResponseOutputText`](#nemo_gym-openai_utils-NeMoGymResponseOutputText)                                                         | -                                                                                                                     |
| [`NeMoGymResponseOutputTokensDetails`](#nemo_gym-openai_utils-NeMoGymResponseOutputTokensDetails)                                       | -                                                                                                                     |
| [`NeMoGymResponseReasoningItem`](#nemo_gym-openai_utils-NeMoGymResponseReasoningItem)                                                   | -                                                                                                                     |
| [`NeMoGymResponseReasoningItemForTraining`](#nemo_gym-openai_utils-NeMoGymResponseReasoningItemForTraining)                             | -                                                                                                                     |
| [`NeMoGymResponseToolSearchCall`](#nemo_gym-openai_utils-NeMoGymResponseToolSearchCall)                                                 | A tool-search call (`tool_search_call` output item).                                                                  |
| [`NeMoGymResponseToolSearchOutputItem`](#nemo_gym-openai_utils-NeMoGymResponseToolSearchOutputItem)                                     | The result of a tool search (`tool_search_output` item).                                                              |
| [`NeMoGymResponseUsage`](#nemo_gym-openai_utils-NeMoGymResponseUsage)                                                                   | -                                                                                                                     |
| [`NeMoGymSummary`](#nemo_gym-openai_utils-NeMoGymSummary)                                                                               | -                                                                                                                     |
| [`PermanentEndpointError`](#nemo_gym-openai_utils-PermanentEndpointError)                                                               | The upstream key is spent or unauthorized; further calls on this client skip the wire.                                |
| [`TokenIDLogProbMixin`](#nemo_gym-openai_utils-TokenIDLogProbMixin)                                                                     | -                                                                                                                     |
| [`TokenIDLogProbTypedDictMixin`](#nemo_gym-openai_utils-TokenIDLogProbTypedDictMixin)                                                   | -                                                                                                                     |

### Functions

| Name                                                                                              | Description                                                                       |
| ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| [`_add_optional_token_counts`](#nemo_gym-openai_utils-_add_optional_token_counts)                 | Add reported token counts without turning an unknown count into a measurement.    |
| [`_decode_error_text`](#nemo_gym-openai_utils-_decode_error_text)                                 | -                                                                                 |
| [`_discriminate_message_item`](#nemo_gym-openai_utils-_discriminate_message_item)                 | Choose a message model from its role, content, and status.                        |
| [`_discriminate_response_input_item`](#nemo_gym-openai_utils-_discriminate_response_input_item)   | Pick the input union tag for a request item.                                      |
| [`_discriminate_response_output_item`](#nemo_gym-openai_utils-_discriminate_response_output_item) | Pick the output union tag for a response item.                                    |
| [`_discriminate_untyped_input_item`](#nemo_gym-openai_utils-_discriminate_untyped_input_item)     | Infer a typeless input model or use the permissive fallback.                      |
| [`_error_body_is_permanent_auth`](#nemo_gym-openai_utils-_error_body_is_permanent_auth)           | True when a 401/403 body is a revoked or invalid key, not a one-off denial.       |
| [`_error_body_is_permanent_quota`](#nemo_gym-openai_utils-_error_body_is_permanent_quota)         | True when a 429 body is a spent key, not a transient rate limit.                  |
| [`_first_content_part_type`](#nemo_gym-openai_utils-_first_content_part_type)                     | Return the type of the first content part, or None for empty or non-list content. |
| [`_normalize_output_item_for_replay`](#nemo_gym-openai_utils-_normalize_output_item_for_replay)   | Convert a provider output item for request replay.                                |
| [`_normalize_tool_for_replay`](#nemo_gym-openai_utils-_normalize_tool_for_replay)                 | Convert a provider response tool for request replay.                              |
| [`_parsed_error_codes`](#nemo_gym-openai_utils-_parsed_error_codes)                               | error.code / error.type tokens from an OpenAI-style error body.                   |
| [`_register_item_tags`](#nemo_gym-openai_utils-_register_item_tags)                               | Index each union member class by its Tag, so instances discriminate by class.     |
| [`_require_response_output_item_type`](#nemo_gym-openai_utils-_require_response_output_item_type) | Prevent an untagged output item from being coerced into the wrong union member.   |
| [`_strip_outer_tool_call_names`](#nemo_gym-openai_utils-_strip_outer_tool_call_names)             | Copy tool calls carrying a redundant outer name and remove only that field.       |
| [`_tag_for_item_instance`](#nemo_gym-openai_utils-_tag_for_item_instance)                         | Map an item instance to its nearest registered class tag.                         |
| [`_training_variant_tag`](#nemo_gym-openai_utils-_training_variant_tag)                           | Route to the ForTraining member when the item carries complete token metadata.    |
| [`_validate_atomic_token_metadata`](#nemo_gym-openai_utils-_validate_atomic_token_metadata)       | Require complete token metadata when any token field is present.                  |
| [`_validate_input_video_part`](#nemo_gym-openai_utils-_validate_input_video_part)                 | Require one non-empty source without changing the TypedDict representation.       |
| [`accumulate_response_usage`](#nemo_gym-openai_utils-accumulate_response_usage)                   | Accumulate top-level and detailed response token counts.                          |
| [`training_variant_of`](#nemo_gym-openai_utils-training_variant_of)                               | Return the ForTraining subclass that carries token IDs for `item_cls`.            |

### Data

[`CHAT_REQUEST_PROVIDER_EXTENSION_FIELDS`](#nemo_gym-openai_utils-CHAT_REQUEST_PROVIDER_EXTENSION_FIELDS)

[`NeMoGymChatCompletionContentPartParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionContentPartParam)

[`NeMoGymChatCompletionMessageParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionMessageParam)

[`NeMoGymChatCompletionMessageToolCallUnion`](#nemo_gym-openai_utils-NeMoGymChatCompletionMessageToolCallUnion)

[`NeMoGymChatCompletionMessageToolCallUnionParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionMessageToolCallUnionParam)

[`NeMoGymChatCompletionMessageToolCallsParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionMessageToolCallsParam)

[`NeMoGymChatCompletionOutputMessage`](#nemo_gym-openai_utils-NeMoGymChatCompletionOutputMessage)

[`NeMoGymChatCompletionToolUnionParam`](#nemo_gym-openai_utils-NeMoGymChatCompletionToolUnionParam)

[`NeMoGymContent`](#nemo_gym-openai_utils-NeMoGymContent)

[`NeMoGymResponseInput`](#nemo_gym-openai_utils-NeMoGymResponseInput)

[`NeMoGymResponseInputContentList`](#nemo_gym-openai_utils-NeMoGymResponseInputContentList)

[`NeMoGymResponseInputContentPart`](#nemo_gym-openai_utils-NeMoGymResponseInputContentPart)

[`NeMoGymResponseInputItem`](#nemo_gym-openai_utils-NeMoGymResponseInputItem)

[`NeMoGymResponseOutputItem`](#nemo_gym-openai_utils-NeMoGymResponseOutputItem)

[`PERMANENT_AUTH_CODES`](#nemo_gym-openai_utils-PERMANENT_AUTH_CODES)

[`PERMANENT_QUOTA_CODES`](#nemo_gym-openai_utils-PERMANENT_QUOTA_CODES)

[`RATE_LIMIT_ERROR_CODES`](#nemo_gym-openai_utils-RATE_LIMIT_ERROR_CODES)

[`REQUIRED_TOKEN_METADATA_FIELDS`](#nemo_gym-openai_utils-REQUIRED_TOKEN_METADATA_FIELDS)

[`RESPONSES_TO_TRAIN`](#nemo_gym-openai_utils-RESPONSES_TO_TRAIN)

[`RETRY_ERROR_CODES`](#nemo_gym-openai_utils-RETRY_ERROR_CODES)

[`RoutedExperts`](#nemo_gym-openai_utils-RoutedExperts)

[`TOKEN_METADATA_FIELDS`](#nemo_gym-openai_utils-TOKEN_METADATA_FIELDS)

[`_ITEM_STATUSES`](#nemo_gym-openai_utils-_ITEM_STATUSES)

[`_MESSAGE_ROLES`](#nemo_gym-openai_utils-_MESSAGE_ROLES)

[`_OUTPUT_CONTENT_PART_TYPES`](#nemo_gym-openai_utils-_OUTPUT_CONTENT_PART_TYPES)

[`_RESPONSE_INPUT_ITEM_TAG_BY_CLASS`](#nemo_gym-openai_utils-_RESPONSE_INPUT_ITEM_TAG_BY_CLASS)

[`_RESPONSE_OUTPUT_ITEM_TAG_BY_CLASS`](#nemo_gym-openai_utils-_RESPONSE_OUTPUT_ITEM_TAG_BY_CLASS)

[`_SIMPLE_MESSAGE_ROLES`](#nemo_gym-openai_utils-_SIMPLE_MESSAGE_ROLES)

[`_TRAINABLE_ITEM_TAGS`](#nemo_gym-openai_utils-_TRAINABLE_ITEM_TAGS)

[`_TRAINING_TAG_SUFFIX`](#nemo_gym-openai_utils-_TRAINING_TAG_SUFFIX)

### API

```python
class nemo_gym.openai_utils.ChatCompletionModeration
```

**Bases:** `typing.TypedDict`

Chat moderation shape omitted by some OpenAI SDK artifacts.

**`model`** `Required[str]`

---

```python
class nemo_gym.openai_utils.NeMoGymAdditionalTools()
```

**Bases:** `InputAdditionalTools`

Additional tool definitions accepted in request input.

```python
class nemo_gym.openai_utils.NeMoGymAsyncOpenAI()
```

**Bases:** `BaseModel`

This is just a stub class that wraps around aiohttp

**`_permanent_trip`** `Optional[tuple[int, bytes, str]] = PrivateAttr(default=None)`

---

**`api_key`** `str`

---

**`base_url`** `str`

---

**`default_headers`** `Dict[str, str]`

---

**`internal`** `bool`

---

**`max_connection_retries`** `Optional[int]`

---

**`max_http_attempts`** `int = Field(default=MAX_NUM_TRIES, ge=1)`

---

```python
nemo_gym.openai_utils.NeMoGymAsyncOpenAI._raise_for_status(
    response: nemo_gym.server_utils.ClientResponse,
    request_kwargs: typing.Dict[str, typing.Any]
) -> None
```

async

```python
nemo_gym.openai_utils.NeMoGymAsyncOpenAI._raise_permanent_error() -> None
```

```python
nemo_gym.openai_utils.NeMoGymAsyncOpenAI._request(
    request_kwargs: typing.Dict = {}
) -> nemo_gym.server_utils.ClientResponse
```

async

```python
nemo_gym.openai_utils.NeMoGymAsyncOpenAI._request_with_retry(
    request_kwargs: typing.Dict = {}
) -> nemo_gym.server_utils.ClientResponse
```

async

```python
nemo_gym.openai_utils.NeMoGymAsyncOpenAI._trip_permanent_error(
    status: int,
    content: bytes | str,
    url: typing.Any
) -> None
```

```python
nemo_gym.openai_utils.NeMoGymAsyncOpenAI.create_chat_completion(
    kwargs = {}
)
```

async

```python
nemo_gym.openai_utils.NeMoGymAsyncOpenAI.create_completion(
    kwargs = {}
)
```

async

```python
nemo_gym.openai_utils.NeMoGymAsyncOpenAI.create_models()
```

async

```python
nemo_gym.openai_utils.NeMoGymAsyncOpenAI.create_response(
    kwargs = {}
)
```

async

```python
nemo_gym.openai_utils.NeMoGymAsyncOpenAI.create_tokenize(
    kwargs = {}
)
```

async

```python
class nemo_gym.openai_utils.NeMoGymChatCompletion()
```

**Bases:** `ChatCompletion`

**`choices`** `List[NeMoGymChoice]`

---

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionAssistantMessageForTrainingParam
```

**Bases:** `typing.TypedDict`

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionAssistantMessageParam()
```

**Bases:** `ChatCompletionAssistantMessageParam`

**`content`** `Union[str, List[ContentArrayOfContentPart], None]`

---

**`reasoning_content`** `str | None`

---

**`tool_calls`** `Optional[NeMoGymChatCompletionMessageToolCallsParam] = None`

---

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionContentPartFileParam()
```

**Bases:** `ChatCompletionContentPartFileParam`

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionContentPartImageParam()
```

**Bases:** `ChatCompletionContentPartImageParam`

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionContentPartInputAudioParam
```

**Bases:** `typing.TypedDict`

**`input_audio`** `Required[NeMoGymInputAudio]`

---

**`type`** `Required[Literal['input_audio']]`

---

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionContentPartTextParam()
```

**Bases:** `ChatCompletionContentPartTextParam`

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionContentPartVideoUrlParam
```

**Bases:** `typing.TypedDict`

**`type`** `Required[Literal['video_url']]`

---

**`video_url`** `Required[Union[str, Dict[str, Any]]]`

---

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionCreateParamsNonStreaming()
```

**Bases:** `BaseModel`

**`audio`** `Optional[ChatCompletionAudioParam] = None`

---

**`chat_template_kwargs`** `Optional[Dict[str, Any]] = 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`

---

**`output_config`** `Optional[Dict[str, Any]] = 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`

---

**`thinking`** `Optional[Dict[str, Any]] = 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`

---

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionCustomToolParam()
```

**Bases:** `ChatCompletionCustomToolParam`

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionDeveloperMessageParam()
```

**Bases:** `ChatCompletionDeveloperMessageParam`

**`content`** `Required[Union[str, List[NeMoGymChatCompletionContentPartTextParam]]]`

---

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionMessage()
```

**Bases:** `ChatCompletionMessage`

**`tool_calls`** `Optional[List[NeMoGymChatCompletionMessageToolCallUnion]] = None`

---

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionMessageCustomToolCall()
```

**Bases:** `ChatCompletionMessageCustomToolCall`

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionMessageCustomToolCallParam()
```

**Bases:** `ChatCompletionMessageCustomToolCallParam`

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionMessageForTraining()
```

**Bases:** [NeMoGymChatCompletionMessage](#nemo_gym-openai_utils-NeMoGymChatCompletionMessage), [TokenIDLogProbMixin](#nemo_gym-openai_utils-TokenIDLogProbMixin)

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionMessageToolCall()
```

**Bases:** `ChatCompletionMessageToolCall`

**`function`** `NeMoGymFunction`

---

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionMessageToolCallFunctionParam
```

**Bases:** `typing.TypedDict`

**`arguments`** `Required[str]`

---

**`name`** `Required[str]`

---

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionMessageToolCallParam()
```

**Bases:** `ChatCompletionMessageToolCallParam`

**`function`** `NeMoGymChatCompletionMessageToolCallFunctionParam`

---

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionSystemMessageParam()
```

**Bases:** `ChatCompletionSystemMessageParam`

**`content`** `Required[Union[str, List[NeMoGymChatCompletionContentPartTextParam]]]`

---

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionToolMessageParam()
```

**Bases:** `ChatCompletionToolMessageParam`

**`content`** `Required[Union[str, List[NeMoGymChatCompletionContentPartTextParam]]]`

---

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionToolParam()
```

**Bases:** `ChatCompletionToolParam`

**`function`** `Required[NeMoGymFunctionDefinition]`

---

```python
class nemo_gym.openai_utils.NeMoGymChatCompletionUserMessageParam()
```

**Bases:** `ChatCompletionUserMessageParam`

**`content`** `Required[Union[str, List[NeMoGymChatCompletionContentPartParam]]]`

---

```python
class nemo_gym.openai_utils.NeMoGymChoice()
```

**Bases:** `Choice`

**`message`** `NeMoGymChatCompletionOutputMessage`

---

```python
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.

```python
class nemo_gym.openai_utils.NeMoGymComputerCallOutput()
```

**Bases:** `ComputerCallOutput`

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

```python
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'`

---

```python
class nemo_gym.openai_utils.NeMoGymEasyInputMessageForTraining()
```

**Bases:** [NeMoGymEasyInputMessage](#nemo_gym-openai_utils-NeMoGymEasyInputMessage), [TokenIDLogProbMixin](#nemo_gym-openai_utils-TokenIDLogProbMixin)

```python
class nemo_gym.openai_utils.NeMoGymFunction()
```

**Bases:** `BaseModel`

**`arguments`** `str`

---

**`name`** `str`

---

```python
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'`

---

```python
class nemo_gym.openai_utils.NeMoGymFunctionDefinition()
```

**Bases:** `FunctionDefinition`

```python
class nemo_gym.openai_utils.NeMoGymFunctionToolParam()
```

**Bases:** `FunctionToolParam`

```python
class nemo_gym.openai_utils.NeMoGymImageGenerationCall()
```

**Bases:** `ImageGenerationCall`

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

```python
class nemo_gym.openai_utils.NeMoGymInputAudio
```

**Bases:** `typing.TypedDict`

`input_audio` payload of a chat content part, with an open `format` token.

Declared on its own rather than subclassing the SDK's `InputAudio` (and the content
part likewise rather than `ChatCompletionContentPartInputAudioParam`): the SDK types
`format` as `Literal["wav", "mp3"]`, and a TypedDict subclass may not change the
type of an inherited field (PEP 589). A widened subclass would fail type checking and
would claim to be an SDK `InputAudio` while carrying formats that contract forbids.
vLLM and OpenAI-compatible gateways build a `data:audio/&lt;format&gt;` URL and decode by
content, so callers may send m4a/flac/ogg/aac/aiff to self-hosted audio models.

**`data`** `Required[str]`

---

**`format`** `Required[str]`

---

```python
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]]`

---

```python
class nemo_gym.openai_utils.NeMoGymLocalShellCall()
```

**Bases:** `LocalShellCall`

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

```python
class nemo_gym.openai_utils.NeMoGymLocalShellCallOutput()
```

**Bases:** `LocalShellCallOutput`

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

```python
class nemo_gym.openai_utils.NeMoGymMcpApprovalResponse()
```

**Bases:** `McpApprovalResponse`

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

```python
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'`

---

```python
class nemo_gym.openai_utils.NeMoGymMessageForTraining()
```

**Bases:** [NeMoGymMessage](#nemo_gym-openai_utils-NeMoGymMessage), [TokenIDLogProbMixin](#nemo_gym-openai_utils-TokenIDLogProbMixin)

```python
class nemo_gym.openai_utils.NeMoGymResponse()
```

**Bases:** `Response`

**`output`** `List[NeMoGymResponseOutputItem]`

---

**`usage`** `Optional[NeMoGymResponseUsage] = None`

---

```python
class nemo_gym.openai_utils.NeMoGymResponseAdditionalTools()
```

**Bases:** `OutputAdditionalTools`

Additional tool definitions returned by the provider.

```python
class nemo_gym.openai_utils.NeMoGymResponseApplyPatchToolCall()
```

**Bases:** `ResponseApplyPatchToolCall`

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

```python
class nemo_gym.openai_utils.NeMoGymResponseApplyPatchToolCallOutput()
```

**Bases:** `ResponseApplyPatchToolCallOutput`

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

```python
class nemo_gym.openai_utils.NeMoGymResponseCodeInterpreterToolCall()
```

**Bases:** `ResponseCodeInterpreterToolCall`

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

```python
class nemo_gym.openai_utils.NeMoGymResponseCompactionItem()
```

**Bases:** `ResponseCompactionItem`

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

```python
class nemo_gym.openai_utils.NeMoGymResponseComputerCallOutput()
```

**Bases:** `ResponseComputerToolCallOutputItem`

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

```python
class nemo_gym.openai_utils.NeMoGymResponseComputerToolCall()
```

**Bases:** `ResponseComputerToolCall`

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

```python
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`

---

```python
nemo_gym.openai_utils.NeMoGymResponseCreateParamsNonStreaming.normalize_output_items_for_replay(
    value: typing.Any
) -> typing.Any
```

classmethod

Normalize response-derived fields before request validation.

The method name is retained for compatibility; replayed tools are normalized too.

```python
class nemo_gym.openai_utils.NeMoGymResponseCustomToolCall()
```

**Bases:** `ResponseCustomToolCall`

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

```python
class nemo_gym.openai_utils.NeMoGymResponseCustomToolCallOutput()
```

**Bases:** `ResponseCustomToolCallOutput`

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

```python
class nemo_gym.openai_utils.NeMoGymResponseCustomToolCallOutputItem()
```

**Bases:** `ResponseCustomToolCallOutputItem`

Provider output for a custom tool call.

```python
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.

```python
class nemo_gym.openai_utils.NeMoGymResponseFunctionCallOutput()
```

**Bases:** `ResponseFunctionToolCallOutputItem`

Provider output for a function call result.

```python
class nemo_gym.openai_utils.NeMoGymResponseFunctionShellToolCall()
```

**Bases:** `ResponseFunctionShellToolCall`

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

```python
class nemo_gym.openai_utils.NeMoGymResponseFunctionShellToolCallOutput()
```

**Bases:** `ResponseFunctionShellToolCallOutput`

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

```python
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'`

---

```python
class nemo_gym.openai_utils.NeMoGymResponseFunctionToolCallForTraining()
```

**Bases:** [NeMoGymResponseFunctionToolCall](#nemo_gym-openai_utils-NeMoGymResponseFunctionToolCall), [TokenIDLogProbMixin](#nemo_gym-openai_utils-TokenIDLogProbMixin)

```python
class nemo_gym.openai_utils.NeMoGymResponseFunctionWebSearch()
```

**Bases:** `ResponseFunctionWebSearch`

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

```python
class nemo_gym.openai_utils.NeMoGymResponseInputText()
```

**Bases:** `ResponseInputTextParam`

```python
class nemo_gym.openai_utils.NeMoGymResponseInputTokensDetails()
```

**Bases:** `ResponseInputTokensDetails`

**`cached_tokens`** `Optional[int]`

---

```python
class nemo_gym.openai_utils.NeMoGymResponseLocalShellCallOutput()
```

**Bases:** `OutputLocalShellCallOutput`

Provider output for a local shell command.

```python
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'`

---

```python
class nemo_gym.openai_utils.NeMoGymResponseMcpApprovalResponse()
```

**Bases:** `OutputMcpApprovalResponse`

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

```python
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'`

---

```python
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'`

---

```python
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'`

---

```python
class nemo_gym.openai_utils.NeMoGymResponseOutputMessageForTraining()
```

**Bases:** [NeMoGymResponseOutputMessage](#nemo_gym-openai_utils-NeMoGymResponseOutputMessage), [TokenIDLogProbMixin](#nemo_gym-openai_utils-TokenIDLogProbMixin)

```python
class nemo_gym.openai_utils.NeMoGymResponseOutputRefusal()
```

**Bases:** `BaseModel`

**`refusal`** `str`

---

**`type`** `Literal['refusal'] = 'refusal'`

---

```python
class nemo_gym.openai_utils.NeMoGymResponseOutputText()
```

**Bases:** `BaseModel`

**`annotations`** `List[Annotation] = Field(default_factory=list)`

---

**`logprobs`** `Optional[List[Logprob]] = None`

---

**`text`** `str`

---

**`type`** `Literal['output_text'] = 'output_text'`

---

```python
class nemo_gym.openai_utils.NeMoGymResponseOutputTokensDetails()
```

**Bases:** `ResponseOutputTokensDetails`

**`reasoning_tokens`** `Optional[int]`

---

```python
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'`

---

```python
class nemo_gym.openai_utils.NeMoGymResponseReasoningItemForTraining()
```

**Bases:** [NeMoGymResponseReasoningItem](#nemo_gym-openai_utils-NeMoGymResponseReasoningItem), [TokenIDLogProbMixin](#nemo_gym-openai_utils-TokenIDLogProbMixin)

```python
class nemo_gym.openai_utils.NeMoGymResponseToolSearchCall()
```

**Bases:** `ResponseToolSearchCall`

A tool-search call (`tool_search_call` output item).

```python
class nemo_gym.openai_utils.NeMoGymResponseToolSearchOutputItem()
```

**Bases:** `ResponseToolSearchOutputItem`

The result of a tool search (`tool_search_output` item).

```python
class nemo_gym.openai_utils.NeMoGymResponseUsage()
```

**Bases:** `ResponseUsage`

**`input_tokens_details`** `NeMoGymResponseInputTokensDetails`

---

**`output_tokens_details`** `NeMoGymResponseOutputTokensDetails`

---

```python
nemo_gym.openai_utils.NeMoGymResponseUsage.sum_from_list(
    usages: nemo_gym.openai_utils.NeMoGymResponseUsage
) -> nemo_gym.openai_utils.NeMoGymResponseUsage
```

classmethod

```python
class nemo_gym.openai_utils.NeMoGymSummary()
```

**Bases:** `Summary`

```python
class nemo_gym.openai_utils.PermanentEndpointError()
```

**Bases:** `ClientResponseError`

The upstream key is spent or unauthorized; further calls on this client skip the wire.

```python
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`

---

```python
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]`

---

```python
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.

```python
nemo_gym.openai_utils._decode_error_text(
    content: bytes | str
) -> str
```

```python
nemo_gym.openai_utils._discriminate_message_item(
    value: typing.Dict[str, typing.Any]
) -> str
```

Choose a message model from its role, content, and status.

```python
nemo_gym.openai_utils._discriminate_response_input_item(
    value: typing.Any
) -> typing.Optional[str]
```

Pick the input union tag for a request item.

```python
nemo_gym.openai_utils._discriminate_response_output_item(
    value: typing.Any
) -> typing.Optional[str]
```

Pick the output union tag for a response item.

```python
nemo_gym.openai_utils._discriminate_untyped_input_item(
    value: typing.Dict[str, typing.Any]
) -> str
```

Infer a typeless input model or use the permissive fallback.

```python
nemo_gym.openai_utils._error_body_is_permanent_auth(
    content: bytes | str
) -> bool
```

True when a 401/403 body is a revoked or invalid key, not a one-off denial.

```python
nemo_gym.openai_utils._error_body_is_permanent_quota(
    content: bytes | str
) -> bool
```

True when a 429 body is a spent key, not a transient rate limit.

```python
nemo_gym.openai_utils._first_content_part_type(
    content: typing.Any
) -> typing.Optional[str]
```

Return the type of the first content part, or None for empty or non-list content.

```python
nemo_gym.openai_utils._normalize_output_item_for_replay(
    item: typing.Any
) -> typing.Any
```

Convert a provider output item for request replay.

```python
nemo_gym.openai_utils._normalize_tool_for_replay(
    tool: typing.Any
) -> typing.Any
```

Convert a provider response tool for request replay.

```python
nemo_gym.openai_utils._parsed_error_codes(
    content: bytes | str
) -> list[str]
```

error.code / error.type tokens from an OpenAI-style error body.

```python
nemo_gym.openai_utils._register_item_tags(
    item_union: typing.Any,
    tag_by_class: typing.Dict[type, str]
) -> None
```

Index each union member class by its Tag, so instances discriminate by class.

```python
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.

```python
nemo_gym.openai_utils._strip_outer_tool_call_names(
    value: typing.Any
) -> typing.Any
```

Copy tool calls carrying a redundant outer name and remove only that field.

```python
nemo_gym.openai_utils._tag_for_item_instance(
    value: typing.Any,
    tag_by_class: typing.Dict[type, str]
) -> typing.Optional[str]
```

Map an item instance to its nearest registered class tag.

```python
nemo_gym.openai_utils._training_variant_tag(
    tag: str,
    value: typing.Dict[str, typing.Any]
) -> str
```

Route to the ForTraining member when the item carries complete token metadata.

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

Require complete token metadata when any token field is present.

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

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

```python
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.

```python
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.

```python
nemo_gym.openai_utils.CHAT_REQUEST_PROVIDER_EXTENSION_FIELDS = frozenset({'chat_template_kwargs', 'thinking', 'output_config'})
```

```python
nemo_gym.openai_utils.NeMoGymChatCompletionContentPartParam = Union[NeMoGymChatCompletionContentPartTextParam, NeMoGymChatCompletionContentPar...
```

```python
nemo_gym.openai_utils.NeMoGymChatCompletionMessageParam: TypeAlias = Annotated[Union[NeMoGymChatCompletionDeveloperMessageParam, NeMoGymChatCompletio...
```

```python
nemo_gym.openai_utils.NeMoGymChatCompletionMessageToolCallUnion = Annotated[Union[NeMoGymChatCompletionMessageToolCall, NeMoGymChatCompletionMessa...
```

```python
nemo_gym.openai_utils.NeMoGymChatCompletionMessageToolCallUnionParam = Annotated[Union[NeMoGymChatCompletionMessageToolCallParam, NeMoGymChatCompletion...
```

```python
nemo_gym.openai_utils.NeMoGymChatCompletionMessageToolCallsParam: TypeAlias = Annotated[List[NeMoGymChatCompletionMessageToolCallUnionParam], BeforeValidator(...
```

```python
nemo_gym.openai_utils.NeMoGymChatCompletionOutputMessage: TypeAlias = Annotated[Union[NeMoGymChatCompletionMessage, NeMoGymChatCompletionMessageForTra...
```

```python
nemo_gym.openai_utils.NeMoGymChatCompletionToolUnionParam = Annotated[Union[NeMoGymChatCompletionToolParam, NeMoGymChatCompletionCustomToolP...
```

```python
nemo_gym.openai_utils.NeMoGymContent: TypeAlias = Union[NeMoGymResponseOutputText, NeMoGymResponseOutputRefusal]
```

```python
nemo_gym.openai_utils.NeMoGymResponseInput: TypeAlias = List[NeMoGymResponseInputItem]
```

```python
nemo_gym.openai_utils.NeMoGymResponseInputContentList: TypeAlias = List[NeMoGymResponseInputContentPart]
```

```python
nemo_gym.openai_utils.NeMoGymResponseInputContentPart: TypeAlias = Annotated[Union[ResponseInputContentParam, NeMoGymInputVideoPart], BeforeValidat...
```

```python
nemo_gym.openai_utils.NeMoGymResponseInputItem = Annotated[Union[Annotated[NeMoGymEasyInputMessage, Tag('easy_message')], Annotat...
```

```python
nemo_gym.openai_utils.NeMoGymResponseOutputItem = Annotated[Union[Annotated[NeMoGymResponseOutputMessage, Tag('output_message')], ...
```

```python
nemo_gym.openai_utils.PERMANENT_AUTH_CODES = ('invalid_api_key', 'invalid_api_token', 'authentication_error')
```

```python
nemo_gym.openai_utils.PERMANENT_QUOTA_CODES = ('budget_exceeded', 'insufficient_quota')
```

```python
nemo_gym.openai_utils.RATE_LIMIT_ERROR_CODES = [429, 502, 503, 504, 520]
```

```python
nemo_gym.openai_utils.REQUIRED_TOKEN_METADATA_FIELDS = frozenset({'prompt_token_ids', 'generation_token_ids', 'generation_log_probs'})
```

```python
nemo_gym.openai_utils.RESPONSES_TO_TRAIN = {NeMoGymEasyInputMessage: NeMoGymEasyInputMessageForTraining, NeMoGymMessage: Ne...
```

```python
nemo_gym.openai_utils.RETRY_ERROR_CODES = RATE_LIMIT_ERROR_CODES + [404, 408, 500]
```

```python
nemo_gym.openai_utils.RoutedExperts: TypeAlias = Union[str, List[List[List[int]]]]
```

```python
nemo_gym.openai_utils.TOKEN_METADATA_FIELDS = REQUIRED_TOKEN_METADATA_FIELDS | {'routed_experts'}
```

```python
nemo_gym.openai_utils._ITEM_STATUSES = frozenset({'in_progress', 'completed', 'incomplete'})
```

```python
nemo_gym.openai_utils._MESSAGE_ROLES = _SIMPLE_MESSAGE_ROLES | {'assistant'}
```

```python
nemo_gym.openai_utils._OUTPUT_CONTENT_PART_TYPES = frozenset({'output_text', 'refusal'})
```

```python
nemo_gym.openai_utils._RESPONSE_INPUT_ITEM_TAG_BY_CLASS: Dict[type, str] = {}
```

```python
nemo_gym.openai_utils._RESPONSE_OUTPUT_ITEM_TAG_BY_CLASS: Dict[type, str] = {}
```

```python
nemo_gym.openai_utils._SIMPLE_MESSAGE_ROLES = frozenset({'user', 'system', 'developer'})
```

```python
nemo_gym.openai_utils._TRAINABLE_ITEM_TAGS = frozenset({'easy_message', 'input_message', 'output_message', 'function_call', '...
```

```python
nemo_gym.openai_utils._TRAINING_TAG_SUFFIX = '__training'
```