Clawgate Clawgate
How-to guide

How to Run GLM 5.2 in Claude Code and Codex with Clawgate AI

GLM 5.2 is an open weight model that performs close to the Claude Opus benchmarks, but at a fraction of the cost. The hard part is usually wiring it into the tools you already use. In this guide, I will show you how to run GLM 5.2 inside both Claude Code and Codex using Clawgate AI as a central control layer for all your models, with simple pay as you go pricing.

By the end, you will have one key that works across both tools, full control from a dashboard, and automatic usage tracking for every request.

📺 Watch the full video walkthrough: youtube.com/watch?v=srWD34GZXUI
🔗 Get started: clawgateai.com

What is Clawgate AI?

Clawgate is the control layer for Claude Code and OpenAI Codex. It puts you in charge of how your team uses AI: you set a budget, pick the model, and see what every project costs, with no surprises.

The way it works is simple. You point Claude Code or Codex at your Clawgate gateway and hand each developer a vsk_… key. Every request is then checked against your budget and tied to a specific user and project before it ever runs. For your engineers, it is a one line endpoint change. For you, everything after that is dashboard toggles.

Clawgate also brings leading models from Anthropic, OpenAI, xAI, DeepSeek, Moonshot, Z.ai, and more directly into Claude Code and Codex, with no extra setup for your team. You decide which models they can use, and usage is billed at provider rates, at cost, plus one clear platform fee.

The problem Clawgate solves

The technical problem

When you give Claude Code and Codex to a team, you lose control in three places:

No usage control. Staff can run company AI on private side projects, and the company still pays for it. There is no gate between the developer and the model.

No cost visibility. Even when you trust your team completely, you cannot tell which project consumed what. The invoice arrives as one large undifferentiated number, with no way to attribute spend back to a project or a person.

No model control. Claude Code and Codex choose the model on their own. You pay for that choice with no say in it, and there is no mechanism to serve a cheaper model when full power is not needed.

Clawgate closes all three gaps at the gateway level. Every request is scoped to a project using an x-project-id header, checked against hard stop budgets, and routed only to the models you have allowed. Privacy safe fingerprints flag shared keys, content mismatches, and usage spikes, all without ever reading your raw code.

The financial problem

AI coding is booming, and so are the costs. The risk is that you cannot see the spend until the invoice arrives, and by then it is too late. This is not a small company problem. Some of the largest companies in the world have run into it head on.

Uber gave Claude Code to roughly 5,000 engineers and watched the cost per engineer climb to between $500 and $2,000 a month, burning through its entire 2026 AI budget in four months. Meta saw staff consume 73.7 trillion tokens in a single 30 day window as people raced to top an internal leaderboard, pushing costs toward billions and forcing the company to start capping usage.

The financial logic behind Clawgate is straightforward. Companies can save millions by giving engineers AI, but the moment you lose control of how it is used, those savings turn into waste and surprise costs. Clawgate protects the savings with:

Hard stop budgets. Daily and weekly token, session, and USD caps per user and per project. When the cap is hit, the request stops, so spend literally cannot exceed the limit.

Model based cost control. Because you choose which models run, you can serve lower cost models like GLM 5.2 whenever full Opus level power is not required, and control the cost of every request.

Transparent billing. AI costs are passed through at cost with a clear platform fee. Cache savings are passed on to you, and failed requests are never billed.

The result is the upside of AI coding without the budget blowups.

Prerequisites

Before you start, make sure you have:

  • A Clawgate Console account (free to sign up)
  • Claude Code and Codex installed
  • An IDE. I am using IntelliJ in this demo.

Step 1: Sign up and create a project

Head to the Clawgate Console and sign up. Once you are in, create a new project. Projects are how Clawgate groups your work and attributes cost.

Step 2: Create a policy

Next, create a policy and add your project to the allowed projects list. A policy defines which models are permitted. You can either select a set of allowed models or lock it down to a single forced model. Either way, you can always override this later when you create a key.

Step 3: Create a user

Create a user and assign the policy you just made. This ties your access rules and budgets to a specific identity.

Step 4: Generate a key

Finally, create a key for that user. In this demo, I am adding a forced model at the key level, which overrides whatever models the policy allows.

Important: The key is shown only once and cannot be retrieved later. Email it to your user or store it somewhere safe and private the moment it is generated.

Once the key is created, Clawgate shows you ready to use configurations for both Claude Code and Codex.

Step 5: Configure Claude Code

  1. Open your project in your favorite IDE. I am using IntelliJ.
  2. Paste the Claude configuration into your settings.local.json file.
  3. Open the terminal and run:
claude

That is it. You are now using Claude Code with the forced model you selected, and every request is recorded in the Clawgate Dashboard.

Step 6: Configure Codex for GLM 5.2

Now let us point Codex at the same key to run GLM 5.2. There are two steps.

1. Add the global configuration (one time setup)

On the key page, open the Connection Setup tab and select Codex. Add the provider block below to your user global ~/.codex/config.toml file (create the file if it does not exist). Codex only reads custom providers from this global file, so a project local one will be ignored.

model_provider = "clawgate"

[model_providers.clawgate]
name = "Clawgate"
base_url = "https://console.clawgateai.com/gateway/v1"
env_key = "CLAWGATE_API_KEY"
wire_api = "responses"
requires_openai_auth = false
env_http_headers = { "x-project-id" = "CLAWGATE_PROJECT_ID" }

2. Add a project level .envrc file

These variables must be set in the shell where you run Codex. At the project level, create a .envrc file and add the two lines below. Replace the key placeholder with the key you saved (it starts with vsk_), and set the project ID for the project you want to track against:

export CLAWGATE_API_KEY="<paste-your-saved-key-here>"
export CLAWGATE_PROJECT_ID=your-project-id

The x-project-id for the selected project is included here, so change it any time you want to switch projects. Then save, exit, and load the file by either sourcing it or, if you use direnv, running direnv allow once to auto load it (a plain .envrc is not loaded automatically without direnv):

source .envrc

Now open Codex in the same project directory where your local config lives:

codex

GLM 5.2 is now running inside Codex. 🎉

The best part: switch models without touching config

Here is where Clawgate shines. Without changing a single line of local configuration, you can switch models directly from the Clawgate Console. You have full control over every key from the dashboard, and all usage stats are saved automatically, which is exactly what you need for cost governance and managing models across a team.

Wrapping up

With Clawgate AI, you get one key, two tools, and complete control:

  • ✅ Run open weight models like GLM 5.2 in Claude Code and Codex
  • ✅ Govern models, users, and spend from a single console
  • ✅ Tie every request to a project and a budget before it runs
  • ✅ Swap models on the fly with no config edits
  • ✅ Track every request automatically

Give it a try at clawgateai.com, and watch the full video walkthrough on YouTube if you want to follow along step by step.

Run GLM 5.2 in your stack today

One Clawgate key across Claude Code and Codex, dashboard model control, hard-stop budgets, and automatic per-project usage tracking.