Skip to content
Connect a clientZCode

ZCode

Z.ai desktop agent: the Guard address and key go into the settings window, no files to edit.

Set up with your own AI
Model protocol

Claude, Kimi, Composer and Grok

ZCode is the desktop agent app from Z.ai for macOS, Windows and Linux (download page). A third-party provider is added right in the settings: name, address, key and a model list. Guard connects as one provider for every family at once.

  1. Open Settings (the button in the lower-left corner), then Model settings, Add provider, Custom endpoint.
  2. Name: Guard AI.
  3. Base URL: https://api.guardrelay.ai (without /v1: ZCode appends the /v1/messages path itself).
  4. API key: your gd-… key from the bot.
  5. API format: Anthropic messages (/v1/messages).
  6. Add model: enter the Model ID from the list below and the context window; under Advanced set Max output tokens: 128000 for Claude Fable 5, Fable 5.1, Opus 5.5, Opus 5, Opus 4.8, Opus 4.7, Opus 4.6, Sonnet 5.5, Sonnet 5, Sonnet 4.6 and Haiku 5.5; 64000 for Claude Opus 4.5, Sonnet 4.5 and Haiku 4.5; 128000 for Grok; 32000 for Composer; leave the field empty for Kimi. Repeat for every model you need.
  7. Click Add provider, switch the provider on and pick a model in the chat.

Type the model id exactly as listed: ZCode sends it to the server unchanged. The context window is the budget the client uses for the chat history. Max output tokens is the limit for one response. Guard serves it up to the model limit; if the key balance cannot cover the reserve for such a response with room for 8 more regular requests, Claude and Grok answer within 32,000. Kimi receives the value as is, and with an empty field ZCode itself sends 32,000. ZCode subtracts this limit from the context window, so a larger limit compacts the history earlier.

Model IDContext window
claude-sonnet-5-51M
claude-sonnet-51M
claude-opus-5-51M
claude-opus-51M
claude-fable-5-11M
claude-fable-51M
claude-opus-4-81M
claude-opus-4-71M
claude-opus-4-61M
claude-opus-4-5200K
claude-sonnet-4-61M
claude-sonnet-4-5200K
claude-haiku-5-51M
claude-haiku-4-5200K
Model IDContext window
k31M
k3-256k256K
kimi-for-coding1M
kimi-for-coding-highspeed256K
Model IDContext window
cursor-grok-4.7-low, cursor-grok-4.7-medium, cursor-grok-4.7-high, cursor-grok-4.7-xhigh256K
cursor-grok-4.7-low-fast, cursor-grok-4.7-medium-fast, cursor-grok-4.7-high-fast, cursor-grok-4.7-xhigh-fast256K · Fast
cursor-grok-4.6-low, cursor-grok-4.6-medium, cursor-grok-4.6-high, cursor-grok-4.6-xhigh500K
cursor-grok-4.6-low-fast, cursor-grok-4.6-medium-fast, cursor-grok-4.6-high-fast, cursor-grok-4.6-xhigh-fast500K
Model IDContext window
composer-2.5200K
composer-2.5-fast200K

Context window takes a number: Claude 1M is 1000000, Kimi K3 and K2.8 Preview (kimi-for-coding) use 1048576, K3-256K and K2.7 Code HighSpeed use 262144, Grok 4.7 uses 256000, while Grok 4.6 uses 500000, and Composer or 200K Claude models use 200000.

Context mode for Composer

For composer-2.5 and composer-2.5-fast, you can enable a separate context counter mode. ZCode receives an estimate of the current history and visible response: accumulated usage across the whole run is no longer used as the size of a single context window.

  1. In Settings → Model settings, open your existing Guard provider using the Anthropic messages format.
  2. Change only Base URL to https://api.guardrelay.ai/zcode and save. Keep your existing key and selected model; ZCode appends /v1/messages itself.
  3. To restore regular token usage in API responses, change Base URL back to https://api.guardrelay.ai.

Charges and prices stay the same: your Guard account records actual usage. The ZCode context counter in this mode is an estimate and should not be used to calculate request cost.

For integrations: requests go to POST /zcode/v1/messages. usage_source is context_estimate, and usage contains the estimate. In a completed response, billing_usage contains actual aggregate usage for the run, matching usage on the regular endpoint. While waiting for a client tool result or before confirmed completion, billing_usage is null.

