Codex on a Grok Bot cloud computer returned code and an image in about 15 minutes
Overview
A CSDN blogger wants code and images with only a browser and no local setup. Install OpenAI's Codex CLI on the Grok Bot cloud computer, authenticate over the API with a TaoToken Base URL, key, and model IDs, and have the bot invoke Codex and deliver files in chat.
Workflow
Trigger: Install Codex in Grok Bot's cloud computer for development through chat. The author treats it as a Linux machine where the bot can run commands, install software, and read and write. Install OpenAI's Codex CLI, describe requirements in chat, let the bot invoke it, and get artifacts back. The author identifies three real hurdles beyond prompting. The machine lacks a usable browser window for normal login. The bot does not know where Codex is or how to call it. Files remain on the machine unless delivery is explicit. From scratch took about 15 minutes, with only changing one login switch and entering one verification code by hand. The bot handled installation, login, tests, and calls, per the author.
- By hand: Get a key, note model IDs, and inject environment variables. In API Keys at https://taotoken.net/api create a key with a purpose-specific name such as grokbot-codex. It is fully shown only once. Copy to a password manager and keep it out of public chat logs and screenshots. Note one coding and one image model ID from the console's model page. Use https://taotoken.net/api for Base URL without extra suffix or doubled /v1/v1. Run these on the cloud shell with your details.
Meaning: Set OPENAI_BASE_URL to TaoToken's API URL, OPENAI_API_KEY to your key, and CODEX_MODEL to your coding model ID.
export OPENAI_BASE_URL="https://taotoken.net/api" export OPENAI_API_KEY="sk-你的Key" export CODEX_MODEL="你的编码模型ID"
To persist, put these lines in ~/.bashrc or ~/.profile and source the file. export affects only the current shell and the bot may execute in another. Persistence across reboots depends on the image. Confirm outbound access with curl -I https://taotoken.net/api and check the status. Later config cannot work if this fails. Completion is echo $OPENAI_BASE_URL showing the correct URL and echo $OPENAI_API_KEY showing only the first characters, without printing it in full.
- Bot: Install Codex CLI and write configuration. Ask the bot to run this on the cloud machine or do it in its terminal.
npm install -g @openai/codex codex --version
Check the version prints, then write ~/.codex/config.toml at that exact path or the CLI silently ignores it.
Meaning: Set the coding model ID and use the TaoToken provider at the given base URL, with the key from OPENAI_API_KEY and chat as the wire protocol.
model = "你的编码模型ID" model_provider = "taotoken"
[model_providers.taotoken] name = "TaoToken" base_url = "https://taotoken.net/api" env_key = "OPENAI_API_KEY" wire_api = "chat"
env_key makes Codex read OPENAI_API_KEY without a plaintext config key. Set wire_api to the protocol the CLI supports. Newer versions support responses, which you can use and verify with one request. The author gives an equivalent JSON snippet for tools that read ~/.codex/settings.json.
Meaning: Set the coding model ID, TaoToken provider, its base URL, and the API key environment variable in JSON.
{ "model": "你的编码模型ID", "modelProvider": "taotoken", "providers": { "taotoken": { "baseUrl": "https://taotoken.net/api", "envKey": "OPENAI_API_KEY" } } }
Check the three match: Base URL https://taotoken.net/api, key from OPENAI_API_KEY, and the model ID as listed. A mismatch shows as 401 or model not found.
- Bot: Remember the standard calling procedure. Send the dedicated bot the author's Chinese template. The author says the whole process was run this way.
Meaning: Save the procedure for calling Codex to code and the image model to generate images. When asked to use Codex, follow it, send results and files, and report the cloud computer path.
请把你调用 Codex 写代码、以及调用图片模型生成图片的方法整理成固定流程记下来。以后我说"用 Codex",你就按这个流程执行,完成后把结果和生成的文件发给我,并说明文件在云电脑里的路径。
Completion is the bot confirming it saved it. The author says later chats reuse endpoint and model IDs without repeating parameters.
- Bot: Test connectivity and run a coding task. Start with a minimal authentication test.
Meaning: Ask Codex to introduce itself in one sentence.
codex exec "用一句话介绍你自己"
A valid reply confirms Base URL, key, and model ID. For errors see step 6. In the coding task, state both what to do and how to deliver it. The author's example follows.
Meaning: Make an accounting page for daily income and expenses with monthly summaries. Send the HTML file and explain how to preview on the cloud computer.
用 Codex 帮我做一个记账网页,能记录每天的收入和支出、按月统计。做好后把 HTML 文件发给我,并告诉我怎么在云电脑里打开预览。
Expected output is one HTML file with monthly income, expenses, and balance, one transaction list, and a monthly spending bar chart. The author found asking to send the file better than just asking to complete it. If it says done without a file, ask for file contents or a download path.
- Bot: Generate an image. Use a different model ID and specify subject and style. The author's template follows.
Meaning: Call the image model through Codex for a tech-style developer avatar with a dark background and simple lines.
用 Codex 调用图片模型,生成一张科技感风格的开发者头像,深色背景,简洁线条。
Expect an image file. Text description usually means a text-only model ID. Check step 1. Both tasks succeeding shows code and images work end to end.
- By hand: Diagnose by the exact error. Paste errors back verbatim or use the author's list of five types encountered and collected. 401 Unauthorized is most common. The author attributes nine in ten to inactive environment variables, absent or misspelled keys. Use echo $OPENAI_API_KEY to confirm nonempty and check env_key spelling. local proxy failed can be outbound restriction or wrong Base URL. Use curl -I and check for excess /v1 suffix, which many compatibility services reject. A reading choices null pointer means an unexpected response structure. Check model ID and wire_api against CLI version. model not found means the ID differs from the console. Copy the exact case. Device-code OAuth failure can mean interactive login without a browser window. Use the API key or authorize from an external browser using device flow. After each change rerun the minimal step-4 test so you can tell what fixed it.
Check: The author used environment echo, codex --version, a minimal reply, and receipt of an accounting HTML page and an avatar image. During verification, retain the response structure, including empty choices and raw error, as the basis for troubleshooting. These are the author's claims without screenshots, files, or raw responses in the source.
Key points and results
- Three setup hurdles matter more than prompt wording. No cloud-browser window for normal sign-in, no default knowledge of Codex location or invocation, and no visible output unless delivery is specified. This is the author's claim; the source gives no comparison figures.
- About 15 minutes with only two manual actions. The author changed a sign-in switch and filled a verification code. Installation, login, tests, and calls were bot-run in the cloud (author's claim, not reproduced).
- Request the file explicitly. Ask for the HTML and preview instructions. Otherwise the author found the bot might only say done.
- 401 is the most common issue and the author attributes nine in ten to environment variables. export is shell-local and bot execution may use another session, so add it to ~/.bashrc. For local proxy failed, check Base URL for appended paths before blaming the network.
- Use distinct text and image model IDs. Text instead of images or choices errors suggest the wrong ID or mismatched wire_api and CLI.
- Keep keys in environment variables and out of plaintext. The key shows fully only once. Keep it out of public chats and screenshots. If other bots share the image, limit access to the current user.
- The author's habits for ongoing use: A dedicated Codex bot keeps coding and image context separate and files easy to find. Ask for absolute paths for scp or dashboard downloads. Store config.toml and both verification prompts in a checklist to avoid overlooking env_key during reinstalls or cloud moves.
- The author's choice of service entry point: Check API Keys then the integration docs for troubleshooting. Use the model chat page for a fast reply check. Coding Plan covers recurring cloud coding and agent work without arranging allowance each time.
- Results and figures are the author's claims, not reproduced. The source gives no screenshots, file contents, or raw responses for 15 minutes, nine in ten, or the artifacts.
Source
- Platform
- Blog
- Author
- EmeraldWolf23
- Published
- Categories
- Code and repos, Getting started
What this evidence label means
Source read in full
We read the source (post, article or transcript). That only means the original was read. It does not mean this site reproduced the author's results.