Codex can use Tencent Cloud TokenHub through a custom model provider. Tencent Cloud's Codex guide demonstrates the setup with Hy3, while its Hunyuan API guide separately confirms that Hy4 supports the OpenAI Responses protocol. The configuration below adapts the Codex example by replacing the model name and environment variable with Hy4-specific values. This adaptation follows the official configuration structure and protocol documentation; Tencent Cloud has not published a Codex configuration specifically for Hy4 or stated that this combination has been tested specifically.
Suitable tasks: Reading, writing, and editing code in Codex with Hy4 through TokenHub.
Unsuitable tasks: Scenarios that require a specifically validated Hy4-Codex combination or guaranteed support for web search tools.
Applicable model version: TokenHub model ID hy4, the general-availability version of Hy4.
Applicable client, agent, or API: The Codex desktop app or CLI with a custom model provider; TokenHub Responses API.
Recommended reasoning level and parameters: Tencent Cloud says Hy4 enables deep thinking by default. The Codex integration guide does not explain how to override the reasoning level for a custom provider, so no reasoning parameters are added.
Configure the TokenHub provider in Codex's config.toml:
model_provider = "hy4-tokenhub"
model = "hy4"
disable_response_storage = true
[model_providers.hy4-tokenhub]
name = "Hy4 via TokenHub"
base_url = "https://tokenhub.tencentmaas.com/v1"
env_key = "HY4_API_KEY"
wire_api = "responses"Set the API key in an environment variable named HY4_API_KEY. Following Tencent Cloud's guide, run this on macOS:
launchctl setenv HY4_API_KEY "您的 TokenHub API Key"On Windows, run:
setx HY4_API_KEY "您的 TokenHub API Key"Create the API key in the TokenHub console and ensure its access scope includes Hy4. Do not put the real key in config.toml or commit it to a code repository.
Create an API key in the TokenHub console and confirm that its access scope includes Hy4.
Add the TOML configuration above to Codex's config.toml, and set the HY4_API_KEY environment variable for your operating system.
Fully quit Codex and restart it so it reloads the configuration and environment variables.
Start a simple conversation or ask for a code explanation to confirm that Hy4 returns a result. This is a suggested local verification workflow; this article did not actually call the model.
Tencent Cloud's Codex integration guide was most recently updated on 2026-09-28. It uses Hy3 as an example and provides settings such as model_provider, model, disable_response_storage, base_url, env_key, and wire_api = "responses". It also says that custom providers use default metadata estimates, and that a Model metadata ... not found message does not mean the model cannot be used.
Tencent Cloud's Hunyuan API guide lists hy4 as compatible with the OpenAI Responses protocol and distinguishes it from hy4-preview. This compatibility supports adapting the Codex example to hy4, but does not mean Tencent Cloud has published results from specific Hy4-Codex testing.
The Hunyuan API guide lists Hy4's context window as 1,024k, maximum input as 960k, and maximum output as 64k. The Codex guide does not provide corresponding context metadata settings for Hy4, so the example retains Codex's default estimates.
Tencent Cloud's Codex example uses Hy3. The Hy4 configuration is derived by replacing the model ID based on the Responses compatibility statement for the same TokenHub service; it has not been tested in this article.
Official materials do not say whether web_search works with Hy4 in Codex. This configuration neither enables nor disables the tool. If Codex reports a related tool compatibility error, you can try turning off web search in Codex and retrying. This is a diagnostic step and does not mean Hy4 has been verified to support the tool.
Codex may report that it cannot find model metadata for hy4 and use default estimates. That message alone does not prove that a model call succeeded; you still need to send a request to verify it. Before overriding the context estimate, confirm the configuration fields supported by your current Codex version and Hy4's effective context window.
This article did not verify key permissions, streaming output, tool calls, web search, or actual response quality.
On 2026-11-16, Tencent Cloud TokenHub's Codex integration guide and Hunyuan API guide were reviewed using Tabbit. The configuration is based on the Hy3 provider example on the Codex page and the Hy4 Responses compatibility listed in the Hunyuan guide. Codex was not installed, no local configuration was changed, and no request was made using an API key.
Hy4