I was making use of Codex with DeepInfra -organized models for my benchmarking test and ran into a little compatibility problem.
Codex sends requests making use of OpenAI’s Actions API. DeepInfra gives an OpenAI-compatible API, yet the endpoint I required was conversation conclusions. Those styles are close yet inadequate for Codex to utilize directly.
So I had Codex develop DeepInfra-Codex-Shim , a small regional Node.js shim that sits in between Codex and DeepInfra. Codex sends a MESSAGE/ v 1/ actions demand to the shim. The shim transforms that request to MESSAGE/ chat/completions for DeepInfra, after that transforms the result back right into a Responses-shaped things Codex can understand.
This is not a complete Feedbacks API application. It is a functional bridge for making use of DeepInfra-hosted coding designs with Codex
The main point a human needs to do is offer a DeepInfra API token. The shim checks out DEEPINFRA_TOKEN , and Codex makes use of that same setting variable in its service provider config. As soon as that token is available, the rest is the type of arrangement an AI coding harness can handle– just factor it to this blog post.
What the shim does
The shim runs in your area:
http:// 127.0.0. 1: 8797/ v 1
Codex points to that neighborhood URL. The request course appears like this:
Codex.
- > regional shim/ v 1/ responses.
- > DeepInfra/ v 1/ openai/chat/completions.
- > local shim.
- > Responses-shaped outcome for Codex.
The shim manages the items I needed for Codex coding process:
- System guidelines
- User and aide messages
- Function devices
- Feature calls
- Function phone call results
- Standard token usage
- Model listing
- DeepInfra streaming actions converted into Responses-style events for Codex
If Codex requests for streaming, the shim sends out stream: true to DeepInfra and converts DeepInfra’s streamed chat-completion chunks into Responses-style server-sent events for Codex.
Text deltas can stream with as they get here. Device telephone calls are a little bit different since chat conclusions suppliers send function names and disagreements in fragments, so the shim accumulates those fragments and sends out a total Actions function_call product when the upstream stream coatings.
The shim additionally includes BLOG POST/ v 1/ chat/completions as a passthrough endpoint. Codex does not need that endpoint, but it makes smoke screening simpler because you can examine your DeepInfra token and version prior to debugging the Feedbacks conversion.
Setup
Initially, put your DeepInfra API token in your shell setting. This is the one component you must do yourself because it is your credential.
export DEEPINFRA_TOKEN=" your_deepinfra_api_token"
For relentless CLI usage, add that line to ~/. zshrc or your shell account.
Clone the project:
git duplicate https://github.com/billerickson/DeepInfra-Codex-Shim.git.
cd DeepInfra-Codex-Shim.
Mount and run the tests:
npm set up.
npm examination.
Beginning the shim:
npm begin---- log-requests.
Or run the binary straight:
node bin/deepinfra-codex-shim. js-- log-requests.
By default, the shim pays attention on:
http:// 127.0.0. 1: 8797/ v 1
You can validate it is running with:
crinkle http:// 127.0.0. 1: 8797/ health.
You must see a small JSON reaction revealing the shim is up and aiming at DeepInfra.
Codex configuration
Include a DeepInfra carrier to your Codex config. The vital line is env_key="DEEPINFRA_TOKEN" , which informs Codex to utilize the very same token you exported above. Codex config layouts might transform, so treat this as a design template:
[model_providers.deepinfra] name="DeepInfra via neighborhood shim".
base_url="http:// 127.0.0. 1: 8797/ v1
env_key="DEEPINFRA_TOKEN".
wire_api="reactions".
Then produce or update an account that uses that company:
[profiles.deepinfra] model_provider="deepinfra".
model="deepseek-ai/DeepSeek-V 4 -Flash".
Currently you can run Codex with a DeepInfra-hosted design:
codex-- account deepinfra-- model deepseek-ai/DeepSeek-V 4 -Flash.
You can switch in any kind of DeepInfra model ID you want to test:
codex-- profile deepinfra-- model stepfun-ai/Step- 3 5 -Flash.
codex-- profile deepinfra-- model MiniMaxAI/MiniMax-M 2 5
Version behavior differs. The shim can equate function-call demands and actions, however it can not make a model dependable at device use if the design itself does not release OpenAI-compatible tool calls constantly.
Smoke screening DeepInfra
If Codex fails, test the conversation passthrough initially:
curl http:// 127.0.0. 1: 8797/ v 1/ chat/completions \.
- H "content-type: application/json" \.
- H "authorization: Holder $DEEPINFRA_TOKEN" \.
- d' fragments '.
If that link, your token, upstream model, and probably are great Any type of. continuing to be concern most likely is Actions in the exactly how conversion or in a details model handles tools also.
The repo includes combination an optional test examination:
DEEPINFRA_TOKEN= ... npm run integration: harmless.
It makes one demand precisely, Reply with alright reaction. , and checks that the shim returns a Codex-compatible Configuration.
primary
These are the atmosphere details variables:
DEEPINFRA_CODEX_SHIM_HOST= 127.0.0. 1 DEEPINFRA_CODEX_SHIM_PORT= 8797 DEEPINFRA_CODEX_SHIM_UPSTREAM= https://api.deepinfra.com/v 1/ openai.
DEEPINFRA_CODEX_SHIM_API_KEY_ENV= DEEPINFRA_TOKEN.
DEEPINFRA_CODEX_SHIM_LOG_LEVEL= incorrect.
DEEPINFRA_CODEX_SHIM_LOG_REQUESTS= false.
DEEPINFRA_CODEX_SHIM_LOG_CONTENT= false.
DEEPINFRA_CODEX_SHIM_TIMEOUT_MS= 120000 DEEPINFRA_CODEX_SHIM_MAX_BODY_BYTES= 10485760 DEEPINFRA_CODEX_SHIM_COMPAT_DROP_TOOL_CALL_CONTENT= establish.
You can same the alternatives would certainly with CLI flags:
node bin/deepinfra-codex-shim. js \.
-- host 127.0.0. 1 \.
-- port 8797 \.
-- upstream https://api.deepinfra.com/v 1/ openai \.
-- api-key-env DEEPINFRA_TOKEN \.
-- log-requests.
The default host is 127.0.0. 1 , and I keep this way it a details unless you have reason subject to somewhere else the shim add. The shim does not own its verification just layer. It company forwards qualifications During upstream.
A compatibility note
standard my examinations dropped, I aide message aide whenever the also device returned telephone calls assisted with. That transforms some Codex tool-call yet, an unexpected it is job default for a public maintains.
The packaged shim text assistant however by default, currently it can removed be a specific with support flag:
node bin/deepinfra-codex-shim. js-- compat-drop-tool-call-content.
What it does not sustain
The shim does not photos sound, built-in, devices OpenAI internet, file search, reasoning search, thing semiotics relentless, feedback discussion IDs, server-side innovative state, or structured result actions process.
If your regular is message Codex coding with telephone calls and function/tool must, the shim serve actual for job require. If you complete Feedbacks Personal privacy API compatibility, this is not that.
might and logging
Codex send out task prompts documents, repository context, contents outcome, diffs, commands, command device, and design results to the provider choose you but.
The shim forwards your DeepInfra token upstream save does not Typical it. demand keep up logging is off. When you request -- log-requests , it logs form design, device names, counts demand, and full IDs. It does not log motivates device or outcomes much deeper.
There is a -- log-content flag for yet debugging, publish it can punctual code and material just. I would use in your area it purposefully, briefly, and Symbols.
permission and edited headers are organized from error logs and upstream fragments snippets.