15% off all models 🎉 Every model at 85% of OpenRouter list price.Browse models →

ApiFlux troubleshooting and FAQ

Troubleshoot API keys, Base URLs, models, environment variables, Codex CLI, Claude Code, and OpenCode.

Use this page to troubleshoot API keys, Base URLs, models, environment variables, Codex CLI, Claude Code, and OpenCode.

Q1: What is the difference between the website address and API Base URL?

Use the website to sign in, create API keys, compare models, check your balance, and view logs:

https://apiflux.ai/

Use the API Base URL when configuring tools and SDKs:

https://apiflux.ai/v1

Most OpenAI-compatible tools should use https://apiflux.ai/v1.

For Claude Code, start with:

https://apiflux.ai

If you get a path-related error, try again:

https://apiflux.ai/v1

Q2: What should I do if an API key is exposed?

Act immediately:

  1. Log in to the ApiFlux console
  2. Enter API keys
  3. Delete the leaked API key
  4. Create a new API key
  5. Update configurations in local tools or applications

Never continue using an exposed API key.

Q3: Why do I get 401 or Unauthorized?

Common reasons include:

  • The API key is incorrect
  • The API key was deleted or expired
  • Extra spaces are included when copying the API key
  • The current terminal session does not have the environment variable
  • The tool is still reading an old API key

For OpenCode or Codex CLI, check:

Windows PowerShell:

echo $env:APIFLUX_API_KEY

macOS/Linux:

echo $APIFLUX_API_KEY

For Claude Code, check:

Windows PowerShell:

echo $env:ANTHROPIC_API_KEY

macOS/Linux:

echo $ANTHROPIC_API_KEY

If there is no output, reset the environment variables.

Q4: Why do I get an insufficient balance error?

The ApiFlux account associated with the API key does not have enough available credit.

To fix it:

  1. Open ApiFlux Dashboard
  2. View Current balance
  3. If needed, click Recharge
  4. Send the request again after the balance updates

Q5: Why do I get a model not found error?

The model ID is usually incorrect.

Open the ApiFlux Models page and copy the interface model ID shown in the model details. Do not use the display name or guess the ID.

Error example:

Claude Sonnet
GPT 4o
Gemini Pro

The correct approach is to copy the full model ID shown on the ApiFlux Models page.

Q6: Why is a successful request missing from Logs?

Check the following:

  • You are signed in to the correct ApiFlux account
  • The tool is configured with the ApiFlux Base URL
  • The tool is using an ApiFlux API key
  • The request was not sent directly to another provider
  • The Logs page has been refreshed
  • The selected time range includes the request

If the tool returns a response but no entry appears in ApiFlux Logs, the request probably did not go through ApiFlux.

Q7: Which interface should be used for Codex CLI, Claude Code, and OpenCode?

Configure Codex CLI with a custom model provider and this Base URL:

https://apiflux.ai/v1

Configure OpenCode with an OpenAI-compatible custom provider and this Base URL:

https://apiflux.ai/v1

Configure Claude Code with these Anthropic-compatible gateway variables:

ANTHROPIC_BASE_URL
ANTHROPIC_API_KEY
DISABLE_INTERLEAVED_THINKING
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS

After setup, use ApiFlux Logs to confirm that requests reach ApiFlux.

Q8: Can an API key be shared by multiple tools?

Yes, but separate keys are safer and easier to trace in regular use.

For example:

codex-cli-key
claude-code-key
opencode-key
production-app-key

There are three benefits to doing this:

  • Attribute usage to a specific tool
  • Troubleshoot unexpected requests
  • Revoke access for one tool or environment without affecting the others

Q9: How do I change the model?

First go to the ApiFlux Models page and copy the new model ID.

For Codex CLI:

model = "YOUR_NEW_MODEL_ID"

For OpenCode:

"models": {
  "YOUR_NEW_MODEL_ID": {}
}

For Claude Code versions that support the --model option:

claude --model "YOUR_NEW_MODEL_ID"

Restart the tool, send a request, and confirm the new model in ApiFlux Logs.

