ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Connect Scavio to Zhipu GLM
Tutorial

How to Connect Scavio to Zhipu GLM

An r/ZaiGLM post asked how to use web_search with GLM. Wire Scavio as a tool function in 12 lines.

Get Free API KeyAPI Docs

An r/ZaiGLM post asked: can anyone use web_search with GLM? GLM accepts the OpenAI tool-calling shape, so any HTTP search API plugs in. This tutorial wires Scavio as a tool.

Prerequisites

  • GLM API key (Zhipu)
  • Scavio API key
  • Python 3.10+

Walkthrough

Step 1: Install zhipuai

Official Python SDK.

Bash
pip install zhipuai

Step 2: Define a Scavio tool function

Plain function, returns JSON.

Python
import os, requests

def scavio_search(query: str) -> dict:
    return requests.post('https://api.scavio.dev/api/v1/search',
        headers={'x-api-key': os.environ['SCAVIO_API_KEY']},
        json={'query': query}).json()

Step 3: Register tool with GLM

OpenAI-style tools schema.

Python
tools = [{
    'type': 'function',
    'function': {
        'name': 'scavio_search',
        'description': 'Live web search — SERP results plus AI Overview citations',
        'parameters': {'type': 'object', 'properties': {'query': {'type': 'string'}}, 'required': ['query']}
    }
}]

Step 4: Call GLM with tool list

Standard chat-completion with tools.

Python
from zhipuai import ZhipuAI
client = ZhipuAI(api_key=os.environ['GLM_API_KEY'])
resp = client.chat.completions.create(
    model='glm-4-plus',
    messages=[{'role': 'user', 'content': 'best mcp practices 2026'}],
    tools=tools,
)

Step 5: Handle tool calls

If GLM returns tool_calls, run scavio_search and feed back.

Python
for tc in resp.choices[0].message.tool_calls or []:
    if tc.function.name == 'scavio_search':
        args = json.loads(tc.function.arguments)
        result = scavio_search(args['query'])
        # Feed result back as tool message and re-call GLM.

Python Example

Python
# GLM agent now has live web search. Per-call cost: $0.0043 Scavio + GLM tokens.

JavaScript Example

JavaScript
// Same shape in TS using the OpenAI SDK with GLM's base_url.

Expected Output

JSON
GLM agent responds to time-sensitive questions with grounded answers. Without the tool, GLM falls back to training-data knowledge.

Related Tutorials

  • How to Add Real-Time Search to Claude via MCP

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

GLM API key (Zhipu). Scavio API key. Python 3.10+. A Scavio API key gives you 50 free credits on signup.

Yes. The free tier includes 50 credits on signup, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Related Resources

Best Of

Best GLM Web Search Tools in 2026

Read more
Use Case

Local LLM Search Grounding via API

Read more
Best Of

Best Web Search API for Local LLMs in 2026

Read more
Use Case

Pi Coding Agent Web Search Integration

Read more
Glossary

Search API Provider Landscape (2026)

Read more
Solution

Local LLM Search After Google Paywall

Read more

Start Building

An r/ZaiGLM post asked how to use web_search with GLM. Wire Scavio as a tool function in 12 lines.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy