| [ Web Proxy ] |
| Viewing: https://developers.cloudflare.com/workers-ai/models/glm-5.2/ | [Back] [Original] |
@cf/zai-org/glm-5.2Z.ai's flagship agentic coding model
Paid access required
This model is not available through standard Workers Free billing. To use it, upgrade to the Workers Paid plan or use prepaid AI Gateway credits.
| Model Info | |
|---|---|
| Context Window | 262,144 tokens |
| Function calling | Yes |
| Reasoning | Yes |
| Unit Pricing | $1.40 per M input tokens, $4.40 per M output tokens, $0.26 per M cached input tokens |
Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.
Launch the LLM Playground
export interface Env {
AI: Ai;
}
export default {
async fetch(request, env): Promise<Response> {
const messages = [
{ role: "system", content: "You are a friendly assistant" },
{
role: "user",
content: "What is the origin of the phrase Hello, World",
},
];
const stream = await env.AI.run("@cf/zai-org/glm-5.2", {
messages,
stream: true,
});
return new Response(stream, {
headers: { "content-type": "text/event-stream" },
});
},
} satisfies ExportedHandler<Env>;
export interface Env {
AI: Ai;
}
export default {
async fetch(request, env): Promise<Response> {
const messages = [
{ role: "system", content: "You are a friendly assistant" },
{
role: "user",
content: "What is the origin of the phrase Hello, World",
},
];
const response = await env.AI.run("@cf/zai-org/glm-5.2", { messages });
return Response.json(response);
},
} satisfies ExportedHandler<Env>;
import os
import requests
ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")
prompt = "Tell me all about PEP-8"
response = requests.post(
f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/zai-org/glm-5.2",
headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
json={
"messages": [
{"role": "system", "content": "You are a friendly assistant"},
{"role": "user", "content": prompt}
]
}
)
result = response.json()
print(result)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/zai-org/glm-5.2 \
-X POST \
-H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
-d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'OpenAI compatible endpoints
/v1/chat/completions and /v1/embeddings. For more details, refer to Configurations.Simple text input for single-turn interactions
MessagesStructured conversation format with roles (user, assistant, system)
stringrequiredminLength: 1The input text prompt for the model to generate a response.stringID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').objectParameters for audio output. Required when modalities includes 'audio'.number | nullPenalizes new tokens based on their existing frequency in the text so far.object | nullModify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.boolean | nullWhether to return log probabilities of the output tokens.integer | nullHow many top log probabilities to return at each token position (0-20). Requires logprobs=true.integer | nullDeprecated in favor of max_completion_tokens. The maximum number of tokens to generate.integer | nullAn upper bound for the number of tokens that can be generated for a completion.object | nullSet of 16 key-value pairs that can be attached to the object.array | nullOutput types requested from the model (e.g. ['text'] or ['text', 'audio']).integer | nullHow many chat completion choices to generate for each input message.booleandefault: trueWhether to enable parallel function calling during tool use.objectnumber | nullPenalizes new tokens based on whether they appear in the text so far.string | nullConstrains effort on reasoning for reasoning models (o1, o3-mini, etc.).objectone ofSpecifies the format the model must output.integer | nullIf specified, the system will make a best effort to sample deterministically.string | nullSpecifies the processing type used for serving the request.one ofboolean | nullWhether to store the output for model distillation / evals.boolean | nullIf true, partial message deltas will be sent as server-sent events.objectnumber | nullSampling temperature between 0 and 2.one ofControls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.arrayA list of tools the model may call.number | nullNucleus sampling: considers the results of the tokens with top_p probability mass.stringA unique identifier representing your end-user, for abuse monitoring.objectOptions for the web search tool (when using built-in web search).one ofarrayminItems: 1maxItems: 128stringA unique identifier for the chat completion.stringintegerUnix timestamp (seconds) of when the completion was created.stringThe model used for the chat completion.arrayminItems: 1objectstring | nullstring | nullSimple text input for single-turn interactions
MessagesStructured conversation format with roles (user, assistant, system)
stringrequiredminLength: 1The input text prompt for the model to generate a response.stringID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').objectParameters for audio output. Required when modalities includes 'audio'.number | nullPenalizes new tokens based on their existing frequency in the text so far.object | nullModify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.boolean | nullWhether to return log probabilities of the output tokens.integer | nullHow many top log probabilities to return at each token position (0-20). Requires logprobs=true.integer | nullDeprecated in favor of max_completion_tokens. The maximum number of tokens to generate.integer | nullAn upper bound for the number of tokens that can be generated for a completion.object | nullSet of 16 key-value pairs that can be attached to the object.array | nullOutput types requested from the model (e.g. ['text'] or ['text', 'audio']).integer | nullHow many chat completion choices to generate for each input message.booleandefault: trueWhether to enable parallel function calling during tool use.objectnumber | nullPenalizes new tokens based on whether they appear in the text so far.string | nullConstrains effort on reasoning for reasoning models (o1, o3-mini, etc.).objectone ofSpecifies the format the model must output.integer | nullIf specified, the system will make a best effort to sample deterministically.string | nullSpecifies the processing type used for serving the request.one ofboolean | nullWhether to store the output for model distillation / evals.boolean | nullIf true, partial message deltas will be sent as server-sent events.objectnumber | nullSampling temperature between 0 and 2.one ofControls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.arrayA list of tools the model may call.number | nullNucleus sampling: considers the results of the tokens with top_p probability mass.stringA unique identifier representing your end-user, for abuse monitoring.objectOptions for the web search tool (when using built-in web search).one ofarrayminItems: 1maxItems: 128stringtext/event-streambinaryarraystringA unique identifier for the chat completion.stringintegerUnix timestamp (seconds) of when the completion was created.stringThe model used for the chat completion.arrayminItems: 1objectstring | nullstring | nullWas this helpful?
| Web Proxy Viewer | New URL | Original Page |