# GLM 4.6

Z.AI's dedicated coding model with a context window of 204.8K tokens and enhanced performance on both benchmarks and real-world programming tasks.

- **Model ID:** `zai/glm-4.6`
- **Type:** chat
- **Providers:** zai, deepinfra, novita
- **Context window:** 204,800
- **Maximum output tokens:** 202,752
- **Pricing:** $0.6/1M input tokens, $2.2/1M output tokens
- **Canonical page:** https://vercel.com/ai-gateway/models/glm-4.6

## Supported parameters

Detailed capability metadata has not been reported for this model.

## Example

```ts
import { streamText } from 'ai'

const result = streamText({
  model: 'zai/glm-4.6',
  prompt: 'Why is the sky blue?'
})
```

## About

GLM 4.6 was released September 30, 2025 as Z.AI's dedicated coding model. It builds on the GLM-4.5 foundation with targeted improvements for software engineering workflows, benchmark performance, and real-world programming tasks.

The key architectural change is an expanded context window of 204.8K tokens. You can process entire codebases, long specification documents, and multi-file analysis in a single request. This benefits code generation tasks that require understanding cross-file relationships, and agentic coding workflows that maintain state across extended interactions.

GLM 4.6 shows enhanced performance on both public benchmarks and real-world programming tasks. Benchmark scores predict capability, but real-world coding involves ambiguous requirements, legacy code patterns, and iterative refinement. GLM 4.6 targets both dimensions.

## What to consider

The context window of 204.8K tokens handles large codebases in a single pass. Structure your prompts to include relevant file context rather than relying on the model to infer missing dependencies.

GLM 4.6 is optimized for code generation and understanding. For general reasoning or conversational tasks, GLM-4.5 may provide a more balanced profile.

Coding tasks with large context inputs consume many tokens. Monitor usage through AI Gateway's built-in observability to track actual costs against estimates.

## When to use

### Best For

- **Software engineering workflows** including code generation, debugging, refactoring, and code review across large repositories
- **Agentic coding tasks** where extended context and multi-step planning improve the quality of generated solutions
- **Large codebase analysis** leveraging the context window of 204.8K tokens to understand cross-file dependencies and architectural patterns
- **Code migration and modernization** where understanding legacy patterns and generating updated code requires broad context
- **Technical documentation generation** from codebases where the model needs to read and synthesize large amounts of source code

### Consider Alternatives When

- Your workload is general-purpose reasoning or conversation. GLM-4.5 provides broader capability without the coding specialization
- You need vision capabilities for code-from-screenshot workflows. GLM-4.6V combines vision input with coding capability
- Faster inference matters more than coding depth. GLM-4.6V-Flash offers vision and coding at reduced latency
- You need further coding-focused improvements. GLM-4.7 includes further advancements in tool usage and multi-step reasoning for complex agentic tasks

## Best for

- **Software engineering workflows:** Code generation, debugging, refactoring, and code review across large repositories
- **Agentic coding tasks:** Extended context and multi-step planning improve the quality of generated solutions
- **Large codebase analysis:** The context window of 204.8K tokens fits cross-file dependencies and architectural patterns
- **Code migration and modernization:** Understanding legacy patterns and generating updated code requires broad context
- **Technical documentation generation:** Codebases where the model must read and synthesize large amounts of source code

## Consider alternatives

- **General-purpose workloads:** GLM-4.5 provides broader capability without the coding specialization for reasoning or conversation
- **Vision-enabled coding:** GLM-4.6V combines vision input with coding capability for code-from-screenshot workflows
- **Faster inference priority:** GLM-4.6V-Flash offers vision and coding at reduced latency when speed matters more than depth
- **Advanced coding improvements:** GLM-4.7 includes further advancements in tool usage and multi-step reasoning for complex agentic tasks

## Frequently asked questions

### What makes GLM 4.6 different from GLM-4.5?

GLM 4.6 is specifically optimized for coding tasks with an expanded context window of 204.8K tokens and targeted improvements in programming benchmark and real-world coding performance. GLM-4.5 is the general-purpose model.

### What is the context window for GLM 4.6?

204.8K tokens, designed to handle large codebases, long specification documents, and multi-file analysis in a single request.

### Can GLM 4.6 handle multi-file code analysis?

Yes. The expanded context window lets you include multiple files in a single request, enabling the model to understand cross-file dependencies, imports, and architectural patterns.

### How do I authenticate with GLM 4.6 through AI Gateway?

AI Gateway provides a unified API key. Configure it in your environment and specify the model identifier. No separate Z.AI account is required, though BYOK is supported.

### How does GLM 4.6 compare to GLM-4.7 for coding?

GLM 4.6 introduced the coding-focused improvements in the GLM lineup. GLM-4.7 adds further gains in tool usage, multi-step reasoning, and frontend development, per Z.AI's release notes.

### Is GLM 4.6 suitable for non-coding tasks?

GLM 4.6 retains general language capability but is optimized for code. For conversational, reasoning, or general-purpose tasks, GLM-4.5 or GLM-5 may be more appropriate.

### What is the pricing for GLM 4.6?

Pricing appears on this page and updates as providers adjust their rates. AI Gateway routes traffic through the configured provider.

## Links

- [Model page](https://vercel.com/ai-gateway/models/glm-4.6)
- [AI Gateway documentation](https://vercel.com/docs/ai-gateway)
- [Provider model documentation](https://z.ai/blog/glm-4.6)
- [Provider pricing](https://docs.z.ai/guides/overview/pricing)


If you encounter incorrect information, can’t find what you need, need a capability Vercel doesn’t currently offer, or have any other feedback to report, please do it by following the instructions at https://vercel.com/feedback.md.