Q10: How do I safely share screenshots and screen recordings?

Before sharing screenshots or screen recordings, remove or redact:

  • Complete API key
  • Environment variables containing the real key
  • Configuration files containing a real key
  • Sensitive prompts
  • Private log content

Example redaction:

sk-****abcd

Show at most the first and last three or four characters. Never display the complete key.

Q11: Do I need to add /v1 after the Base URL?

Most OpenAI-compatible tools and SDKs should use:

https://apiflux.ai/v1

For Claude Code, set ANTHROPIC_BASE_URL to this value first:

https://apiflux.ai

If you get a path-related error, try again:

https://apiflux.ai/v1

The configuration is correct when the tool returns a response and the request appears in ApiFlux Logs.

Q12: How do I confirm that a request went through ApiFlux?

Send a simple request, then open Logs in the ApiFlux console.

If the request appears, the tool is using ApiFlux.

If the tool responds but no entry appears, check the Base URL, API key, and signed-in account.

Q13: What should I do if Claude Code reports invalid beta flag?

This is a beta header compatibility issue that may occur when Claude Code connects to a third-party gateway.

Before starting Claude Code, please set:

Windows PowerShell:

$env:DISABLE_INTERLEAVED_THINKING="1"
$env:CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS="1"

macOS/Linux:

export DISABLE_INTERLEAVED_THINKING=1
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1

Then rerun:

claude --model "YOUR_MODEL_ID"

Q14: What should I do if OpenCode reports fn3 is not a function?

This error usually comes from an OpenCode plugin, not the ApiFlux API key or Base URL.

Open the configuration file:

~/.config/opencode/opencode.json

Temporarily set plugin to an empty array:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": []
}

After OpenCode starts successfully, restore the plugins one at a time.

Q15: What should I do if OpenCode reports that function tools or reasoning_effort are not supported?

The current model does not support the tool calls OpenCode needs.

Try a model that supports coding tool calls, such as:

deepseek-v4-pro
qwen3.7-plus
glm-5.2

Q16: Why are the commands different between Windows and macOS/Linux?

The shells use different syntax for environment variables.

Windows PowerShell uses:

$env:APIFLUX_API_KEY="YOUR_APIFLUX_API_KEY"

macOS and Linux use:

export APIFLUX_API_KEY="YOUR_APIFLUX_API_KEY"

Using the wrong command will usually only produce an error or fail to set the variable. Return to the section for your operating system and use the matching command.

Q17: What should I do if I see command not found or “not recognized as an internal or external command”?

The tool may not be installed, or its installation directory may be missing from PATH.

To fix it:

  1. Close the terminal and reopen it
  2. Run version check commands such as node -v, codex --version, claude --version, opencode --version
  3. If it still fails, run the tool's installation command again
  4. If you installed with npm on Windows, confirm that npm -v prints a version number

Q18: What should I do if npm is not found?

Node.js may not be installed, or the terminal may still be using an old PATH from before installation.

Please visit the Node.js website to install the LTS version:

https://nodejs.org/

After the installation is complete, close the terminal and reopen it, then run:

node -v
npm -v

Windows PowerShell can also run the same version check command.

Q19: Are environment variables temporary or permanent?

Environment variables set directly in a terminal are usually valid only for the current session.

For the current Windows PowerShell session:

$env:APIFLUX_API_KEY="YOUR_APIFLUX_API_KEY"

For future Windows PowerShell sessions:

[Environment]::SetEnvironmentVariable("APIFLUX_API_KEY","YOUR_APIFLUX_API_KEY","User")

For the current macOS or Linux shell session:

export APIFLUX_API_KEY="YOUR_APIFLUX_API_KEY"

To persist the variable, macOS usually uses ~/.zshrc and Linux usually uses ~/.bashrc.

Q20: Do Windows users have to install WSL?

No. PowerShell is sufficient for the steps in these guides.

Consider WSL if you frequently use Linux commands or if a tool behaves inconsistently on native Windows. When working inside WSL, follow the Linux instructions.

References