How to Use GLM 4.5 in Codex: A Practical Guide

GLM 4.5 is the flagship large language model released by Z.ai, excelling in reasoning, coding, and agentic tasks. With advanced optimizations such as Mixture-of-Experts architecture and extended context handling, it sets a new benchmark for developers who need both power and efficiency in their AI workflows.

Meanwhile, Codex provides a lightweight but capable command-line interface (CLI) that makes working with large language models fast and flexible. Instead of being tied to an IDE, you can run prompts, test code, and connect to multiple API providers directly from your terminal.

This guide will show you how to use GLM 4.5 inside Codex—from installation and configuration to running your first coding tasks—so you can quickly turn powerful model capabilities into a smooth developer workflow.

What is GLM 4.5: Basics and Highlights

Basic Features

FeatureDetail
Parameters355B in total and 32B activated
ArchitectureMixture-of-Experts
Context Window128K tokens
Inference ModeThink + Non-Think
MultimodalText-only
Multilingual CapabilitySupports multiple languages; strong in English & Chinese
GLM 4.5 Benchmark
GLM 4.5 Benchmark

Key Highlights

Architecture & Training

  • Deepened MoE Structure – More layers with slimmer width, enhancing reasoning depth while keeping efficiency.
  • Massive Pre-training Corpus – 15 trillion tokens for broad knowledge coverage.
  • Advanced RL Infrastructure – Open-source platform for scalable reinforcement learning and agent training.
  • Skill Consolidation – Reinforcement and supervised learning distilled into robust expert models.

Agentic Capabilities

  • Built for autonomous agents, with native function calling, in-context web browsing, and multi-step task planning.
  • Can run toolchains without heavy external orchestration, making it more flexible for agent frameworks.

Coding Strengths

  • Excels at end-to-end software development, from frontend to backend and database handling.
  • Strong in code generation and debugging, plus terminal-level operations for CLI environments.
  • Demonstrates solid performance in algorithm design and real-world engineering tasks, validated against leading model benchmarks.

Reasoning Power

  • Handles mathematical reasoning (AIME, MATH benchmarks) with competitive results.
  • Strong in scientific and logical problem-solving, supporting multi-step inference.
  • Effective at long-context comprehension, maintaining accuracy over extended inputs.

Why Use GLM 4.5 in Codex

GLM 4.5 is impressive on its own—but pairing it with Codex unlocks a more efficient way to bring its strengths into daily development. Codex isn’t just another interface; it’s a command-line coding agent designed to make large language models feel natural inside the terminal, right where many developers already spend most of their time.

Codex as a Developer’s Companion

Unlike IDE plug-ins or browser dashboards, Codex is lightweight and terminal-native. That means you can call GLM 4.5 directly, test outputs, and manage multiple APIs without switching tools. For developers who value speed and control, this CLI approach is hard to beat.

Key Advantages of Using GLM 4.5 in Codex

AdvantageWhat It Means for Developers
Direct model accessRun prompts and get results instantly without leaving the terminal.
Automated workflowsOrchestrate tasks like generate → test → commit in one pipeline.
Flexible integrationEasily switch between providers with minimal setup.
Lightweight setupNo heavy IDE integrations, just a simple CLI tool.

Benefits of Using GLM 4.5 over Native Codex Models

Native Codex models are excellent for broad coding tasks and general-purpose development. GLM-4.5, however, brings unique advantages that make it a valuable complement in specific scenarios:

  • Specialized coding support: GLM-4.5 is designed with hybrid reasoning and coding in mind. It handles structured code generation, iterative debugging, and tool-use workflows in a way that can feel more consistent for developers building agent pipelines.
  • Agent-friendly capabilities: With built-in modes for function calling, tool usage, and task planning, GLM-4.5 naturally supports agentic workflows. This makes it easier to experiment with autonomous agents or integrate multi-step reasoning into production systems.

Together, Codex provides robust general-purpose coding power, while GLM-4.5 is well-suited for specialized reasoning and agent integration in your development workflow.

Real-World Scenarios

  • Prototyping: Draft a Python script in seconds and run it immediately.
  • Debugging: Test SQL queries or code snippets with rapid iteration.
  • Enterprise workflows: Operate in compliance-friendly environments where auditability matters.

In short, Codex makes GLM 4.5 not just a powerful model, but a practical everyday tool for coding, reasoning, and agentic workflows.

How to Use GLM 4.5 in Codex: Prerequisites Overview