Prices and details for every model are on the Models page. For Grok the reasoning level is chosen by the model name (low, medium, high, xhigh); Composer has no reasoning: the ZCode reasoning switch does not affect these models.

The reasoning mode ZCode enables by default is adjusted by Guard to what each model accepts: Sonnet 5.5, Opus 5.5 and Fable 5.1 always reason adaptively, enabled reasoning on Haiku 5.5 becomes adaptive, and the effort level is not applied on Haiku 4.5 and Sonnet 4.5. Kimi takes the ZCode reasoning parameters as is.

To receive an image created by Grok or Composer, ask the model to save it in the working folder. Supported images are delivered at the end of the reply as a download link valid for 24 hours, accessible without a key. Automatically created assets without that save step are not delivered. This delivers images, not arbitrary files. There is no separate file fee; request tokens are billed.

GLM 5.3 in ZCode

Install and open ZCode

Install ZCode from the official page. Open a separate test folder without secrets, then go to Settings → Model settings.

Get a Guard key

Get a universal gd-… key from the direct API link in @guardapi and choose an API package. Do not put the key in a project, repository, task prompt, or screenshot. Balance and usage are available in your Guard account.

Create a custom provider

  1. Select Add provider → Create custom provider. In ZCode 3.14.3 the new entry may be named New provider.
  2. Set Base URL to https://api.guardrelay.ai/glm/v1, choose Responses (/responses) under API format, and enter the gd-… key under API key.
  3. Select Add model, keep Smart configuration enabled, and enter Model ID glm-5.3.
  4. Leave Context window and Max output tokens blank: the verified configuration did not set an assumed numeric limit. Save the model and provider.
  5. Repeat Add model for glm-5.3-flash if needed.
ZCode fieldValue
ProviderNew provider
Base URLhttps://api.guardrelay.ai/glm/v1
API formatResponses (/responses)
API keygd-…
Model IDglm-5.3
Smart configurationenabled
Context window / Max output tokensleave blank
Final requestPOST https://api.guardrelay.ai/glm/v1/responses

Quick check and continuation

  1. Select glm-5.3 in a new conversation and open a separate test folder containing README.md.
  2. Send: Read README.md and reply with exactly GUARD_GLM_OK. Change nothing.
  3. In the same chat, ask for the line without reopening the file. Use a new chat only for a separate task.

Models and confirmed capabilities

Model IDWhen to use it
glm-5.3Default model; text and coding tasks.
glm-5.3-flashFast model; at API level it accepts PNG and PDF through all three protocols, and MP4 through Chat Completions only.
  • Responses, local Read/Edit/Bash tools, and continuation of the same ZCode chat are confirmed.
  • The client itself executes file, edit, and terminal tools. This profile does not connect Z.AI tools or MCP automatically.
  • This version was checked with text tasks; its attachment button was not checked. Flash capability at API level does not prove that this particular UI can send a file.
  • The profile uses OpenAI Responses. The GLM server prompt is off by default for ordinary API access; client setup does not enable it.
  • Native TXT, DOCX, and XLSX are outside the confirmed GLM contract. Use PDF for documents, or PNG with glm-5.3-flash for images.

If the connection fails

SymptomWhat to check
401 invalid_api_keyThe client received the complete active gd-… key; the variable is set in the same process that starts the client.
404 model_not_foundThe model ID is exactly glm-5.3 or glm-5.3-flash; old GLM IDs, aliases, Turbo, and FlashX are unsupported.
404 or incorrect pathBase URL is https://api.guardrelay.ai/glm/v1. The client appends /responses; do not add it twice.
400 invalid_requestThe documented API format is selected; reasoning, temperature, MCP, or other unconfirmed fields were not copied from an older profile.
402 insufficient_balanceCheck available balance and unfinished reservations in your Guard account.
The Add provider UI looks differentCheck version 3.14.3. Its path is Add provider → Create custom provider; do not reuse 3.9.1 steps.
404 after savingResponses (/responses) is selected, Base URL does not contain /responses, Smart configuration is enabled, and Model ID is exact.

Gemini in ZCode

Install and open ZCode

Install ZCode from the official page. Open a separate test folder without secrets, then go to Settings → Model settings.

Get a Guard key

Get a universal gd-… key from the direct API link in @guardapi and choose an API package. Do not put the key in a project, repository, task prompt, or screenshot. Balance and usage are available in your Guard account.

