
Tutorial
Himi LiProduct Manager at EvoLink7 min read
How to Use GLM-5.4: From Your First API Call to a Screenshot-Driven Fix
Call GLM-5.4 through EvoLink, send a screenshot with its HTML and CSS, and verify a mobile checkout fix in the browser.
On this page
GLM-5.4 is available through EvoLink’s Chat Completions API as
glm-5.4. Make a short text request with your EvoLink API key, then send a screenshot and the code that produced it. In this example, a help bubble covers the right side of Place order at 390 CSS pixels. You’ll ask for a CSS patch and check that both buttons receive clicks after applying it. Get an EvoLink API keyMake a text-only request
Use an EvoLink API key,
curl, and jq. Step 3 also uses Python 3. Set EVOLINK_API_KEY in the shell running the commands. Both examples send a Chat Completions request to https://api.evolink.ai/v1/chat/completions with the key in the Bearer authorization header. Manage EvoLink API keyscurl --silent --show-error --fail-with-body \
https://api.evolink.ai/v1/chat/completions \
-H "Authorization: Bearer ${EVOLINK_API_KEY:?Set EVOLINK_API_KEY}" \
-H 'Content-Type: application/json' \
--data '{
"model": "glm-5.4",
"stream": false,
"reasoning_effort": "low",
"messages": [
{ "role": "user", "content": "Reply with just the word READY." }
]
}' \
-o text-response.json &&
jq -e '{model, answer: .choices[0].message.content, usage}
| select((.answer // "") | length > 0)' text-response.jsonThe request passes the smoke test when the API returns a success status and the response contains an answer in
choices[0].message.content. The expected short answer is READY. The model field identifies the model reported by the endpoint. Keep the usage object as a baseline for the screenshot request. EvoLink Chat Completions response exampleReproduce the overlap on mobile
Save the following as
checkout.html. Open it in your browser, enable responsive mode, and set the viewport to 390 × 540 CSS pixels. The help button sits over the order button’s right edge. At 1280 × 720, the buttons occupy separate areas.<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Checkout overlap example</title>
<style>
body { margin: 0; background: #f4f6fa; color: #182235; font: 16px system-ui, sans-serif; }
main { max-width: 26rem; margin: 48px auto; padding: 0 16px; }
h1 { margin: 0 0 24px; }
.summary { padding: 20px; border: 1px solid #dae0eb; border-radius: 12px; background: white; }
.summary p:first-child { margin-top: 0; }
.summary p:last-child { margin-bottom: 0; }
.actions { position: fixed; inset: auto 16px 24px; display: grid; max-width: 26rem; margin-inline: auto; }
button { font: inherit; font-weight: 600; cursor: pointer; }
.place-order { width: 100%; min-height: 52px; border: 0; border-radius: 10px; background: #1742bf; color: white; }
.help-bubble { position: fixed; right: 16px; bottom: 16px; z-index: 2; width: 112px; min-height: 44px; border: 0; border-radius: 24px; background: #17243d; color: white; }
</style>
<main>
<h1>Checkout</h1>
<section class="summary" aria-label="Order summary">
<p>Travel mug × 1</p>
<p><strong>Total $24.00</strong></p>
</section>
<p id="status" role="status"></p>
</main>
<div class="actions">
<button class="place-order" type="button">Place order</button>
<button class="help-bubble" type="button">Need help?</button>
</div>
<script>
const statusLine = document.querySelector("#status");
document.querySelector(".place-order").onclick = () => { statusLine.textContent = "Order button clicked"; };
document.querySelector(".help-bubble").onclick = () => { statusLine.textContent = "Help button clicked"; };
</script>
</html>Save the screenshot below as
checkout-390.png next to checkout.html, or capture the same viewport in your browser. The example uses a static checkout and the buttons only report which click was received.
Send the screenshot and source together
The screenshot shows which control gets covered. The source gives the model the selectors, positions, and stacking order needed to propose a change. Save this instruction as
repair-prompt.txt in the same folder.The attached screenshot is checkout.html at a viewport of 390 × 540 CSS pixels.
The Need help button covers the right edge of Place order.
Use the screenshot and the source below to explain which CSS rules cause the overlap.
Return one minimal CSS-only unified diff for checkout.html. Keep both buttons
visible and clickable at 390 px, with no horizontal overflow. Preserve the fixed
bottom-right help position and the centered action at 1280 px. Keep both labels
and click handlers. Finish with instructions for checking the right edge of
Place order, the help button, and the desktop layout.The request attaches the PNG as a Base64 data URL inside an
image_url block. You can also pass a public image URL that EvoLink can fetch. GLM-5.4 keeps reasoning enabled on EvoLink and accepts low, high, and max for reasoning_effort. This example uses high and gives the reasoning and final answer a shared output budget of 8,192 tokens.python3 - <<'PY' > screenshot-request.json
import base64
import json
from pathlib import Path
image = base64.b64encode(Path("checkout-390.png").read_bytes()).decode("ascii")
prompt = Path("repair-prompt.txt").read_text(encoding="utf-8")
source = Path("checkout.html").read_text(encoding="utf-8")
print(json.dumps({
"model": "glm-5.4",
"stream": False,
"reasoning_effort": "high",
"max_tokens": 8192,
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": f"{prompt}\n\ncheckout.html:\n{source}"},
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{image}"}},
],
}],
}))
PY
curl --silent --show-error --fail-with-body \
https://api.evolink.ai/v1/chat/completions \
-H "Authorization: Bearer ${EVOLINK_API_KEY:?Set EVOLINK_API_KEY}" \
-H 'Content-Type: application/json' \
--data-binary @screenshot-request.json \
-o screenshot-response.json &&
jq -e '{model, finish_reason: .choices[0].finish_reason,
answer: .choices[0].message.content, usage}
| select((.answer // "") | length > 0)' screenshot-response.jsonRead the patch in
answer. EvoLink bills media as input tokens, so usage.prompt_tokens includes the processed screenshot along with the prompt and source. completion_tokens reports output usage, including reasoning, and prompt_tokens_details.cached_tokens gives the cache count when supplied. The screenshot request also contains extra instructions and source code, so its prompt-token total covers all three inputs. Find the billed charge in your EvoLink usage records. EvoLink usage dashboardApply and verify a patch
Review the proposed diff, then apply it to your local copy. In this fixture, both controls occupy the bottom-right area on a narrow viewport. The help bubble’s
z-index puts it above the order button, intercepting clicks within the overlap. One reference fix is to let the controls stack at narrower widths and keep the help bubble in its own row. Add this rule after the existing styles if you want to compare your result against a known solution.@media (max-width: 720px) {
.actions { gap: 8px; }
.help-bubble { position: static; justify-self: end; }
}| Check | Expected result |
|---|---|
| 390 × 540, click 12 px inside the order button’s right edge at its vertical center | The status reads Order button clicked. Before the fix, the same point relative to the order button hits the help bubble. |
| 390 × 540, click the help button | The status reads Help button clicked. Both controls are visible, their bounds are separate, and the page has no horizontal scrollbar. |
| 1280 × 720, click both controls | Each click produces its own status. The order button is horizontally centered and the help button stays fixed 16 px from the right and bottom edges. |
The reference CSS and click checks were verified in Chromium. The reference fix is an author-written example.
In this 390 px checkout recording, the first click falls on the overlap and opens Help. After the reference CSS fix, Place order and Need help? each produce their own status. The clip shows the expected browser behavior using the tutorial’s example patch.
Troubleshooting
- The text request fails. Inspect the error object in
text-response.json. Check thatEVOLINK_API_KEYcontains a valid EvoLink key and that the request body usesglm-5.4. - The text request works and the image request fails. Check that the file is a PNG and the data URL begins with
data:image/png;base64,. For a hosted image, confirm the raw image is reachable without cookies or sign-in. - The response ends before the diff. Check
finish_reason. For a length limit, trim irrelevant source or adjust the output budget. Read the proposed change fromchoices[0].message.contentand use the browser checks to verify it.
Try the same workflow on EvoLink with your own screenshot and matching component. For a comparison of access options and billing, see where to use GLM-5.4.
For a different task, check which inputs GLM-5.4 accepts. If you already use a coding CLI, the EvoLink gateway setup guide shows how to configure the client. Use the GLM-5.4 benchmarks to choose comparison tasks.