To use GLM 4.5 inside Codex, you’ll need three things in place:

  1. An API key for GLM 4.5: Recommended to obtain from Novita AI, stored in a configuration file for seamless integration.
  2. The Codex CLI: Installed globally so you can call the agent directly from your terminal.
  3. A working environment: Node.js 18 or higher, plus npm for package management.

Once these are ready, you’ll have everything needed to connect Codex with GLM 4.5 and start experimenting. The setup is lightweight, and the entire process takes just a few minutes.

How to Use GLM 4.5 in Codex: Step-by-Step Guide

Step 1: Get Your API Key on Novita AI

Create an Novita AI account andThe first step is to generate an API key from the Novita AI platform. Then go to Key Management and select Add New Key.
This API Key acts as your access credential. Since it is only shown once, copy it immediately and save it in a secure place. It will be needed for the steps below.

Novita AI provides first-class Codex support for a range of state-of-the-art models, such as:

  • zai-org/glm-4.5
  • deepseek/deepseek-v3.1
  • qwen/qwen3-coder-480b-a35b-instruct
  • moonshotai/kimi-k2-0905
  • openai/gpt-oss-120b
  • google/gemma-3-12b-it

Step 2: Install Codex CLI

Node.js 18+ is required

node -v
npm install -g @openai/codex

Install via Homebrew (macOS)

brew install codex

Verify Installation

codex --version

Configuring GLM 4.5 via Novita AI API

Create a Codex config file and set GLM 4.5 as the default model.

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

Basic Configuration Template

model = "zai-org/glm-4.5"
model_provider = "novitaai"

[model_providers.novitaai]
name = "Novita AI"
base_url = "https://api.novita.ai/openai"
http_headers = {"Authorization" = "Bearer YOUR_NOVITA_API_KEY"}
wire_api = "chat"

Step3: Getting Started

Launch Codex CLI

codex

Basic Usage Examples

Code Generation:

> Create a Python class for handling REST API responses with error handling

Project Analysis:

> Review this codebase and suggest improvements for performance

Bug Fixing:

> Fix the authentication error in the login function

Testing:

> Generate comprehensive unit tests for the user service module

Working with Existing Projects

Navigate to your project directory before launching Codex CLI:

cd /path/to/your/project
codex

Codex CLI will automatically understand your project structure, read existing files, and maintain context about your codebase throughout the session.

Troubleshooting

Error / SymptomLikely CauseFix
401 UnauthorizedInvalid or expired API key; header typoRegenerate key on Novita AI, update config.toml with correct Authorization = "Bearer …"
404 model_not_foundWrong model nameUse exact string: zai-org/glm-4.5
Slow / TimeoutNetwork latency, proxy, or low timeoutRetry small prompt, check VPN/proxy, increase timeout flag
Model won’t switchWrong config path or typoConfirm ~/.codex/config.toml (Linux/macOS) or %USERPROFILE%\.codex\config.toml (Windows); restart shell
CLI freezesMultiline prompt not terminatedUse here-doc (<< 'EOF' ... EOF) in bash/zsh; here-string in PowerShell
Windows path confusionConfig placed in System32 by mistakeMove file to %USERPROFILE%\.codex\config.toml
Rate-limit / Payload errorToo many concurrent requests or large inputAdd retries with backoff, trim context, split long files

Conclusion

GLM 4.5 brings advanced coding and agentic capabilities, while Codex offers a lightweight way to use them directly from the terminal. Together, they create a workflow that is fast, flexible, and well suited for both rapid prototyping and enterprise environments.

For developers, this combination means fewer barriers: powerful reasoning and coding skills from GLM 4.5, paired with Codex’s ability to orchestrate tasks without leaving the CLI.

Frequently Asked Questions

What is GLM 4.5?

GLM 4.5 is Z.ai’s flagship large language model, optimized for coding, reasoning, and agentic tasks.

Can GLM 4.5 be used directly inside Codex?

Yes. Codex supports GLM 4.5 integration via API configuration.

How do I get access to GLM 4.5?

Generate an API key from Novita AI’s platform and add it to your Codex configuration file.

Novita AI is an AI cloud platform that offers developers an easy way to deploy AI models using our simple API, while also providing the affordable and reliable GPU cloud for building and scaling.


Discover more from Novita

Subscribe to get the latest posts sent to your email.

Leave a Comment

Scroll to Top

Discover more from Novita

Subscribe now to keep reading and get access to the full archive.

Continue reading