How to connect Grok Build to APIArc and use GPT models
Grok Build can load custom OpenAI-compatible models. If a provider gives you a compatible base URL, a model ID and an API key, you can add that provider without changing the rest of your workflow. This guide uses APIArc and gpt-5.6-luna as a complete example.
grok -m apiarc-luna grok -p "Describe this project in three sentences" -m apiarc-luna
Install Grok Build
On macOS, install Grok Build with Homebrew, then verify that the command is available:
brew install --cask grok-build grok --version
Collect the APIArc connection details
You'll use these three values in the configuration:
Base URL https://apiarc.ai/v1 Model ID gpt-5.6-luna Key env APIARC_API_KEY
APIArc exposes an OpenAI-compatible API. Grok Build uses the Chat Completions protocol, so the base URL should be the APIArc /v1 endpoint rather than a full /chat/completions URL. Keep the real API key in an environment variable; never paste it into a public tutorial or commit it to a repository.
Create the Grok Build configuration
Create the user configuration directory and file if they do not already exist:
mkdir -p ~/.grok touch ~/.grok/config.toml nano ~/.grok/config.toml
Add this model definition:
[model.apiarc-luna] model = "gpt-5.6-luna" base_url = "https://apiarc.ai/v1" name = "APIArc GPT-5.6 Luna" description = "GPT-5.6 Luna through APIArc" env_key = "APIARC_API_KEY" api_backend = "chat_completions" context_window = 200000
apiarc-luna is Grok Build's local alias. You can rename it, but model must remain the real APIArc model ID.env_key tells Grok Build which environment variable to read, while context_window helps it decide when to compact context.
Set the API key safely
Export your APIArc key in the current terminal. Replace the placeholder with your own key:
export APIARC_API_KEY="your_apiarc_api_key"
This only affects the current shell. If you add it to ~/.zshrc, protect that file and your device because the key will be stored locally in plain text. To check that the variable exists without printing the secret, inspect only whether it is non-empty:
test -n "$APIARC_API_KEY" && echo "APIARC_API_KEY is set"
Check that Grok Build loaded the model
List the configured models, and use the inspection command if the alias does not appear:
grok models grok inspect
The list should contain apiarc-luna. If it does not, check that Grok Build is reading ~/.grok/config.toml and that the TOML section name, quotes and field names are valid.
Run a small end-to-end test
Start with a short, deterministic prompt to make troubleshooting easier:
grok \ -p "Reply with only APIARC_LUNA_OK" \ -m apiarc-luna \ --max-turns 1 \ --disable-web-search \ --no-subagents
If the terminal returns APIARC_LUNA_OK, Grok Build has successfully called gpt-5.6-luna through APIArc. Warnings about unrelated local MCP services can be investigated separately; they do not necessarily indicate an APIArc failure.
Add other APIArc GPT models
You can add more model aliases to the same file and reuse the same key variable:
[model.apiarc-sol] model = "gpt-5.6-sol" base_url = "https://apiarc.ai/v1" name = "APIArc GPT-5.6 Sol" env_key = "APIARC_API_KEY" api_backend = "chat_completions" context_window = 200000 [model.apiarc-terra] model = "gpt-5.6-terra" base_url = "https://apiarc.ai/v1" name = "APIArc GPT-5.6 Terra" env_key = "APIARC_API_KEY" api_backend = "chat_completions" context_window = 200000
Launch any alias directly:
grok -m apiarc-sol grok -m apiarc-terra
Before adding a new model, confirm its exact ID from APIArc:
curl https://apiarc.ai/v1/models \ -H "Authorization: Bearer $APIARC_API_KEY"
Common errors
| Error | Likely cause | What to check |
|---|---|---|
| No API key | The environment variable is missing or mismatched | Compare `env_key` with the exported variable name without printing the key |
| Model not found | The config uses the local alias as the upstream ID | Use the exact APIArc model ID in `model` |
| 401 Unauthorized | The key is missing, invalid or lacks permission | Create a new key and revoke any exposed key |
| 404 Not Found | The base URL includes too much path | Use `https://apiarc.ai/v1`, not `/chat/completions` |
Grok Build may also report warnings from local MCP or plugin configuration. For a clean model-only test, keep --disable-web-search and --no-subagents enabled.
Complete configuration
A minimal working ~/.grok/config.toml looks like this:
[model.apiarc-luna] model = "gpt-5.6-luna" base_url = "https://apiarc.ai/v1" name = "APIArc GPT-5.6 Luna" env_key = "APIARC_API_KEY" api_backend = "chat_completions" context_window = 200000
Export the key, then start Grok Build with the alias. From then on, switching APIArc models only requires copying the model block and changing its alias and model ID.
Browse APIArc's model catalog to check current model IDs and pricing.