# GLM 5

Z.AI's GLM-5 generation model with multiple thinking modes, improved long-range planning, and added focus on agentic coding and structured data extraction.

- **Model ID:** `zai/glm-5`
- **Type:** chat
- **Providers:** zai, deepinfra, bedrock, novita
- **Context window:** 202,800
- **Maximum output tokens:** 131,100
- **Pricing:** $0.8/1M input tokens, $2.56/1M output tokens
- **Canonical page:** https://vercel.com/ai-gateway/models/glm-5

## Supported parameters

Detailed capability metadata has not been reported for this model.

## Example

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

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

## About

GLM 5 was released February 12, 2026 as Z.AI's GLM-5 generation model, introducing multiple thinking modes and enhanced long-range planning. It builds on the GLM-4.x family, with added focus on agentic coding, autonomous tool use, and complex multi-step workflows.

The multiple thinking modes let you control how the model approaches problems. Different modes optimize for different task profiles: quick direct responses, structured reasoning, or deep deliberation with extended chain-of-thought. This flexibility is valuable in agentic architectures where different pipeline steps have different reasoning requirements, all served by a single model.

GLM 5 demonstrates improved long-range planning and memory, enabling it to maintain coherence across extended interactions and complex task sequences. Z.AI highlights structured extraction from documents like contracts and financial reports, and agentic coding workflows where the model autonomously plans, writes, tests, and iterates on code. Through AI Gateway, GLM 5 is available with unified API access, built-in observability, and intelligent provider routing.

## What to consider

GLM 5 supports multiple thinking modes. Experiment with different modes on your specific tasks to find the right balance between reasoning depth and response speed.

The combination of long-range planning, autonomous tool use, and multiple thinking modes makes GLM 5 well-suited as the central model in agentic pipelines. Design your tool schemas to leverage these capabilities.

For structured data extraction from contracts and financial reports, benchmark GLM 5 against general-purpose alternatives on your document types.

## When to use

### Best For

- **Complex agentic workflows** requiring multi-step planning, autonomous tool use, and sustained reasoning across extended task sequences
- **Agentic coding** where the model autonomously plans, writes, tests, and iterates on code with minimal human intervention
- **Structured data extraction** from contracts, financial reports, and complex documents where precision matters
- **Workflow automation** leveraging improved long-range planning and memory for multi-phase processes
- **Applications requiring flexible reasoning** where multiple thinking modes let you optimize the accuracy-latency tradeoff per request

### Consider Alternatives When

- Speed and cost efficiency are the primary constraints. GLM-4.7-Flash or GLM-4.7-FlashX provides faster inference for less demanding tasks
- Vision and multimodal input is required. GLM-4.6V or GLM-4.5V provides visual understanding capabilities
- Your workload is straightforward generation or classification. Earlier GLM models may be more cost-effective for simple tasks
- Frontend-specific code generation is the main use case. GLM-4.7's targeted frontend improvements may be sufficient at lower cost

## Best for

- **Complex agentic workflows:** Multi-step planning, autonomous tool use, and sustained reasoning across extended task sequences
- **Agentic coding:** The model autonomously plans, writes, tests, and iterates on code with minimal human intervention
- **Structured data extraction:** Contracts, financial reports, and complex documents where precision matters
- **Workflow automation:** Improved long-range planning and memory support multi-phase processes
- **Applications requiring flexible reasoning:** Multiple thinking modes let you optimize the accuracy-latency tradeoff per request

## Consider alternatives

- **Speed and cost priority:** GLM-4.7-Flash or GLM-4.7-FlashX provides faster inference for less demanding tasks
- **Vision and multimodal input:** GLM-4.6V or GLM-4.5V provides visual understanding capabilities
- **Simple generation or classification:** Earlier GLM models may be more cost-effective for straightforward tasks
- **Frontend-specific code generation:** GLM-4.7's targeted frontend improvements may be sufficient at lower cost

## Frequently asked questions

### What are the multiple thinking modes in GLM 5?

GLM 5 supports different thinking modes that optimize for different task profiles, from quick direct responses to deep deliberation with extended chain-of-thought reasoning. This lets you control the accuracy-latency tradeoff per request.

### How does GLM 5 compare to GLM-4.7?

GLM 5 adds multiple thinking modes, improved long-range planning and memory, and expanded agentic features compared with GLM-4.7. GLM-4.7 can still fit coding and frontend tasks when you want lower cost.

### What makes GLM 5 good at document extraction?

Z.AI cites structured extraction from contracts, financial reports, and other complex documents. Improved planning and reasoning help with multi-section files, cross-references, and complex formatting.

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

202.8K tokens.

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

AI Gateway provides a unified API key. No separate Z.AI account is needed. Use the model identifier to route requests. BYOK is also supported for direct provider access.

### Is GLM 5 suitable for autonomous coding?

Yes. GLM 5 handles agentic coding where it autonomously plans, writes, tests, and iterates on code. The improved long-range planning helps maintain coherence across complex, multi-file coding tasks.

### What is the pricing for GLM 5?

Rates are listed on this page. They reflect the providers routing through AI Gateway and shift when providers update their pricing.

## Links

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