[Integrations](https://spiral.ai/integrations) › [opencode](https://spiral.ai/integrations/opencode) › [GLM-4.6](https://spiral.ai/integrations/opencode/glm-4-6)

# How to Use GLM-4.6 in opencode

GLM-4.6 suits code changes, front-end development, and research that uses tools. Its 200K-token context supports long text tasks, while Z.ai reports that its coding ability trails Claude Sonnet 4.5.

|  |  |
| --- | --- |
| Model | GLM-4.6 |
| Available through | OpenRouter |
| Category | LLM |
| Price | Up to $0.010673 per run at the default inputs. $0.65 per 1M input tokens, $2.60 per 1M output tokens. |
| Returns | text, json |
| Runs | In the background |
| Setup | About 2 minutes, no API key |

## Prompts to try with GLM-4.6 in opencode

- Use GLM-4.6 to inspect the failing tests and relevant project files, identify the cause, and make the smallest patch that restores the expected behavior. Run the relevant tests and report the results.
- Use GLM-4.6 to build a settings page using this project's existing components. Include narrow-screen behavior, validation messages, and loading states, then check each control.
- Use GLM-4.6 to compare the API specification with its implementation. List mismatches with file references, then fix the mismatch with the clearest reproduction.
- Use GLM-4.6 to review the current diff for behavior changes. Explain each concrete issue with a failing example and propose a regression test.
- Use GLM-4.6 to implement a CSV validation utility in the project's language. Reject malformed rows with useful errors, and check quoted commas, missing values, and duplicate headers.

## How to set up GLM-4.6 in opencode

Pick the way that suits you. Each takes about two minutes.

### Use Spiral's MCP server

1. **Add the server**: Leave out `--global` to add Spiral to the current project only. No header and no client ID or secret: opencode registers itself with Spiral.

```bash
opencode mcp add spiral --global --url https://api.spiral.ai/mcp
```

2. **Sign in**: Your browser opens. Sign in to Spiral, pick the organization and click Authorize, then return to the terminal. No API key. Inside opencode, `/mcps` starts the same sign-in.

```bash
opencode mcp auth spiral
```

3. **Check it**: Spiral shows as connected.

```bash
opencode mcp list
```

### Use the Spiral skill

1. **Send opencode this message**: Your agent reads Spiral's skill and sets itself up.

```
set up https://spiral.ai/SKILL.md
```

2. **Sign in or paste a key**: Approve Spiral in the browser, or give the agent a key from the console.

### Use the Spiral CLI

1. **Install and sign in**: Installs the Spiral CLI, signs you in and adds its skill to your coding agents.

```bash
npx -y spiral-cli@latest init
```

### Call the Spiral API

1. **Create an API key**: In the console, under API keys.

2. **Run GLM-4.6**: One request; the result comes back by polling or a webhook.

```bash
curl https://api.spiral.ai/v1/runs \
  -H "Authorization: Bearer $SPIRAL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "provider": "openrouter",
    "model": "z-ai/glm-4.6",
    "input": {
      "messages": [
        {
          "role": "system"
        }
      ]
    }
  }'
```

Then paste one of the prompts above: opencode finds GLM-4.6 on Spiral, shows the price and runs it.

Setup guide in the docs: https://spiral.ai/docs/quickstarts/opencode

## GLM-4.6 tools and prices

- [Z.ai: GLM 4.6](https://spiral.ai/tools/openrouter/z-ai/glm-4.6) (OpenRouter): Up to $0.010673 per run at the default inputs. $0.65 per 1M input tokens, $2.60 per 1M output tokens.

## Settings you can ask for

| Setting | Allowed values | Default | Description |
| --- | --- | --- | --- |
| seed |  | — |  |
| stop |  | — |  |
| min_p | 0 to 1 | — |  |
| tools |  | — |  |
| top_k | 0 to … | — |  |
| top_p | 0 to 1 | — |  |

## What can you do with GLM-4.6 in opencode?

Turn a written requirement into code changes and a verification plan with GLM-4.6. Supply the relevant project files, expected behavior, and acceptance criteria.

### Repair a failing feature

Give GLM-4.6 the relevant code, error output, and expected behavior. Ask for a focused patch and a regression check.

### Build a front-end from a written brief

Ask GLM-4.6 to turn layout requirements into interface code, including narrow-screen behavior, empty states, and error messages.

### Compare long specifications

Supply labeled specification text and ask GLM-4.6 for conflicting requirements, missing decisions, and supporting section references.

### Prepare a research brief

Have GLM-4.6 use available search tools to investigate a narrow question, compare sources, and separate supported conclusions from open questions.

### Edit customer-facing copy

Give GLM-4.6 a draft, audience, and tone guide. Request a clearer version that preserves the supplied claims and removes repetition.

### Translate product descriptions

Ask GLM-4.6 for French, Russian, Japanese, or Korean product copy using a supplied glossary, with product names and measurements preserved.

### Draft a recurring change digest

Have GLM-4.6 compare retrieved release-note text with the previous digest and explain changes, affected users, and unresolved questions.

## Overview

- [OpenRouter](https://spiral.ai/providers/openrouter)
- [All opencode guides](https://spiral.ai/integrations/opencode)

## GLM-4.6 in other agents

- [Amp](https://spiral.ai/integrations/amp/glm-4-6)
- [ChatGPT](https://spiral.ai/integrations/chatgpt/glm-4-6)
- [Claude](https://spiral.ai/integrations/claude-desktop/glm-4-6)
- [Claude Code](https://spiral.ai/integrations/claude-code/glm-4-6)
- [Cline](https://spiral.ai/integrations/cline/glm-4-6)
- [Codex](https://spiral.ai/integrations/codex/glm-4-6)
- [Cursor](https://spiral.ai/integrations/cursor/glm-4-6)
- [Devin](https://spiral.ai/integrations/devin/glm-4-6)
- [dots](https://spiral.ai/integrations/dots/glm-4-6)
- [Factory Droid](https://spiral.ai/integrations/factory-droid/glm-4-6)
- [Gemini](https://spiral.ai/integrations/gemini/glm-4-6)
- [Gemini CLI](https://spiral.ai/integrations/gemini-cli/glm-4-6)
- [Google Antigravity](https://spiral.ai/integrations/antigravity/glm-4-6)
- [goose](https://spiral.ai/integrations/goose/glm-4-6)
- [Grok](https://spiral.ai/integrations/grok/glm-4-6)
- [Grok Build](https://spiral.ai/integrations/grok-build/glm-4-6)
- [Hermes](https://spiral.ai/integrations/hermes/glm-4-6)
- [Instinct](https://spiral.ai/integrations/instinct/glm-4-6)
- [Manus](https://spiral.ai/integrations/manus/glm-4-6)
- [Muse](https://spiral.ai/integrations/muse/glm-4-6)
- [Muse Code](https://spiral.ai/integrations/muse-code/glm-4-6)
- [n8n](https://spiral.ai/integrations/n8n/glm-4-6)
- [Notion](https://spiral.ai/integrations/notion/glm-4-6)
- [OpenClaw](https://spiral.ai/integrations/openclaw/glm-4-6)
- [Perplexity](https://spiral.ai/integrations/perplexity/glm-4-6)
- [Raycast](https://spiral.ai/integrations/raycast/glm-4-6)
- [VS Code](https://spiral.ai/integrations/vscode/glm-4-6)
- [Windsurf](https://spiral.ai/integrations/windsurf/glm-4-6)
- [Zapier](https://spiral.ai/integrations/zapier/glm-4-6)

## More opencode guides

- [GLM-4.5V](https://spiral.ai/integrations/opencode/glm-4-5v)
- [GLM-4.6V](https://spiral.ai/integrations/opencode/glm-4-6v)
- [GLM-4.5](https://spiral.ai/integrations/opencode/glm-4-5)
- [GLM-4.7](https://spiral.ai/integrations/opencode/glm-4-7)
- [GLM Latest](https://spiral.ai/integrations/opencode/glm-latest)
- [GLM-5](https://spiral.ai/integrations/opencode/glm-5)

## Questions about GLM-4.6 in opencode

**Can opencode use GLM-4.6?**

Yes. Add Spiral to opencode as an MCP server, and opencode can find and run GLM-4.6 like any built-in tool.

**How much does GLM-4.6 cost in opencode?**

Up to $0.010673 per run at the default inputs. $0.65 per 1M input tokens, $2.60 per 1M output tokens. You pay from your Spiral balance as you go, with no subscription, and a failed run is not charged. Your opencode plan is separate.

**Do I need an OpenRouter account to use GLM-4.6 in opencode?**

No. Spiral runs GLM-4.6 on its own OpenRouter account. You sign in to Spiral once and never paste a key.

**How long does it take to set up GLM-4.6 in opencode?**

About two minutes: add the server, then sign in, then check it.

**Does opencode wait while GLM-4.6 runs?**

GLM-4.6 runs in the background. opencode starts the run, checks on it and gives you the text, json when it's ready.

**What is GLM-4.6 useful for?**

Use GLM-4.6 for code changes, front-end development, and research that combines reasoning with tools. Give it a concrete deliverable and acceptance criteria.

**How much text can GLM-4.6 handle?**

Z.ai documents a 200K-token context window and a maximum output of 128K tokens. Treat those as ceilings and request only the output your task needs.

**Can GLM-4.6 read screenshots or generate images?**

GLM-4.6 has text input and text output. For a visual debugging task, supply the code, error text, and a written description of the problem.

**Which settings should I try for coding?**

Z.ai recommends top_p of 0.95 and top_k of 40 for code evaluations such as LiveCodeBench. Use those as a starting point and compare results on your own tasks.

**Which translation languages have documented improvements?**

Z.ai specifically names French, Russian, Japanese, and Korean. Include the target audience, tone, and a glossary when requesting a translation.