Create a custom provider

  1. Select Add provider → Create custom provider. The new entry may be named New provider.
  2. Set Base URL to https://api.guardrelay.ai/v1, choose Responses (/responses) under API format, and enter the gd-… key under API key.
  3. Select Add model, keep Smart configuration enabled, and enter Model ID gemini-4-argon.
  4. Leave Context window and Max output tokens blank: ZCode itself chooses the numeric limits. Save the model and provider.
  5. Repeat Add model for the other IDs from the table below if needed.
ZCode fieldValue
ProviderNew provider
Base URLhttps://api.guardrelay.ai/v1
API formatResponses (/responses)
API keygd-…
Model IDgemini-4-argon
Smart configurationenabled
Context window / Max output tokensleave blank
Final requestPOST https://api.guardrelay.ai/v1/responses

Quick check and continuation

  1. Select gemini-4-argon in a new conversation and open a separate test folder containing README.md.
  2. Send: Read README.md and reply with exactly GUARD_GEMINI_OK. Change nothing.
  3. In the same chat, ask for the line without reopening the file. Use a new chat only for a separate task.

Gemini models and capabilities

Model IDInput and window
gemini-4-argonText, images, PDF; 1,048,576-token window, shared by input and answer.
gemini-3.8-flashText, images, PDF; 1,048,576-token window for input.
  • ZCode itself executes the local read, edit, and command tools; the conversation continues in the same chat.
  • The Guard catalog takes text, images, and PDF as input and returns text. How to send a file or an image depends on the client's interface; this guide does not describe attachments.
  • The profile uses OpenAI Responses. The server prompt is a separate setting of the Gemini family: it applies only when the key has the entitlement and the option is on; client setup does not enable it.

If the connection fails

SymptomWhat to check
401 invalid_api_keyThe client received the complete active gd-… key; the variable is set in the same process that starts the client.
404 model_not_foundThe model ID is an exact ID from the table above or the short name gemini; other spellings are unsupported.
404 or incorrect pathBase URL is https://api.guardrelay.ai/v1. The client appends /responses; do not add it twice.
400 invalid_requestThe documented API format is selected; extra settings from an older profile were not copied: reasoning, temperature, MCP, and others.
402 insufficient_creditCheck available balance and unfinished reservations in your Guard account.
The Add provider UI looks differentThe steps above follow Add provider → Create custom provider. If your ZCode version names things differently, find the same fields in it: Base URL, API format, API key, and Model ID.
404 after savingResponses (/responses) is selected, Base URL does not contain /responses, Smart configuration is enabled, and Model ID is exact.

Muse in ZCode

Install and open ZCode

Install ZCode from the official page. Open a separate test folder without secrets, then go to Settings → Model settings.

Get a Guard key

Get a universal gd-… key from the direct API link in @guardapi and choose an API package. Do not put the key in a project, repository, task prompt, or screenshot. Balance and usage are available in your Guard account.

Create a custom provider

  1. Select Add provider → Create custom provider. The new entry may be named New provider.
  2. Set Base URL to https://api.guardrelay.ai/v1, choose Responses (/responses) under API format, and enter the gd-… key under API key.
  3. Select Add model, keep Smart configuration enabled, and enter Model ID muse-wonder-1.0.
  4. Leave Context window and Max output tokens blank: ZCode itself chooses the numeric limits. Save the model and provider.
  5. Repeat Add model for the other IDs from the table below if needed.
ZCode fieldValue
ProviderNew provider
Base URLhttps://api.guardrelay.ai/v1
API formatResponses (/responses)
API keygd-…
Model IDmuse-wonder-1.0
Smart configurationenabled
Context window / Max output tokensleave blank
Final requestPOST https://api.guardrelay.ai/v1/responses

Quick check and continuation

  1. Select muse-wonder-1.0 in a new conversation and open a separate test folder containing README.md.
  2. Send: Read README.md and reply with exactly GUARD_MUSE_OK. Change nothing.
  3. In the same chat, ask for the line without reopening the file. Use a new chat only for a separate task.

Muse models and capabilities

Model IDInput and window
muse-wonder-1.0Text, images, PDF; 1,048,576-token window.
muse-spark-1.3Text, images, PDF; 1,048,576-token window.
muse-spark-1.2Text, images, PDF; 1,048,576-token window.
  • ZCode itself executes the local read, edit, and command tools; the conversation continues in the same chat.
  • The Guard catalog takes text, images, and PDF as input and returns text. How to send a file or an image depends on the client's interface; this guide does not describe attachments.
  • The profile uses OpenAI Responses. The server prompt is a separate setting of the Muse family: it applies only when the key has the entitlement and the option is on; client setup does not enable it.

