APIMaster.ai

GLM-5.2, GLM-5.3 and GLM-5.3-Flash in Claude Code: Settings and Model Switching

Set up GLM in Claude Code using APIMaster. Configure settings.json on Windows, macOS and Linux, launch claude, select a model with /model and start chatting.

Configure APIMaster in settings.json, run claude, then enter /model MODEL_ID in the conversation to use GLM. The available IDs covered here are glm-5.2, glm-5.3, glm-5.3-flash. Claude Code is the client; GLM is the model that answers.

Before you start

Complete the environment check and Claude Code setup. Obtain an APIMaster API key with sufficient balance and access to the selected models.

claude --version

The gateway base URL is https://apimaster.ai, without /v1. Claude Code appends /v1/messages itself.

1. Open the configuration directory

Windows

Press Win + R, enter the following path and press Enter:

%USERPROFILE%\.claude

Create the folder if needed. Open or create settings.json. Make sure it is not named settings.json.txt.

macOS / Linux

On macOS, in Finder press Command + Shift + G and enter:

~/.claude

On Linux, open the same directory with your file manager or editor. Create it if needed:

mkdir -p ~/.claude

Open or create settings.json there. If you set a custom Claude Code configuration directory, use that directory instead.

2. Edit settings.json

Windows, macOS and Linux use the same configuration. Replace YOUR_APIMASTER_API_KEY with your APIMaster key:

{
  "model": "glm-5.3",
  "env": {
    "ANTHROPIC_BASE_URL": "https://apimaster.ai",
    "ANTHROPIC_API_KEY": "YOUR_APIMASTER_API_KEY",
    "ANTHROPIC_AUTH_TOKEN": "",
    "CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
    "CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
  }
}

If the file already exists, back it up and merge these fields into the existing JSON object and env object. Keep other settings you need. Do not append a second JSON object or duplicate an env key. JSON does not allow comments or trailing commas.

The general Claude Code guide shows token authentication. This guide uses the API-key authentication exercised in our integration tests. Keep ANTHROPIC_AUTH_TOKEN empty when using ANTHROPIC_API_KEY, and remove conflicting credentials from other settings or your terminal. Use an APIMaster key for this gateway.

The model field sets the starting model. You can select another one after launch. Keep this user settings file private; do not commit real keys to a shared repository. Save the file and restart Claude Code to load the new configuration.

3. Start Claude Code

In a terminal opened in your project directory, run:

claude

Complete any normal first-run prompts and review the project trust prompt. The starting model should be glm-5.3. This is a normal interactive session with the usual tools and project settings.

4. Select a model and start chatting

In the Claude Code conversation, enter one of the following commands and press Enter:

/model glm-5.2
/model glm-5.3
/model glm-5.3-flash

Run one line at a time, choosing the model you want. After Claude Code confirms the switch, send a short message:

Reply with exactly OK.

A normal text reply confirms the basic connection. You can then continue chatting or ask it to work on your project. To switch again in the same conversation, enter another /model MODEL_ID command.

Entering /model alone opens the model picker. Custom gateway IDs may not appear in its default list. Type the full ID as shown above instead. The slash command belongs inside Claude Code, not in PowerShell or Bash. The model names describe GLM models, not Claude Sonnet or Opus.

You can also choose a model when launching from the terminal. Run one command at a time:

claude --model glm-5.2
claude --model glm-5.3
claude --model glm-5.3-flash

To set the default for future sessions explicitly, edit model in settings.json. A launch flag, ANTHROPIC_MODEL environment variable, or project/managed setting can affect the selected model; check these if the starting model differs from your saved value.

Troubleshooting

Symptom Check
401 / unexpected login prompt Check the APIMaster key, base URL and conflicting authentication variables; restart the CLI after editing settings.
404 Use https://apimaster.ai, without /v1 or /v1/messages.
Settings do not take effect Check the file location, valid JSON and overrides from terminal, project or managed settings.
Model missing from the picker Enter /model MODEL_ID with the exact ID, or launch with claude --model MODEL_ID.
Model unavailable / 403 Check spelling, the key's allowed models, account balance and current route availability.
unrecognized_model Observed with custom IDs in our tests. Check the actual answer and tool result; built-in Claude capability defaults are not verified for GLM.
File or command permission denied Review and approve the intended operation through the usual permission prompts.
429 / 5xx / interrupted reply Keep the error, model ID, CLI version, UTC time and request ID if available for support.

Validation and optional diagnostics

Recorded integration tests: 2026-09-15 UTC, Claude Code 2.1.239, Linux. All models listed here returned the expected text and read a local file through a tool. All three also completed a small Python repair and test run, independently checked afterward. Windows and macOS were not part of those recorded runs.

The earlier automated checks used bare mode to isolate configuration. Normal daily use follows the settings.json and interactive steps above. Bare mode and --setting-sources "" skip normal integrations or saved settings, so they should not be added to the everyday startup command from this guide.

For a quick non-interactive check using your saved configuration:

claude --model glm-5.3 -p "Reply with exactly OK."

For a tool check, create probe.txt containing FILE_PROBE_739182, start Claude Code in that directory and ask it to read the file using a tool and return its exact contents. Confirm that the tool actually runs.

These are bounded integration checks, not a guarantee of every Claude Code feature, long-session behavior or maximum context. Anthropic's gateway documentation does not officially support routing Claude Code to non-Claude models; this guide describes APIMaster's integration.

FAQ

Does my Claude subscription pay for these requests?

No. With this APIMaster configuration, requests use your APIMaster key and balance.

Can I keep chatting after switching models?

Yes, use the model switch command in the open conversation and wait for confirmation before sending the next message. For a clean comparison between models, start a separate session with claude --model MODEL_ID.

Related guides and sources