# Codex in Linear: Key and Network Setup for Scraper Fixes

> Codex in Linear drops secrets before the agent phase and starts offline. Config examples from the official docs, plus real API runs at $0.001904 each.

- Canonical page: [https://everyinfra.com/en/blog/codex-linear](https://everyinfra.com/en/blog/codex-linear?utm_medium=ai_doc&utm_campaign=page_md)
- Published: 2026-11-20T02:32:14+08:00 · Fact-checked: 2026-11-20T02:00:00+08:00

In Codex in Linear, you assign an issue to Codex or mention `@Codex`. Codex then runs a cloud task and posts the result to the issue ([OpenAI: Use Codex in Linear](https://learn.chatgpt.com/docs/third-party/linear)). The task runs in a Codex Cloud (Legacy) environment. There, secrets exist only for the setup script, and the agent phase is offline by default ([OpenAI: Codex Cloud (Legacy)](https://learn.chatgpt.com/codex/environments/cloud-environment)).

We did not delegate a real issue to Codex. The Codex and Linear steps below come from the official docs, and the issue, `AGENTS.md` and environment settings are configuration examples. We tested only the EveryInfra API side.

On our own machine, we rewrote a daily TikTok, YouTube and Reddit scraper as three `POST /api/v1/social` calls. We ran it three times on November 20, 2026, between 00:19 and 00:59 Singapore time. Each run cost exactly $0.001904. Five requests with wrong parameters all returned 422 at no charge, and each 422 named only one error.

> **Key takeaways**
>
> - The Codex and Linear setup, key rules and network rules come from OpenAI and Linear docs read on November 20, 2026. The issue template, `AGENTS.md` and `config.toml` are configuration examples. We did not run them in Codex.
> - Our real tests cover only the API side: three runs of one script on our machine, five bad requests, and one free `/account` call.
> - Codex in Linear needs a paid ChatGPT plan: Plus, Pro, Business, Enterprise or Edu, per Linear's integration page.
> - Tasks run in Codex Cloud (Legacy). Environment variables stay for the full task. Secrets are removed before the agent phase.
> - The agent phase is offline by default. A "GET, HEAD, OPTIONS only" rule blocks `POST /api/v1/social`.
> - Linear's MCP server works only for local Codex (CLI and IDE). Cloud tasks edit code that calls a REST API.
> - Our rewritten script makes 3 calls per run at $0.001904. 500 calls a day cost about $9.05 for 30 days.
> - Five bad requests returned 422 in 0.11 to 0.31 seconds, with no charge. One body with two errors needed two rounds.

![Illustration of two glass rooms side by side. The left room is a setup room with toolboxes, a crate and a glowing key on a hook. Its wide door connects to a network of distant nodes. The right room is a work room with a laptop showing code and a card with a check mark on the wall. Its key hook is empty. Its door is almost closed, with one narrow slot where a teal line reaches one distant teal cube.](https://everyinfra.com/articles/codex-linear/img-explain.webp?utm_medium=ai_doc&utm_campaign=page_md)

The two phases of Codex Cloud (Legacy). Setup has internet and secrets. The agent phase has no secrets and only the network paths you allow.

## What Codex in Linear does, per the November 18 docs

OpenAI moved the Codex in Linear guide to its new docs site around November 18, 2026. The page is short. You assign an issue to Codex, or you mention `@Codex` in a comment. Codex creates a cloud chat and posts progress to the issue's Activity feed. When it finishes, it posts a summary and a link. You open the link to review the diff and create a pull request ([OpenAI: Use Codex in Linear](https://learn.chatgpt.com/docs/third-party/linear)).

Linear's own integration page says the same thing and lists the plans: ChatGPT Plus, Pro, Business, Enterprise and Edu ([Linear: Codex Integration](https://linear.app/integrations/codex)). On Enterprise, a workspace admin must first turn on Codex cloud tasks in workspace settings. The admin must also enable the "Codex for Linear" connector in connector settings.

Setup has three steps. First, connect GitHub in Codex and create a cloud environment for the repository. Second, open the connectors page in Codex settings and install Codex for Linear for your workspace. Third, mention `@Codex` once in any issue comment and link your Linear account when Codex asks.

Linear's agent docs add two points. At install time, you choose which teams the agent can access. Agents also do not count as billable seats in Linear ([Linear Docs: Agent platform](https://linear.app/docs/agents-in-linear)).

| Item | What the docs say | Source (read November 20, 2026) |
| --- | --- | --- |
| Plans | ChatGPT Plus, Pro, Business, Enterprise, Edu | Linear integration page |
| Trigger | Assign the issue to Codex, or mention @Codex; reply in the thread to continue | OpenAI docs |
| Repo choice | Codex picks the best-matching environment; else the most recent one | OpenAI docs |
| Pin a repo | Write `@Codex fix this in org/repo` | OpenAI docs |
| Branch | Default branch of the first repo in the environment | OpenAI docs |
| Auto-delegation | Triage rule: Delegate → Codex; runs as the issue creator | OpenAI docs, Linear Triage docs |
| Triage rules plan | Linear Business and Enterprise | Linear Triage docs |
| Local use | Codex CLI, IDE extension or ChatGPT desktop with Linear's MCP server | OpenAI docs, Linear Codex MCP page |

A Linear Triage rule can delegate matching new issues to Codex. This includes an issue that an alert or a teammate opens for a broken data job ([Linear Docs: Triage](https://linear.app/docs/triage)). OpenAI's guide says that with triage rules, Codex runs chats as the issue creator.

So the person or account that opens the issue must have a linked Codex account. Linear's assignment docs give the same rule. For basic triage rules, the agent session uses the identity of the auto-assigned teammate ([Linear Docs: Assign and delegate issues](https://linear.app/docs/assigning-issues)). An alert bot that opens issues cannot start a Codex session by itself.

## Two kinds of Codex Linear integration

A search for "codex linear integration" returns two products. Both use the name Codex. Billing and key rules are different.

The first product is the one above: OpenAI's Codex for Linear. Tasks run in OpenAI's Codex Cloud (Legacy) and use your ChatGPT plan allowance. The second product is Linear's own cloud coding agent, which Linear calls coding sessions. It can run Claude Code or Codex, and the default model is GPT-6 Sol.

It uses AI credits in your Linear workspace ([Linear Docs: Linear cloud coding agent](https://linear.app/docs/linear-cloud-coding-agent)). On November 12, 2026, Linear added "bring your own key" to that agent. Your provider bills model usage, and Linear still bills sandbox runtime in AI credits. Linear says you need an API key, not a ChatGPT or Claude subscription ([Linear changelog, November 12, 2026](https://linear.app/changelog/2026-11-12-bring-your-own-key)).

| Item | OpenAI's Codex for Linear | Linear cloud coding agent (Codex option) |
| --- | --- | --- |
| Where to install | Codex settings → Connectors | Linear settings → AI & agents → Cloud coding agent |
| Who pays | ChatGPT plan allowance (Plus and up) | Linear AI credits; model fees can go to your OpenAI or Anthropic API key |
| Environment setup | Codex cloud environment: setup script, env vars, secrets, internet switch | Linear Code → Environments: runtimes, env vars, prepare script, files |
| Can the agent read the key? | Env vars yes; secrets removed before the agent phase | Plain env vars yes; values marked Secret are hidden from the agent by default, but anyone who can run a session sees them |
| Basis of the config examples below | Yes | Comparison only |

Linear's docs are direct about their environment variables. Names and values are visible to the coding agent, and you should not treat them as agent-hidden secrets. Linear also has a Secret checkbox. By default, the coding agent cannot see a value with that box checked. But anyone who can run a session in that environment can see it. The docs say to treat it like a local `.env` file ([Linear Docs: Configure coding environments](https://linear.app/docs/linear-cloud-coding-agent)).

The docs do not say whether agent-phase tests can use such a Secret, and we did not try it in Linear. On the OpenAI side, secrets exist only in the setup script. Under the OpenAI legacy rules, a live API check by the agent needs the key as an environment variable, which the agent can read. So give that environment its own key with limited access. The key section below covers this.

## Three hard limits in the cloud environment: key, network, MCP

The docs state which environment Codex in Linear uses. Codex Cloud (Legacy) still supports Code Review and the Linear and GitHub integrations. OpenAI also says it plans to deprecate the legacy experience ([OpenAI: Cloud environments](https://learn.chatgpt.com/codex/environments/cloud-environments)). So the three limits below come from the legacy docs.

**Limit 1: the key.** A legacy environment stores values in two ways. Environment variables exist for the full task, including the setup script and the agent phase. Secrets get an extra layer of encryption. Codex decrypts them only for task execution. Only setup scripts can read them, and Codex removes them before the agent phase ([OpenAI: Codex Cloud (Legacy)](https://learn.chatgpt.com/codex/environments/cloud-environment)).

The security page repeats this rule ([OpenAI: Agent approvals & security](https://learn.chatgpt.com/codex/agent-approvals-security)). Also, the setup script and the agent run in different Bash sessions. An `export` in the setup script does not reach the agent. If you store the API key as a secret, any live test in the agent phase fails without a key.

**Limit 2: the network.** In the legacy environment, the agent phase has no internet by default. You can turn it on per environment, with a domain allowlist and a list of allowed HTTP methods. OpenAI suggests a strict option: allow only `GET`, `HEAD` and `OPTIONS`, and block `POST` and all other methods ([OpenAI: Agent internet access](https://learn.chatgpt.com/codex/cloud/internet-access)). The EveryInfra data API is `POST /api/v1/social`.

With that strict option, Codex can read the free catalog with a GET, but it cannot send a real request. You have two choices. Allow `api.everyinfra.com` and `POST`, or keep the agent offline and run only offline tests.

The same OpenAI page shows a prompt-injection example. An issue body hides an instruction to send repository data to an outside URL. If the agent follows it, data leaks. In Codex in Linear, the issue body is the main input for the agent. So keep the allowlist to the domains the task needs.

**Limit 3: MCP.** The Linear MCP server works only for local Codex tasks in the CLI or IDE ([Linear: Codex MCP Integration](https://linear.app/integrations/codex-mcp)). OpenAI's MCP docs place all MCP settings in a local `~/.codex/config.toml` file. The desktop app, CLI and IDE extension share that file ([OpenAI: Model Context Protocol](https://learn.chatgpt.com/codex/extend/mcp)). We did not find a setting in the legacy cloud docs that attaches an MCP server to a cloud task.

So for issues in Linear, Codex edits Python code that calls a REST API. You can use the EveryInfra remote MCP server locally with the Codex CLI.

![Matrix chart with four rows and three columns. Columns are setup script, agent phase, and whether the agent can read the value. Codex legacy environment variable: yes, yes, yes. Codex legacy secret: yes, removed, no. Linear coding agent environment variable: yes, yes, yes. Codex legacy agent internet: on during setup, off by default in the agent phase, allowed per domain and method.](https://everyinfra.com/articles/codex-linear/fig-02-key-visibility.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

## From issue to pull request: seven steps in the cloud

The docs spread the flow over several pages. In time order, Codex in Linear handles one issue in seven steps.

| Step | Phase | Internet | Secrets | Env vars |
| --- | --- | --- | --- | --- |
| 1. @Codex or delegate | Linear | — | — | — |
| 2. Pick environment | Codex | — | — | — |
| 3. Container and checkout | Codex | — | — | — |
| 4. Setup script | Setup | On | Readable | Readable |
| 5. Edit and test | Agent | Off by default | Removed | Readable |
| 6. Summary to the issue | Codex → Linear | — | — | — |
| 7. Review and PR | You | — | — | — |

In step 1, you mention `@Codex` or delegate the issue. Linear sends the issue content to Codex. OpenAI's guide says Codex receives your issue content, and its privacy policy covers that data. In step 2, Codex picks an environment from Linear's repo suggestion. If the request is not clear, it uses your most recent environment. If no environment fits, Codex replies in the issue with fix steps, and you retry after the fix.

In step 3, Codex creates a container and checks out the repo. The legacy docs name the default image `universal`, which has common languages and tools. You can pin the Python version in the environment settings ([openai/codex-universal](https://github.com/openai/codex-universal)). In step 4, the setup script runs with internet and with secrets.

This is where `pip` installs `requests` and other packages. Codex caches the container state for up to 12 hours. A change to the setup script, environment variables or secrets clears the cache.

In step 5, the agent phase starts. Secrets are gone, and the network follows your settings. Codex reads `AGENTS.md`, edits code and runs checks in a loop. In step 6, Codex shows its answer and diff, and it posts a summary and link to the Linear issue. In step 7, you open the link, review the diff and open a pull request. Your normal review rules apply to the merge.

![Flow chart with seven boxes. 1 mention @Codex or delegate the issue. 2 pick environment and repo from the issue. 3 create container and check out the default branch. 4 setup script with internet and readable secrets. 5 agent phase with secrets removed and no internet by default, reading AGENTS.md and running tests. 6 summary and link posted to the issue. 7 you review the diff and open a pull request. Boxes 4 and 5 have teal borders to show where the key and network rules change.](https://everyinfra.com/articles/codex-linear/fig-01-ticket-to-pr-flow.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

## A hypothetical case: social_pulse.py

The issue example below uses a hypothetical case: a daily script on a growth team. Every morning it pulls three things. First, views, likes, comments and saves for a list of TikTok videos. Second, the newest comments on a YouTube launch video. Third, new Reddit posts that match a keyword.

The old version parsed web pages. The TikTok part read a JSON blob in the page HTML. The YouTube part used an open-source downloader. The Reddit part read the old Reddit web pages.

Assume that one day the TikTok part starts to return 0 rows, and an alert opens an issue in Linear Triage. This failure is an assumption for the example. We did not run the old script, and we did not check whether the TikTok page changed.

The official platform APIs each have a barrier. Reddit requires registered OAuth tokens and heavily limits default user agents ([Reddit Help: Reddit Data API Wiki](https://support.reddithelp.com/hc/en-us/articles/16160319875092-Reddit-Data-API-Wiki)). The YouTube Data API gives each project 10,000 quota units a day by default. Also, `search.list` has its own limit of 100 calls a day ([YouTube Data API: Quota Calculator](https://developers.google.com/youtube/v3/determine_quota_cost)). The TikTok Research API is for approved researchers, and review usually takes about 4 weeks ([TikTok for Developers: Research Tools](https://developers.tiktok.com/products/research-api/)). In the hypothetical case, the team uses these limits to choose a ready API over another round of parser fixes.

The old code looked like this. This is a sketch, and we did not run it:

```text
# Old version: parses web pages and breaks when the page changes
import re, json, requests
from bs4 import BeautifulSoup

def tiktok_stats(url):
    html = requests.get(url, headers={"User-Agent": "Mozilla/5.0"}, timeout=30).text
    blob = BeautifulSoup(html, "html.parser").find("script", id="__UNIVERSAL_DATA_FOR_REHYDRATION__")
    data = json.loads(blob.string)            # assumed case: blob is None when the JSON is missing; the error is swallowed, 0 rows
    item = data["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]
    return {"views": item["stats"]["playCount"], "likes": item["stats"]["diggCount"]}
```

The new version replaces all three parsers with one `call(platform, action, params)` function. There are three capabilities. [`tiktok/video`](/tiktok-api/video) gives one video's stats. [`youtube/comments`](/youtube-api/comments) gives comments on a video.

[`reddit/search`](/reddit-api/search) gives posts that match a keyword. The free catalog lists each capability name, its required and optional parameters, and its price. Codex can read the catalog before it writes code. Platform overviews are on the [TikTok API](/tiktok-api), [YouTube API](/youtube-api) and [Reddit API](/reddit-api) pages.

## How to write the issue: a config example, not run in Linear

Codex reads the issue title, the description and the comment that mentions it. OpenAI's troubleshooting section covers the case where Codex works on the wrong part of the code. The fix is more context in the issue, or explicit instructions in the `@Codex` comment ([OpenAI: Use Codex in Linear](https://learn.chatgpt.com/docs/third-party/linear)). So write the issue as a set of instructions that a person can follow.

Name the file, the change, the acceptance checks and the limits. The template below is a configuration example based on the docs. We did not delegate it to Codex. Which environment Codex picks, how many rounds it needs and what the diff looks like depend on your own issue:

```text
Title: social_pulse.py TikTok step returns 0 rows; switch to EveryInfra API

Symptom: jobs/social_pulse.py runs daily at 07:00. tiktok_stats() returns 0 rows.
The YouTube and Reddit steps sometimes time out.
Do:
1. Delete the three page parsers (tiktok_stats, yt_comments, reddit_posts).
   Call POST https://api.everyinfra.com/api/v1/social with {"platform","action","params"}.
2. Capabilities: tiktok/video (url), youtube/comments (url, sort, limit), reddit/search (keyword, sort, limit).
   Take parameter names from GET https://api.everyinfra.com/api/v1/social/catalog?platform=tiktok (and youtube, reddit).
   Do not guess parameter names.
3. Read the key only from the EVERYINFRA_API_KEY environment variable. Never put it in code, tests or logs.
4. Handle 202 running (poll poll_url), 429 (wait retry_after), 503 (back off and retry).
   Do not retry 422. Raise it with error.param, error.allowed and error.did_you_mean.
Acceptance:
- tests/test_social_pulse.py passes offline with the three real responses in tests/fixtures/.
- The output JSON has rows and charged_usd for each capability.
Do not: rename output fields; add new dependencies (requests is already installed).
```

Then add a comment: `@Codex follow the issue, repo acme/growth-jobs`. Name the repo, because Codex guesses the environment from the issue text. If the guess is unclear, it falls back to the most recent environment. The docs show this exact pattern ([OpenAI: Use Codex in Linear](https://learn.chatgpt.com/docs/third-party/linear)).

The "do not guess parameter names" line matches an API-side test. We sent `query` instead of `keyword` on purpose. The API returned 422 at once. It said that `query` is not a parameter for this capability and that it needs `keyword`.

Also add an `AGENTS.md` file at the repo root. Codex reads it before it starts. OpenAI says Codex uses this file to find the project's test and lint commands ([OpenAI: Custom instructions with AGENTS.md](https://learn.chatgpt.com/codex/agent-configuration/agents-md)). The data API lines can look like this. This is also an example that we did not run in Codex:

```text
## Data API
- Before you call EveryInfra, read required_params, optional_params and allowed_values from
  /api/v1/social/catalog?platform=<platform>.
- On 422, change only the parameter named in error.param, using error.allowed or error.did_you_mean.
  Then send again. Each 422 reports one error.
- Tests run offline by default with tests/fixtures/*.json. Live calls only when EVERYINFRA_LIVE=1,
  with a maximum of 3 requests per run.
- Never print EVERYINFRA_API_KEY. Never write it to any file.
```

## Where to keep the key: env var, secret or offline tests

Under the legacy rules, you have three options, and each has a cost.

Option A is a secret. Only the setup script can read it, and the agent phase cannot. A live test that Codex runs after it writes the code fails. This option fits a case where setup needs the key, for example to install a private package, and the agent never needs it.

Option B is an environment variable. The agent phase can read it, so Codex can verify its change with a live call. The cost is that the key is visible to the agent and can appear in task logs.

Option C is no key. All tests run offline with recorded real responses. Codex changes only code, and live calls run in your own scheduler after the merge.

| Option | Agent can read the key | Live test in the task | Main risk | Use it when |
| --- | --- | --- | --- | --- |
| A. Secret | No | Fails with 401 | None for the agent | Setup needs the key, the agent does not |
| B. Environment variable | Yes | Works | Key visible to the agent and in logs | You need one live check in the task |
| C. No key | No key exists | Offline only | Fixtures get old | Code changes only (our default) |

We recommend option C first and option B only when you need it. For a scraper fix, the acceptance test is "does the code handle the real response shape". Three recorded responses, such as the ones we saved on November 20, 2026, cover fields, empty results and 422 errors. If you do need a live call inside the task, create a separate key for that environment only.

EveryInfra's docs list several ways to limit a key ([EveryInfra quickstart](/docs#quickstart)). In the console, under "API Keys → permission limits", you can keep only the data API product. A disabled product returns 403. You can disable one key without affecting others. You can set an IP allowlist. With the same key, `GET /api/v1/account` shows the balance and the per-minute limit at no charge.

OpenAI publishes the egress IP ranges for its cloud agents ([OpenAI: chatgpt-agents.json](https://openai.com/chatgpt-agents.json)). The file we read was generated on November 13, 2026. OpenAI also says these ranges are shared across customers, so you must keep authentication in place ([OpenAI: Cloud environments](https://learn.chatgpt.com/codex/environments/cloud-environments)). An IP allowlist is a second gate, not the first.

We tested the auth order once. At 00:19 Singapore time, we sent an incomplete request with no key. The API returned 401 `missing_key` first, with no parameter error. So an unauthenticated caller cannot probe the parameter shape.

With a key, the parameter checks run. This also helps Codex. In an environment without a key, a live test returns 401. It does not return a 422 that makes Codex think the parameters are wrong.

For local debugging with the Codex CLI, you can add the EveryInfra remote MCP server. Codex can then read the catalog and try calls directly. Our MCP page gives this command: `codex mcp add everyinfra --url https://api.everyinfra.com/mcp --bearer-token-env-var EVERYINFRA_API_KEY` ([EveryInfra remote MCP](/mcp-server)). The `config.toml` version is below. One public issue in the Codex repo is relevant.

Sometimes the variable in `bearer_token_env_var` is missing from the running process. Then `codex mcp list` still shows Bearer auth, but requests have no header ([openai/codex issue #30125](https://github.com/openai/codex/issues/30125)). After you change your shell environment, restart Codex. Then check the variable with `printenv`.

```text
# ~/.codex/config.toml (local CLI and IDE only; Linear cloud tasks do not read this file)
[mcp_servers.everyinfra]
url = "https://api.everyinfra.com/mcp"
bearer_token_env_var = "EVERYINFRA_API_KEY"

[mcp_servers.linear]
url = "https://mcp.linear.app/mcp"
```

There is a simpler split of work. First, set up the EveryInfra MCP server in your local Codex CLI. Let local Codex read the catalog and make one real call for each capability. Save the responses in `tests/fixtures/` and commit them. Then delegate "replace the old parsers" to cloud Codex in Linear.

In that cloud task, Codex only edits code and runs offline tests. It needs no key and no internet. The real calls happen on your own machine, where you can see each request and each charge. If an issue body contains a strange instruction, the cloud task has no key to leak.

We did only the first half. All three runs happened on our machine, and we saved the responses as fixtures. We did not run the second half, the cloud task in Linear.

## Check the key first with the free /account call

You can check at no cost that the key exists, which key it is and how much balance it has. At 00:39 Singapore time on November 20, 2026, we called `GET /api/v1/account` with the key that ran the script. It returned 200 in 0.22 seconds, with no charge.

The response had the balance in two parts, paid and bonus. It had the account limit of 60 requests a minute and the key limit of 10 requests a minute. It also had the key name, the expiry date, and the calls, failures and spend of this key for the last 24 hours. The key itself came back only as a masked prefix.

Put this call in `AGENTS.md` as a start check. Before any real call, Codex calls `/account` once. A 401 means the environment variable is missing. Usually the key was saved as a secret. In that case, Codex must stop and reply in the issue, and it must not start to guess parameters.

| Field in the /account response | Value at 00:39 | Use in a Codex task |
| --- | --- | --- |
| `balance.total_usd` | Shown, split into paid and bonus | Stop if the balance is too low |
| `rate_limit.requests_per_minute` | 60 (account) | Upper limit for all keys together |
| `rate_limit.key_requests_per_minute` | 10 (this key) | Limit for live calls and retries |
| `key.prefix` | Masked | Confirms which key is loaded, without the full value |
| `usage_24h.this_key.spent_usd` | Shown | Call before and after a task to get its cost |

A 200 response shows `key_requests_per_minute`. Our key allows 10 requests a minute. Three real calls are fine. But an agent that retries in a loop can get 429 quickly. The `AGENTS.md` line "a maximum of 3 requests per run" follows this limit.

`usage_24h.this_key.spent_usd` is the spend of this key in the last 24 hours. Codex can call `/account` before and after the task, and the difference is the real-call cost of the task. With a separate key for Codex, the difference contains only its calls.

## The Python code after the change

This is the full script after the change. It is the exact file we ran three times. It uses `requests` ([Requests: Quickstart](https://requests.readthedocs.io/en/latest/user/quickstart/)). The script does four things.

It reads the key from an environment variable. It sends one request per capability. It handles each status code. It writes rows, charges and seconds per capability to an output file.

```text
"""social_pulse.py: daily pull of TikTok video stats, YouTube comments and Reddit posts."""
import json, os, sys, time
import requests

API = "https://api.everyinfra.com/api/v1/social"
KEY = os.environ["EVERYINFRA_API_KEY"]
HEAD = {"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"}

class ParamError(Exception):
    """422: the request is wrong; resending the same body will not help."""

def call(platform, action, params, tries=4):
    body = {"platform": platform, "action": action, "params": params}
    for attempt in range(tries):
        r = requests.post(API, headers=HEAD, json=body, timeout=120)
        if r.status_code == 422:
            err = r.json()["error"]
            raise ParamError(json.dumps({k: err.get(k) for k in
                ("code", "param", "message", "allowed", "did_you_mean", "example")}))
        if r.status_code == 429:
            time.sleep(r.json()["error"].get("retry_after", 20) + 1); continue
        if r.status_code == 503:
            time.sleep(5 * (attempt + 1)); continue
        r.raise_for_status()
        data = r.json()
        if data.get("status") == "running":      # slow capability: poll
            data = poll(data["poll_url"])
        return data
    raise RuntimeError(f"{platform}/{action}: no result after {tries} tries")

def poll(url, every=5, limit=60):
    full = url if url.startswith("http") else "https://api.everyinfra.com" + url
    for _ in range(limit):
        data = requests.get(full, headers=HEAD, timeout=60).json()
        if data.get("status") != "running":
            return data
        time.sleep(every)
    raise RuntimeError("job still running")

def main(out_path):
    jobs = [
        ("tiktok", "video", {"url": "https://www.tiktok.com/@openai/video/7647247430546672909"}),
        ("youtube", "comments", {"url": "https://www.youtube.com/watch?v=JlhQD6GHT3g", "sort": "newest", "limit": 50}),
        ("reddit", "search", {"keyword": "codex cloud", "sort": "newest", "limit": 25}),
    ]
    spent, rows = 0.0, []
    for platform, action, params in jobs:
        t0 = time.time()
        data = call(platform, action, params)
        res = data.get("results")
        n = len(res) if isinstance(res, list) else (1 if res else 0)
        usd = (data.get("billing") or {}).get("charged_usd", 0.0)
        spent += usd
        rows.append({"capability": f"{platform}/{action}", "rows": n, "charged_usd": usd,
                     "seconds": round(time.time() - t0, 2), "results": res})
    with open(out_path, "w") as f:
        json.dump({"spent_usd": round(spent, 6), "jobs": rows}, f, ensure_ascii=False, indent=1)

if __name__ == "__main__":
    main(sys.argv[1])
```

Each part of the code matches an API behavior. `tiktok/video` returns one object in `results`. `youtube/comments` and `reddit/search` return lists. So the code counts rows in two ways. The catalog field `returns_list` tells you which capabilities return lists ([EveryInfra catalog](https://api.everyinfra.com/api/v1/social/catalog)).

Slow capabilities first return `status: running` and a `poll_url`. Poll that URL. Do not resend the same body within 5 minutes, because the API treats it as a replay. A 429 response includes `retry_after` in seconds, so wait that long.

A 503 means the data is not available now. Failed calls are not charged, so back off and retry. A 422 raises its own exception, because the same body always fails again. That kind of error needs a code change.

The fields match the catalog's `response_fields`. For `tiktok/video` we use `view_count`, `like_count`, `comment_count`, `share_count`, `collect_count`, `posted_at` and `author_follower_count`. For `youtube/comments` we use `text`, `like_count`, `reply_count`, `posted_at` and `is_reply`. For `reddit/search` we use `title`, `community`, `like_count`, `comment_count` and `posted_at`. The old output used column names such as `views` and `likes`. The issue says "do not rename output fields", so Codex writes this mapping inside the script, and downstream jobs do not change.

## Offline tests with real responses as fixtures

The acceptance rule in the issue says the tests pass offline with three real responses. The test below is the kind Codex should return. The fixtures are raw API responses. So the test checks how the code handles the real shape: `tiktok/video` returns an object, and the other two return lists.

`charged_usd` sits inside `billing`. A 422 raises an exception that carries `param`.

```text
# tests/test_social_pulse.py (offline: replace requests.post with unittest.mock)
import json, pathlib
from unittest import mock
import pytest, social_pulse as sp

FIX = pathlib.Path(__file__).parent / "fixtures"

def fake_post(status, name):
    r = mock.Mock(status_code=status)
    r.json.return_value = json.loads((FIX / name).read_text())
    r.raise_for_status = mock.Mock()
    return r

def test_tiktok_video_is_one_object():
    with mock.patch.object(sp.requests, "post", return_value=fake_post(200, "tiktok_video.json")):
        data = sp.call("tiktok", "video", {"url": "https://www.tiktok.com/@openai/video/7647247430546672909"})
    assert isinstance(data["results"], dict)
    assert data["billing"]["charged_usd"] == 0.000556

def test_422_is_not_retried():
    with mock.patch.object(sp.requests, "post", return_value=fake_post(422, "youtube_comments_422.json")) as p:
        with pytest.raises(sp.ParamError) as e:
            sp.call("youtube", "comments", {"url": "x", "sort": "top", "limit": 50})
    assert p.call_count == 1
    assert json.loads(str(e.value))["allowed"] == ["newest", "popular"]
```

The second test protects a rule that an agent can easily break: do not retry a 422. When an agent sees a failure, it often adds a retry. This test fails if the agent puts 422 into the retry branch. The fixture files are copies of the responses we saved on November 20, 2026, with usernames removed.

There is one more benefit. When a platform changes its fields later, you replace the fixtures and see which tests fail. That tells you what the next Codex issue must fix.

## Real runs: the same script, three times

We ran the script at three times on November 20, 2026: 00:19, 00:38 and 00:59 Singapore time. The key came only from an environment variable. The request bodies were the same in all three runs. The table shows rows, charges and seconds for each capability.

| Capability | Run 1, 00:19 (rows / charge / seconds) | Run 2, 00:38 | Run 3, 00:59 |
| --- | --- | --- | --- |
| `tiktok/video` | 1 / $0.000556 / 8.38 | 1 / $0.000556 / 10.09 | 1 / $0.000556 / 9.75 |
| `youtube/comments` | 3 / $0.000556 / 0.99 | 3 / $0.000556 / 1.36 | 3 / $0.000556 / 1.00 |
| `reddit/search` | 5 / $0.000792 / 4.02 | 5 / $0.000792 / 8.88 | 5 / $0.000792 / 9.17 |
| Total | 9 / $0.001904 / 13.39 | 9 / $0.001904 / 20.33 | 9 / $0.001904 / 19.92 |

![Grouped horizontal bar chart of seconds per call in three real runs. tiktok/video: 8.38, 10.09, 9.75. youtube/comments: 0.99, 1.36, 1.00. reddit/search: 4.02, 8.88, 9.17. The highlighted bottom bar is the average time of the five 422 responses, about 0.20 seconds.](https://everyinfra.com/articles/codex-linear/fig-03-latency-bar.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

The charges matched to the last digit. Every run cost $0.000556 + $0.000556 + $0.000792 = $0.001904. That is the sum of the three `price_usd` values in the catalog.

The YouTube video has only 3 comments, and `reddit/search` with newest sort returned 5 posts. The charge was the same as for 50 or 25 rows, because you pay per call, not per row. So the issue does not need to lower `limit` to save money. Set it to the maximum: 100 for `youtube/comments` and 25 for `reddit/search`.

Latency varied more than cost. `tiktok/video` took 8.38, 10.09 and 9.75 seconds in the three runs. `reddit/search` took 4.02, 8.88 and 9.17 seconds. `youtube/comments` stayed between 0.99 and 1.36 seconds.

One run of three calls took 13.4 to 20.3 seconds in total.

In these 40 minutes, the TikTok video stayed at 74,200 views. On Reddit, the results changed. Runs 1 and 2 returned the same 5 posts. Then a new off-topic post appeared in r/IA_Italia at 16:50 UTC on November 19, 2026.

Run 3 included the new post. It dropped the oldest one, the lamp post from November 18, 2026, at 22:55 UTC. The result again had 5 rows. The lamp post was still inside the one-month window, and `limit` was 25.

So for this keyword, newest sort returned 5 posts each time, fewer than `limit`. Write the real row count to your output, and do not read "fewer than `limit`" as "no more posts". In tests, assert "rows ≥ 0", not 5.

![Screenshot of a real response. A dark terminal shows the output file of the first social_pulse.py run. tiktok/video has one row with view_count 74200, like_count 5047, comment_count 158 and charged_usd 0.000556. youtube/comments has three rows and charged_usd 0.000556. reddit/search has five rows and charged_usd 0.000792. The last line, spent_usd 0.001904, has a teal box.](https://everyinfra.com/articles/codex-linear/img-run-output.webp?utm_medium=ai_doc&utm_campaign=page_md)

Output of the first social_pulse.py run, November 20, 2026, 00:19 Singapore time. Three capabilities cost $0.001904 in total. [EveryInfra API real response screenshot](https://api.everyinfra.com/api/v1/social/catalog)

`youtube/comments` returns `posted_at` as relative text, for example "11 months ago". The Linear video was published on December 4, 2025, and most comments came soon after. If your report filters by date, use the catalog's `since` parameter. Convert relative times in your script.

The catalog says `reddit/search` covers only the last month. At 00:18 we searched "codex linear" and got only 2 posts. Neither was about Codex.

One was a task board tool, posted on October 20, 2026 in a subreddit for open-source projects. That date is at the edge of the one-month window. The other was a photo post from October 23, 2026. For older threads, use a capability that reads a subreddit, or state the time window in the issue.

## Split ads from organic posts: 99% of "openai codex" views were ads

After the script works, the next question is whether the numbers can go into the report as they are. At 00:18 we ran [`tiktok/search`](/tiktok-api/search) for "openai codex" and got 10 videos for $0.000556. We wanted to see what a team gets if it tracks "Codex buzz" by keyword.

The 10 videos had 42,335,552 views in total. The 3 videos with `is_ad` set to true had 42,074,200 views, or 99.4%. One of them was from the OpenAI account, and two were from creators with a ChatGPT partner tag. The 7 organic videos had only 261,352 views together. The top video had 31.8 million views, a `#chatgptpartner` tag and 0 comments.

![Horizontal bar chart on a log scale, each step 10x. Ten TikTok videos from a search for "openai codex", sorted by views. March 26 partner-tag ad: 31,800,000. May 19 partner-tag ad: 10,200,000. May 26: 109,800. June 5: 84,500. June 3 OpenAI account ad: 74,200. October 10: 33,500. November 6: 31,100. November 18 partner tag: 1,413. November 18: 813. November 18: 226. The three videos with is_ad true are highlighted and make up 99.4% of views.](https://everyinfra.com/articles/codex-linear/fig-06-tiktok-views-bar.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

A buzz number based on total views is almost all paid reach. One more partner video in a day moves the line by two orders of magnitude. So the issue should tell Codex to keep the `is_ad` and `is_sponsored` columns. Both fields are in the `response_fields` of `tiktok/video` and `tiktok/search`. Then the report counts paid and organic views in two columns.

The two fields mean different things. `is_ad` marks a paid ad. `is_sponsored` marks sponsored content. In these 10 videos, one video had only `is_sponsored`, and one had both. The catalog's `field_note` also says some requests do not return `is_sponsored`. When the key is missing, record "unknown", not false.

| Posted (UTC) | Subreddit | Comments | Topic |
| --- | --- | --- | --- |
| November 19, 15:39 | r/codex | 6 | A Rust app backend built with Codex |
| November 19, 12:47 | r/alphaandbetausers | 0 | Call for app testers |
| November 19, 09:20 | r/singularity | 1 | Image model comparison |
| November 19, 03:30 | r/AtlasCloudAI | 0 | Promotion |
| November 18, 22:55 | r/codex | 31 | A lamp that lights up when Codex needs a reply |

We also looked at the other two capabilities. On Reddit, the 00:19 run searched "codex cloud" with newest sort and returned 5 posts. All were posted between November 18, 22:55 and November 19, 15:39 UTC. Two came from r/codex.

One of those had 31 comments and described a desk lamp that lights up when a long Codex task needs a human ([r/codex post](https://www.reddit.com/r/codex/comments/1xztfrg/i_stopped_babysitting_codex_a_lamp_does_it_now/)). The other post is from November 19, 2026 at 15:39 UTC and has 6 comments. It says GPT-6 Astra in Codex built the full Rust backend of a Mac app. The other 3 posts were a tester call, an image-model comparison and a promotion. On YouTube, Linear's 28-second video has had 3 comments in 11 months.

Keyword reports contain many off-topic or promotional items. Put the filter rules in the acceptance checks of the issue. Do not expect Codex to guess them.

## How Codex fixes its own 422 errors

The most common Codex mistakes are wrong parameter names and wrong enum values. Between 00:14 and 00:19 we sent five bad request bodies on purpose. All five returned 422, and none was charged:

| Time (Singapore) | Capability | Mistake | `error.code` | Fix information in the response | Seconds |
| --- | --- | --- | --- | --- | --- |
| 00:14 | `reddit/search` | Sent `query`, not `keyword` | `missing_param` | `query` is not a parameter; use `keyword`; working `example` | 0.15 |
| 00:14 | `reddit/search` | `sort` set to `hot` | `invalid_value` | 6 `allowed` values; `did_you_mean`: `popular`, `top` | 0.21 |
| 00:19 | `youtube/comments` | `max_results` and `sort: top` (two errors) | `unknown_param` | Reports only `max_results`; `allowed`: url, limit, since, sort | 0.11 |
| 00:19 | `tiktok/video` | Sent `video_url`, not `url` | `missing_param` | `video_url` is not a parameter; use `url`; working `example` | 0.23 |
| 00:19 | `youtube/comments` | Fixed to `limit`, still `sort: top` | `invalid_value` | `allowed`: newest, popular; `did_you_mean`: `popular` | 0.31 |

Two of the five errors used parameter names from other APIs (`query`, `video_url`). Three responses listed allowed values. Two included `did_you_mean` candidates. Three included a working `example` body.

Rows 3 and 5 show something Codex must know: each 422 reports one error. Our body had two errors. The first response said only that `max_results` is not a parameter. After that fix, the next response reported the bad `sort` value.

An agent that fixes errors one round at a time needs one round for each error. In each round, the agent must change only the parameter that the error names, and nothing else. Our `AGENTS.md` above says exactly this. The first `next_steps` line ends with "Nothing was charged." So the agent knows that this failure has no cost.

![Timeline. At 00:19:24, youtube/comments with two errors, max_results and sort top, returns 422 unknown_param and names only max_results. At 00:19:32, the request with limit returns 422 invalid_value and says sort must be newest or popular. At 00:38, the same request with sort newest returns 200 and costs $0.000556. Neither 422 was charged.](https://everyinfra.com/articles/codex-linear/fig-05-fix-rounds-timeline.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

The 422 body looks like this. It is from the second request at 00:19. Codex reads `param` and finds `sort` in the code. It picks a value from `allowed`.

`did_you_mean` has one candidate, `popular`. If the business needs the newest comments, the right value is `newest`. That choice is a business decision. If the issue says "we need the newest comments", Codex does not just take the candidate value.

HTTP defines 422 as a status where the server understands the content type and syntax but cannot process the instructions ([RFC 9110, section 15.5.21](https://www.rfc-editor.org/rfc/rfc9110.html#name-422-unprocessable-content)). That matches this use. The request is valid JSON, and the parameters are wrong.

![Screenshot of a real response. A dark terminal shows a POST /api/v1/social request body for youtube/comments with sort set to top and limit 50. Below it is the HTTP 422 response: code invalid_value, param sort, allowed newest and popular, did_you_mean popular. A next_steps line says to change only sort and resend, with nothing charged. The allowed and did_you_mean lines have a teal box.](https://everyinfra.com/articles/codex-linear/img-422-roundtrip.webp?utm_medium=ai_doc&utm_campaign=page_md)

The 422 response at 00:19 Singapore time on November 20, 2026. It names one parameter and gives the allowed values and a candidate. [EveryInfra API real response screenshot](https://api.everyinfra.com/api/v1/social/catalog)

Now look at the time cost. The 5 responses with 422 took 0.11 to 0.31 seconds, about 0.2 seconds on average. Successful calls in the same period took 1 to 10 seconds. So one fix round costs almost no API time and no money. The slow part is the model, which reads the error, edits the code and runs the tests again.

Two errors in two rounds added only about 0.4 seconds of API time. Now think of code that puts 422 into the retry branch. Four retries get four identical 422 responses. They waste time and use 4 of the 10 requests a minute for the key. That is why the offline test above checks that a 422 causes only one call. We saved the five 422 responses and the 401 response as they came, so you can use them as fixtures.

For more error codes and self-repair patterns, see [how AI agents fix API errors](/build/api-errors-self-healing). For refunds on failed and empty results, see [failure refund reconciliation](/build/failure-refund-reconciliation).

## What 500 calls a day cost

API fees use the catalog `price_usd`. Each call has a fixed price. We assume this use for the hypothetical team. It tracks 300 TikTok videos (300 `tiktok/video` calls), comments on 100 YouTube videos (100 `youtube/comments` calls) and 100 Reddit keywords (100 `reddit/search` calls). That is 500 calls a day.

| Capability | Price (catalog, November 20, 2026) | Per 1,000 calls | Calls a day | Per day | 30 days |
| --- | --- | --- | --- | --- | --- |
| `tiktok/video` | $0.000556 | $0.556 | 300 | $0.1668 | $5.004 |
| `youtube/comments` | $0.000556 | $0.556 | 100 | $0.0556 | $1.668 |
| `reddit/search` | $0.000792 | $0.792 | 100 | $0.0792 | $2.376 |
| Total | — | — | 500 | $0.3016 | $9.048 |

If "500 runs a day" means 500 full runs of the script (3 calls each), the cost is 500 × $0.001904 = $0.952 a day, or $28.56 for 30 days. The most expensive mix is 500 `reddit/search` calls, at $0.396 a day or $11.88 for 30 days. Failed and empty results are not charged, so these are upper limits.

Codex costs are separate. Codex in Linear tasks use your ChatGPT plan allowance. Plus costs $20 a month ([OpenAI Help: What is ChatGPT Plus](https://help.openai.com/en/articles/6950777-what-is-chatgpt-plus)). A Business standard seat costs $25 per user per month billed monthly, or $20 billed annually ([OpenAI Help: ChatGPT Business overview](https://help.openai.com/en/articles/8792828-chatgpt-business-overview)).

| Plan | Price (read November 20, 2026) | What it covers in this setup |
| --- | --- | --- |
| ChatGPT Plus | $20 a month | Codex in Linear cloud tasks for one user |
| ChatGPT Business (standard) | $25 per user a month, or $20 billed annually | Team use of Codex |
| Linear Business | $16 per user a month | Triage rules for auto-delegation |
| EveryInfra data API | Per call, from the catalog | The three capabilities in the script |

OpenAI's pricing page says cloud tasks can use more allowance than local messages. Check the usage dashboard for real numbers ([OpenAI: Pricing](https://learn.chatgpt.com/codex/pricing)). Auto-delegation with Triage rules also needs Linear Business, at $16 per user per month ([Linear Pricing](https://linear.app/pricing)).

## Compared with the hours to maintain your own scraper

We did not find reliable survey data on how many hours scraper upkeep takes. So we use one public number and three stated assumptions. The public number is the 2025 median pay from the US Bureau of Labor Statistics. It is $64.44 an hour for software developers, QA analysts and testers ([BLS: Software Developers](https://www.bls.gov/ooh/computer-and-information-technology/software-developers.htm)).

| Assumed upkeep | Hours a month | Rate | Monthly cost |
| --- | --- | --- | --- |
| 1 hour a month | 1 | $64.44 (BLS median) | $64.44 |
| 1 hour a week | 52 ÷ 12 ≈ 4.33 | $64.44 | $279.24 |
| 1 day (8 hours) a week | ≈ 34.67 | $64.44 | $2,233.92 |

The three hour counts are assumptions for a size comparison. Your scraper can run for six months without a break, or it can break several times a week. Put in your own team's hours for a better number.

![Horizontal bar chart on a log scale, each step 10x, comparing monthly cost. EveryInfra at 500 calls a day (300 tiktok/video, 100 youtube/comments, 100 reddit/search) for 30 days: $9.05. 500 full script runs a day for 30 days: $28.56. One hour of fixes at the BLS median wage: $64.44. Assumed 1 hour of fixes a week: $279.24 a month. Assumed 1 day of fixes a week: $2,233.92 a month. The first bar is highlighted.](https://everyinfra.com/articles/codex-linear/fig-04-monthly-cost-bar.en.light.svg?utm_medium=ai_doc&utm_campaign=page_md)

Put the three cases together. One hour of fixes a month at the BLS median wage costs $64.44. That is about 7 times the $9.05 for 500 calls a day for a month. One hour a week costs $279.24, about 31 times. One day a week costs $2,233.92, about 247 times.

This comparison has three limits. First, the hour counts are assumptions, not survey data. Second, the labor numbers exclude the servers and proxies that a homemade scraper needs, so the real cost of a homemade scraper is higher. Third, the API covers only the platforms and fields in the catalog. For other sites you still need your own scraper. In that case, Codex in Linear helps you fix the scraper itself.

## Steps shown in videos but missing from the docs

Video tutorials and the docs disagree in three places. At 00:14 we ran [`youtube/search`](/youtube-api) for "codex linear". Three of the top 10 results were about Codex in Linear. The first was "OpenAI Codex agent" from Linear's own channel, posted December 4, 2025.

The second was "Introducing coding sessions" from Linear, posted June 11, 2026 (7 minutes 9 seconds). It covers Linear's own coding agent. The third was a walkthrough by an SEO creator, posted December 8, 2025.

| Video | Channel | Posted | Length | Views (00:14 search) | Captions |
| --- | --- | --- | --- | --- | --- |
| OpenAI Codex agent | Linear | December 4, 2025 | 0:28 | 4,727 | None; refunded |
| Introducing coding sessions | Linear | June 11, 2026 | 7:09 | 19,783 | 6,242 characters |
| OpenAI Codex Agent in Linear walkthrough | An SEO creator channel | December 8, 2025 | 8:19 | 8,243 | 9,033 characters |

We fetched captions with [`youtube/transcript`](/youtube-api/transcript). Linear's 28-second video had no captions. The API returned an empty result and refunded the charge automatically. The creator video returned 9,033 characters of captions. The coding sessions video returned 6,242 characters at 00:38 Singapore time, for $0.000556.

It covers Triage automation. Alerts from Datadog and bug reports land in Triage, and Linear's own agent investigates and fixes them. A speaker says that the Linear agent merged almost 700 PRs in the last month. The video does not mention environment variables, secrets or network settings. For those steps, you must read the docs.

First, the creator video gives the local setup command as "codex connect linear". The OpenAI and Linear docs give `codex mcp add linear --url https://mcp.linear.app/mcp`. The other option is a manual `config.toml` edit and then `codex mcp login linear` ([Linear: Codex MCP Integration](https://linear.app/integrations/codex-mcp)). The command from the video does not work.

| Step | What the video says | What the docs say |
| --- | --- | --- |
| Local setup | `codex connect linear` | `codex mcp add linear --url https://mcp.linear.app/mcp` |
| Before @Codex | Connect GitHub, install in Linear | Also create a cloud environment that includes the repo |
| MCP feature flag | Not mentioned | Linear page: `rmcp_client = true`; OpenAI page: no flag |
| Time to PR | About 2 minutes | No time given |

Second, the video shows a pull request two minutes after `@Codex`. It does not mention that you must first create a cloud environment that lists the repo. The docs say that if no environment fits, Codex replies in the issue with fix steps and asks you to retry. The video skips that step.

Third, Linear's Codex MCP page still says that first-time MCP users must add `rmcp_client = true` to `config.toml`. OpenAI's new docs do not have this line. Follow the prompts from your local Codex version.

Linear's video had 3 comments. The top one, with 11 likes, asked if Linear plans the same integration for Claude Code.

Another said the Cursor integration works well and that Claude Code would need good handling of remote agents.

## Keep watch on Codex in Linear: access, audit and handoff

You can track work for Codex in Linear as you track work for a teammate. Linear's agent docs list four places. Each agent has a user page that shows its issues. Delegated issues still appear in your My issues view, because you are still the owner. Custom views can filter by Delegate. Insights can slice by Delegate to show how much work goes to agents ([Linear Docs: Agent platform](https://linear.app/docs/agents-in-linear)).

The assignment docs add that the Activity feed records assignment and delegation history with names and times ([Linear Docs: Assign and delegate issues](https://linear.app/docs/assigning-issues)). For access, agents cannot sign in to the Linear app, cannot use admin features and cannot manage users.

For issues that fix data scripts, add team-level agent guidance. Linear lets you write extra guidance for agents at the workspace and team level. Team guidance takes priority, and agents receive it when they work on issues. The docs also say each agent decides how to apply the guidance ([Linear Docs: Agent platform](https://linear.app/docs/agents-in-linear)).

One useful rule: "For data scripts in jobs/, include offline tests. Never put a key in code, logs or PR text. In the PR text, list the capabilities you changed and their prices." The last sentence lets the reviewer check the cost at review time.

| Check before merge | How | If it fails |
| --- | --- | --- |
| No key in code | Search the diff for `Bearer`, `sk-` and your key prefix | Reject, and disable that key |
| No retry on 422 | Run `test_422_is_not_retried` | Reject |
| Capabilities and params match the catalog | Compare with `/api/v1/social/catalog?platform=…` | Paste the catalog text into the issue and ask Codex to fix |
| Output field names unchanged | Compare columns with the old output | Add the mapping |
| Ad flags kept | Output has `is_ad` and `is_sponsored` | Add the columns |

You can paste this table into the issue as acceptance checks and ask Codex to answer each line in its summary.

Long tasks need someone to watch them. In Linear, that job falls to Inbox notifications and the mobile app. Since November 4, 2026, Diffs reviews work on phones.

So you can review agent changes on a phone before the merge ([Linear changelog: Mobile Diffs](https://linear.app/changelog/2026-11-04-mobile-diffs)).

## Troubleshooting by symptom

This table puts the errors from the docs next to the cases from our real calls. Look up the row by what you see in Linear. The first three rows come from the OpenAI and Linear docs. Rows 4 and 5 follow from the docs, and we did not reproduce them in Codex. The other rows come from our API calls on November 20, 2026.

| What you see | Most likely cause | Fix |
| --- | --- | --- |
| After @Codex, Codex replies with fix steps and does not start | No cloud environment matches the issue, or the environment does not include the repo | Create an environment for the repo; write `in org/repo` in the comment |
| A Triage rule delegates the issue to Codex, but no task starts | The issue creator has no linked Codex account, or Linear is not on Business or Enterprise | Let alerts open issues as a member with Codex linked, or mention @Codex by hand |
| Codex edits the wrong place | The issue has too little context, so Codex picked other files | Write the file path and the function names to delete |
| A real call in the agent phase returns 401 `missing_key` | The key is a secret, or a setup-script `export` did not reach the agent | Use an environment variable, or run only offline tests |
| A real call in the agent phase fails with a network error | Agent internet is off, or only GET is allowed | Allow `api.everyinfra.com` and POST |
| 422 `missing_param` or `unknown_param` | A parameter name came from another API (`query`, `video_url`, `max_results`) | Use `param` and `example` from the response; change only that parameter |
| 422 `invalid_value` | The enum value is not allowed (`sort: hot`, `sort: top`) | Pick from `allowed`; for newest items use `newest`, not the `did_you_mean` value |
| 429 | The per-minute limit of the key is reached | Wait `retry_after` seconds; make fewer real calls in tests |
| Empty result | The keyword is rare, or it is outside the one-month window of `reddit/search` | Empty results are refunded; put the time window in the issue |

## Limits and things to watch

Codex in Linear runs on the legacy environment, and OpenAI says the legacy experience will be deprecated ([OpenAI: Cloud environments](https://learn.chatgpt.com/codex/environments/cloud-environments)). The new environment has finer key rules. It has environment variables and network secrets. A program sees a network secret only as a placeholder.

The proxy puts the real value into HTTPS requests to allowed domains. When the Linear integration moves to the new environment, the recommended setup becomes a network secret for `api.everyinfra.com`. Then the agent process never holds the raw key. Until then, follow the legacy rules.

The issue body is both the agent's input and an injection path. OpenAI's internet access page uses this case. An issue hides an instruction that sends commit data to an outside URL ([OpenAI: Agent internet access](https://learn.chatgpt.com/codex/cloud/internet-access)). Triage rules can auto-delegate issues that come from outside sources such as support, alerts and forms. More outside sources mean you should limit agent-phase internet to one or two domains. OpenAI's guide ends with the same advice: Codex can make mistakes, so review answers and diffs before you merge.

| Capability | `price_usd` | Returns | Required | Optional | Default / max `limit` | `field_note` (summary) |
| --- | --- | --- | --- | --- | --- | --- |
| `tiktok/video` | 0.000556 | One object | `url` | — | — | Some requests miss `is_sponsored`, `repost_count` and a few author fields |
| `youtube/comments` | 0.000556 | List | `url` | `since`, `sort` (newest, popular) | 20 / 100 | Some requests return at most 40 comments, with no like or reply counts |
| `reddit/search` | 0.000792 | List | `keyword` | `sort` (6 values) | 10 / 25, larger values are capped | Last month only; some requests miss flair, text and image fields |

Two more points are outside the table. `youtube/comments` returns relative `posted_at` values. The `cover_image_url` from `tiktok/video` is signed and expires, so save the image if you need it later.

Slow capabilities switch to async, so keep the polling code. EveryInfra provides only the data API. It does not touch your Linear workspace or GitHub repo. You review every pull request from Codex.

## Recent changes

- Around November 18, 2026: OpenAI moved the Codex in Linear guide to its new docs site. The guide covers auto-delegation with Triage rules and says chats run as the issue creator ([OpenAI: Use Codex in Linear](https://learn.chatgpt.com/docs/third-party/linear)). What it means: before you auto-delegate, confirm the issue creator has linked Codex.
- November 17, 2026: the AI Engineer channel posted "New Ways of Working with Codex" by two OpenAI engineers. Our 00:14 `youtube/search` result showed 16,251 views. What it means: OpenAI promotes delegation as a way of working, and Linear is one entry point.
- November 13, 2026: OpenAI updated the egress IP file for cloud agents ([chatgpt-agents.json](https://openai.com/chatgpt-agents.json)). What it means: services that allow by IP must check the ranges daily, and IP rules cannot replace a key.
- November 12, 2026: Linear's cloud coding agent added bring-your-own-key for OpenAI, Anthropic and other providers ([Linear changelog](https://linear.app/changelog/2026-11-12-bring-your-own-key)). What it means: "Codex in Linear" through Linear's own agent bills your API account.
- November 4, 2026: Linear shipped Diffs on mobile, and the same update fixed Codex missing from the reviewer dropdown ([Linear changelog: Mobile Diffs](https://linear.app/changelog/2026-11-04-mobile-diffs)). What it means: you can review changes from Codex on a phone.
- Through at least November 21, 2026: OpenAI's pricing page says GPT-5.6 Sol promo pricing runs at least until then ([OpenAI: Pricing](https://learn.chatgpt.com/codex/pricing)). GPT-5.6 Sol is a different model from GPT-6 Sol, the default in Linear's coding agent; Linear lists both as options. What it means: allowance-based Codex costs may change near the end of the month.

## FAQ

### What plan do I need for Codex in Linear?

You need a paid ChatGPT plan. Linear's integration page lists Plus, Pro, Business, Enterprise and Edu ([Linear: Codex Integration](https://linear.app/integrations/codex)). OpenAI's guide says "paid plans" and requires a Codex cloud environment first. On Enterprise, an admin must also enable it in workspace settings and connector settings. Source of the question: Google suggestion "install codex in linear".

### Is Codex Linear MCP the same as Codex in Linear?

No. Codex in Linear delegates work from Linear issues, and the task runs in the OpenAI cloud. Codex Linear MCP lets local Codex (CLI, IDE extension, ChatGPT desktop) read and write Linear issues. The command is `codex mcp add linear --url https://mcp.linear.app/mcp`. Linear says this MCP server works only for local Codex tasks ([Linear: Codex MCP Integration](https://linear.app/integrations/codex-mcp)). Source of the question: Google suggestion "codex linear mcp".

### Where do I install the Codex Linear plugin?

The cloud version has no separate plugin. Install "Codex for Linear" on the connectors page in Codex settings ([OpenAI: Use Codex in Linear](https://learn.chatgpt.com/docs/third-party/linear)). Linear also has an "open issues in coding tools" setting. It adds Codex to the Work on issue menu, which you open with W then O ([Linear Docs: Assign and delegate issues](https://linear.app/docs/assigning-issues)). Source of the question: Google suggestion "codex linear plugin".

### Can a Codex cloud task call an outside API?

Yes, but you must turn it on. In the legacy environment, the agent phase is offline by default. You can turn on internet per environment with a domain allowlist and allowed HTTP methods. If you allow only GET, HEAD and OPTIONS, POST is blocked ([OpenAI: Agent internet access](https://learn.chatgpt.com/codex/cloud/internet-access)). For EveryInfra, allow `api.everyinfra.com` and POST. Source of the question: the OpenAI community thread "Linear connector available in Codex", which asks what browser Codex can do with Linear ([OpenAI Community](https://community.openai.com/t/linear-connector-available-in-codex/1324689)).

### Codex Linear auth: why can my test not read a key stored as a secret?

In the legacy environment, secrets are available only to setup scripts, and Codex removes them before the agent phase ([OpenAI: Codex Cloud (Legacy)](https://learn.chatgpt.com/codex/environments/cloud-environment)). If the agent must read the key, use an environment variable with a separate, limited key. Or run tests offline. Source of the question: Google suggestion "codex linear auth".

### Codex or Claude Code in Linear: which one?

The top comment under Linear's Codex video asked about Claude Code. Today Linear's own cloud coding agent can run either one, and the default model is GPT-6 Sol ([Linear Docs: Linear cloud coding agent](https://linear.app/docs/linear-cloud-coding-agent)). A thread in r/Linear also discusses workflows that use both ([r/Linear](https://www.reddit.com/r/Linear/comments/1oh869t/use_claude_code_codex_with_linear_as_a_pm_or_dev/)). Pick based on what you already pay for: a ChatGPT plan or Linear AI credits.

## Get started

1. Sign up in the [EveryInfra quickstart](/docs#quickstart) and get an API key. Create a separate key for the Codex environment, with only the data API enabled.
1. Read the catalog, for example `GET https://api.everyinfra.com/api/v1/social/catalog?platform=tiktok`. Put the capabilities, parameters and prices in the issue.
1. Save three real responses in `tests/fixtures/`. Add the "Data API" section to `AGENTS.md`.
1. In the Codex cloud environment, set `EVERYINFRA_API_KEY` as an environment variable if you need live calls. Allow `api.everyinfra.com` and POST in the internet settings.
1. In Linear, mention @Codex or delegate the issue. Watch Activity, then review the diff in the chat link and open a PR.
1. After the merge, run the script in your own scheduler. Check `charged_usd` in the output file against the [pricing page](/pricing) and the catalog.

Another use of Codex cloud tasks is a weekly review report, covered in [Codex Cloud weekly app review report](/blog/codex-cloud-app-review-weekly-report). That article explains the cloud environment basics in more detail. For a parallel TikTok pull with Claude Code subagents, see [Claude Code subagents for TikTok brand accounts](/blog/claude-code-subagents-tiktok-accounts).

## References

1. [Use Codex in Linear](https://learn.chatgpt.com/docs/third-party/linear), OpenAI, around November 18, 2026, read November 20, 2026
1. [Codex Integration](https://linear.app/integrations/codex), Linear, read November 20, 2026
1. [Codex MCP Integration](https://linear.app/integrations/codex-mcp), Linear, read November 20, 2026
1. [Codex Cloud (Legacy)](https://learn.chatgpt.com/codex/environments/cloud-environment), OpenAI, read November 20, 2026
1. [Codex Cloud (Legacy): internet access](https://learn.chatgpt.com/codex/cloud/internet-access), OpenAI, read November 20, 2026
1. [Cloud environments](https://learn.chatgpt.com/codex/environments/cloud-environments), OpenAI, read November 20, 2026
1. [Agent approvals & security](https://learn.chatgpt.com/codex/agent-approvals-security), OpenAI, read November 20, 2026
1. [Model Context Protocol](https://learn.chatgpt.com/codex/extend/mcp), OpenAI, read November 20, 2026
1. [Custom instructions with AGENTS.md](https://learn.chatgpt.com/codex/agent-configuration/agents-md), OpenAI, read November 20, 2026
1. [Pricing](https://learn.chatgpt.com/codex/pricing), OpenAI, read November 20, 2026
1. [openai/codex-universal](https://github.com/openai/codex-universal), OpenAI, GitHub
1. [MCP bearer-token env var appears configured even when missing (#30125)](https://github.com/openai/codex/issues/30125), openai/codex, June 25, 2026
1. [chatgpt-agents.json](https://openai.com/chatgpt-agents.json), OpenAI, generated November 13, 2026
1. [What is ChatGPT Plus?](https://help.openai.com/en/articles/6950777-what-is-chatgpt-plus), OpenAI Help Center, read November 20, 2026
1. [ChatGPT Business overview](https://help.openai.com/en/articles/8792828-chatgpt-business-overview), OpenAI Help Center, read November 20, 2026
1. [Linear connector available in Codex](https://community.openai.com/t/linear-connector-available-in-codex/1324689), OpenAI Developer Community, July 26, 2025
1. [Agent platform](https://linear.app/docs/agents-in-linear), Linear Docs, read November 20, 2026
1. [Assign and delegate issues](https://linear.app/docs/assigning-issues), Linear Docs, read November 20, 2026
1. [Triage](https://linear.app/docs/triage), Linear Docs, read November 20, 2026
1. [Linear cloud coding agent](https://linear.app/docs/linear-cloud-coding-agent), Linear Docs, read November 20, 2026
1. [Coding sessions](https://linear.app/docs/coding-sessions), Linear Docs, read November 20, 2026
1. [Agents: Getting Started](https://linear.app/developers/agents), Linear Developers, read November 20, 2026
1. [Bring your own key (BYOK)](https://linear.app/changelog/2026-11-12-bring-your-own-key), Linear changelog, November 12, 2026
1. [Mobile Diffs](https://linear.app/changelog/2026-11-04-mobile-diffs), Linear changelog, November 4, 2026
1. [Linear Pricing](https://linear.app/pricing), Linear, read November 20, 2026
1. [Use Claude Code, Codex with Linear as a PM or Dev](https://www.reddit.com/r/Linear/comments/1oh869t/use_claude_code_codex_with_linear_as_a_pm_or_dev/), r/Linear
1. [OpenAI Codex agent](https://www.youtube.com/watch?v=JlhQD6GHT3g), Linear, YouTube, December 4, 2025
1. [Introducing coding sessions](https://www.youtube.com/watch?v=rZk0QrxPpw8), Linear, YouTube, June 11, 2026
1. [OpenAI Codex Agent in Linear is INSANE! : Automate ANYTHING!](https://www.youtube.com/watch?v=phZkN7j6jaQ), YouTube, December 8, 2025
1. [New Ways of Working with Codex](https://www.youtube.com/watch?v=IPh9YsWvDQk), AI Engineer, YouTube, November 17, 2026
1. [Software Developers, Quality Assurance Analysts, and Testers](https://www.bls.gov/ooh/computer-and-information-technology/software-developers.htm), US Bureau of Labor Statistics, read November 20, 2026
1. [Quota Calculator](https://developers.google.com/youtube/v3/determine_quota_cost), YouTube Data API docs, read November 20, 2026
1. [Reddit Data API Wiki](https://support.reddithelp.com/hc/en-us/articles/16160319875092-Reddit-Data-API-Wiki), Reddit Help, read November 20, 2026
1. [TikTok Research Tools: Access and Eligibility](https://developers.tiktok.com/products/research-api/), TikTok for Developers, read November 20, 2026
1. [RFC 9110: HTTP Semantics, 15.5.21 422 Unprocessable Content](https://www.rfc-editor.org/rfc/rfc9110.html#name-422-unprocessable-content), IETF, June 2022
1. [Requests: Quickstart](https://requests.readthedocs.io/en/latest/user/quickstart/), Requests docs
1. [EveryInfra catalog](https://api.everyinfra.com/api/v1/social/catalog), EveryInfra, read November 20, 2026, 00:14
1. [EveryInfra data API](https://api.everyinfra.com/api/v1/social), EveryInfra, real calls November 20, 2026
1. [EveryInfra account API](https://api.everyinfra.com/api/v1/account), EveryInfra, real call November 20, 2026
1. [OpenAI on TikTok: It's time to fly](https://www.tiktok.com/@openai/video/7647247430546672909), OpenAI, TikTok, June 3, 2026
1. [I stopped babysitting Codex. A lamp does it now.](https://www.reddit.com/r/codex/comments/1xztfrg/i_stopped_babysitting_codex_a_lamp_does_it_now/), r/codex, November 18, 2026 (UTC)