If the connection fails

SymptomWhat to check
401 invalid_api_keyThe client received the complete active gd-… key; the variable is set in the same process that starts the client.
404 model_not_foundThe model ID is an exact ID from the table above or the short name muse; other spellings are unsupported.
404 or incorrect pathBase URL is https://api.guardrelay.ai/v1. The client appends /responses; do not add it twice.
400 invalid_requestThe documented API format is selected; extra settings from an older profile were not copied: reasoning, temperature, MCP, and others.
402 insufficient_creditCheck available balance and unfinished reservations in your Guard account.
The Add provider UI looks differentThe steps above follow Add provider → Create custom provider. If your ZCode version names things differently, find the same fields in it: Base URL, API format, API key, and Model ID.
404 after savingResponses (/responses) is selected, Base URL does not contain /responses, Smart configuration is enabled, and Model ID is exact.

Codex in ZCode

For ZCode 3.9.1.5853, use a separate OpenAI Responses provider with exact gpt-6-astra. Get your gd-… key from the Guard bot. This guide covers Responses/Astra only; it does not confirm Chat, other models, or other ZCode versions.

For a connection check, use a plain chat without files and ask “Reply: connection established”. To check project work, create a separate guard-test folder in File Explorer or Finder, open it in your editor, and create README.md containing “This is a Guard test project”. The file-reading example below uses that folder.

1. Add the address and key

  1. Open Settings → Model settings. If settings are closed, select the model name by the chat input and choose Manage Models.
  2. Select Add provider → Custom endpoint. Do not edit an existing provider for Claude, Kimi, GLM, Gemini, Muse, Composer, or Grok.
  3. Set Name to GUARD API · Codex.
  4. Paste https://api.guardrelay.ai/codex/v1 into Base URL.
  5. Paste your gd-… key from the bot into API key; never put the key in a project file or chat message.
  6. Choose Responses (/responses) under API format and save the provider.

2. Add a GPT model

  1. Open the new provider and select Add model. If this button appears before saving the provider, add the model in the same form.
  2. Enter the exact gpt-6-astra value in Model ID and choose OpenAI Responses for it. See Models for other IDs and effort levels.
  3. If ZCode shows Thought Level, choose Low for this Astra profile; do not append effort to the Model ID.
  4. Set Context window to 272000. Under Advanced → Max output tokens, set 128000: Guard preserves max_output_tokens as advisory for managed Codex without promising hard response truncation.
  5. Save the model and enable the provider toggle.
Model IDContext window for ZCode
gpt-6-astra272000
gpt-6.1-sol872000
gpt-6-sol872000
gpt-6-luna872000
gpt-5.6-sol872000
gpt-5.6-terra872000
gpt-5.6-luna872000

Use 272000 for the proved Astra profile. The other rows are catalog budgets for client setup only and do not verify those models in ZCode. ZCode may compact history earlier; Context window does not set a one-response limit.

ZCode fieldValue
Base URLhttps://api.guardrelay.ai/codex/v1
API formatResponses (/responses)
Model IDgpt-6-astra
Model API formatOpenAI Responses
Context window272000
Max output tokens128000 · advisory
Final requestPOST https://api.guardrelay.ai/codex/v1/responses

Choose a reasoning level only if ZCode shows Thought Level for the selected model. Check the allowed values under Models; do not add an effort suffix to the Model ID or substitute another model. If there is no selector, leave the default setting.

3. First reply and follow-up

  1. Choose a test workspace without keys or personal data and with a README.md. In a new chat, keep Ask before changes, select the model name beside the input, and choose GUARD API · Codex → gpt-6-astra.
  2. Send: Read README.md and explain in two sentences what this test project does. Do not change anything. If ZCode asks for permission, allow only a read of that file.
  3. After the reply, send in the same chat: Name one fact from README.md that supports your explanation. Start a new chat for a different task.

After checking file reading, you can request a change: “Add a Test section and one descriptive line to README.md.” Review the proposed edit and approve it if it matches your task. Command, file and tool permissions are controlled by the client; connecting Guard does not require granting unrestricted access to your whole computer.

Sections

On this page