ReqLLM. Providers. OpenAI. AdapterHelpers
(ReqLLM v1.12.0)
View Source
Shared helper functions for OpenAI-compatible model adapters (Azure, etc.).
These functions handle OpenAI-specific request formatting that is shared across providers hosting OpenAI models.
Summary
Functions
Adds parallel_tool_calls option to the request body.
Adds response_format to the request body with schema normalization.
Adds strict mode settings to tools that have strict: true on their function.
Adds appropriate token limit parameters based on model type.
Checks if model is a Codex model (codex-mini, gpt-5-codex, etc.).
Checks if model is a DeepSeek model.
Ensures all properties in a function's parameters schema are required.
Checks if model is a GPT-4o family model.
Checks if model is a GPT-5 reasoning model (excludes gpt-5-chat-latest).
Checks if model is a GPT-4.1 model.
Checks if model is an o-series reasoning model (o1, o3, o4).
Checks if a model ID corresponds to an OpenAI reasoning model.
Checks if a model ID should default to the Responses API.
Translates ReqLLM's tool_choice format to OpenAI's function format.
Functions
Adds parallel_tool_calls option to the request body.
Checks multiple option sources for the value:
opts[:parallel_tool_calls]provider_opts[:openai_parallel_tool_calls]provider_opts[:parallel_tool_calls]
Adds response_format to the request body with schema normalization.
Handles json_schema response formats by converting ReqLLM schema DSL to JSON Schema format. Supports both atom and string key maps.
Adds strict mode settings to tools that have strict: true on their function.
For tools with strict mode enabled:
- Sets
additionalProperties: falseon the parameters schema - Makes all properties required
Adds appropriate token limit parameters based on model type.
For reasoning models (o1, o3, o4, gpt-4.1, gpt-5):
- Uses
max_completion_tokensinstead ofmax_tokens - Falls back to
max_tokensvalue ifmax_completion_tokensnot specified
For standard models:
- Uses
max_tokensand optionallymax_completion_tokens
Cleans up any existing token limit keys to ensure consistent state.
Checks if model is a Codex model (codex-mini, gpt-5-codex, etc.).
Checks if model is a DeepSeek model.
Ensures all properties in a function's parameters schema are required.
Also sets additionalProperties: false for strict JSON schema compliance.
Checks if model is a GPT-4o family model.
Checks if model is a GPT-5 reasoning model (excludes gpt-5-chat-latest).
Checks if model is a GPT-4.1 model.
Checks if model is an o-series reasoning model (o1, o3, o4).
Checks if a model ID corresponds to an OpenAI reasoning model.
Reasoning models (o-series, gpt-4.1, gpt-5, codex) require special handling:
- Use
max_completion_tokensinstead ofmax_tokens - Support
reasoning_effortparameter
Note: gpt-5-chat-latest is a non-reasoning variant that uses standard conventions.
Checks if a model ID should default to the Responses API.
This includes reasoning/codex families plus GPT-4o models, which support Responses even when older metadata has not been updated yet.
Translates ReqLLM's tool_choice format to OpenAI's function format.
ReqLLM uses %{type: "tool", name: "tool_name"} for specific tool selection.
OpenAI requires %{type: "function", function: %{name: "tool_name"}}.
Handles both atom and string key maps.