DEV Community

ModelFild
ModelFild

Posted on AI-assisted

Point Claude Code, Codex, and Grok Build at one API key

The three tools do not share a settings file. Claude Code reads ~/.claude/settings.json. Codex reads ~/.codex/config.toml. Grok Build reads ~/.grok/config.toml. ModelFold's docs give a copy-paste block for each one, and the same key works in all three. This note copies those blocks from the public docs on 23 November 2026. If a model ID on the page has changed, copy the current ID from the model list instead of guessing.

Disclosure: the author works on ModelFold.

Docs:

Create the key first at https://modelfold.ai/account?tab=keys . The dashboard shows it as mf-.... Pricing is on https://modelfold.ai/pricing . Do not budget from a number in an old post.

Claude Code

Mac / Linux file: ~/.claude/settings.json. Windows: %USERPROFILE%\.claude\settings.json. Replace mf-... with your key. The docs say all four model lines are required, including Haiku, or background tasks error.

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://modelfold.ai/anthropic",
    "ANTHROPIC_AUTH_TOKEN": "mf-...",
    "ANTHROPIC_MODEL": "claude-sonnet-5-5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5-5",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5"
  }
}
Enter fullscreen mode Exit fullscreen mode

Close every terminal, including the one inside the editor, then run claude. In the session, /status should show Anthropic base URL as https://modelfold.ai/anthropic.

The docs' failure table:

  • A login prompt means the file is in the wrong place, or a project .claude/settings.json is overriding it.
  • 401: the token should be the raw mf-... value, with no Bearer prefix.
  • 404 or a URL that contains /v1/v1: stop the base URL at /anthropic. Do not append /v1.
  • model not found: run /model and pick an ID from the list.

Codex

Set the key, then write the provider in the user config, not a project file.

export MODELFOLD_API_KEY=mf-...
Enter fullscreen mode Exit fullscreen mode

Mac / Linux: ~/.codex/config.toml. Windows: %USERPROFILE%\.codex\config.toml.

model = "gpt-6-astra"
model_provider = "ModelFold"

[model_providers.ModelFold]
name = "ModelFold"
base_url = "https://modelfold.ai/openai/v1"
env_key = "MODELFOLD_API_KEY"
wire_api = "responses"
Enter fullscreen mode Exit fullscreen mode

Open a new terminal and run codex. The docs say a line like Model metadata for '…' not found only means the model is not in Codex's built-in list. It does not block the call.

Do not set model to gpt-5.6-luna. The docs say that model returns text and does not run commands or edit files. Do not name the provider openai, ollama, or lmstudio. If the URL contains /responses/responses, the base URL was given an extra /responses. codex doctor should show the env key under auth and a reachable provider under reachability.

Grok Build

Same environment variable. Config file: ~/.grok/config.toml on Mac / Linux, %USERPROFILE%\.grok\config.toml on Windows.

[models]
default = "ModelFold"
web_search = "ModelFold"

[model.ModelFold]
model = "grok-4-7"
base_url = "https://modelfold.ai/xai/v1"
name = "ModelFold"
api_backend = "responses"
env_key = "MODELFOLD_API_KEY"
supports_backend_search = true
Enter fullscreen mode Exit fullscreen mode

The model ID on that page is grok-4-7, not grok-4.7. After a new terminal, grok models should list ModelFold. Then run grok.

If you have signed in to a grok.com account, the docs say that account can override default. Start with grok -m ModelFold, or pick ModelFold with /model inside the session. A request to /chat/completions means api_backend = "responses" was dropped. A request to /responses/responses means the base URL included /responses already.

One check that covers all three

Each tool's doc says the first reply is enough to know the path works, and the call shows up at https://modelfold.ai/account?tab=usage . The first turn caches tool instructions, so it spends more than a later turn. That is described as normal, not as a flat rate.

Top comments (0)