Chat completions
curl --request POST \
--url https://models.phanedge.cloud/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://models.phanedge.cloud/v1/chat/completions"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://models.phanedge.cloud/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://models.phanedge.cloud/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://models.phanedge.cloud/v1/chat/completions"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://models.phanedge.cloud/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://models.phanedge.cloud/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{}OpenAI 兼容
Chat Completions
通过 OpenAI 兼容的 chat/completions 接口调用 GLM。
POST
/
v1
/
chat
/
completions
Chat completions
curl --request POST \
--url https://models.phanedge.cloud/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'import requests
url = "https://models.phanedge.cloud/v1/chat/completions"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://models.phanedge.cloud/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://models.phanedge.cloud/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://models.phanedge.cloud/v1/chat/completions"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://models.phanedge.cloud/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();require 'uri'
require 'net/http'
url = URI("https://models.phanedge.cloud/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body{}POST /v1/chat/completions 是 PhanEdge 接入 GLM 的默认入口。
基础请求
curl -X POST "https://models.phanedge.cloud/v1/chat/completions" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-4.7",
"messages": [
{"role": "system", "content": "你是一个简洁的技术助手。"},
{"role": "user", "content": "用三句话介绍 GLM。"}
],
"max_tokens": 256
}'
GLM 特有能力
thinking
GLM OpenAI 兼容入口支持透传 thinking 对象:
{
"model": "glm-5.1",
"thinking": {
"type": "disabled"
}
}
tools.type=web_search
GLM 的联网搜索不是普通 function tool。你需要传入完整的原生 web_search 子对象,详见 GLM 联网搜索。
什么时候用这个入口
- 你正在使用 OpenAI SDK、OpenAI 风格的网关、或现有
chat/completions代码路径 - 你需要统一接入多个 provider,同时保留 GLM 的少量原生扩展字段
什么时候不要用这个入口
- 你的应用明确依赖 Anthropic Messages 协议、Message blocks 或 Anthropic SDK
- 你只想接入 GLM 的 Anthropic 兼容能力,此时应使用 Anthropic 兼容
返回结果
普通文本调用返回标准 OpenAI 风格的:choices[].message.contentusagereasoning_content(当上游返回时)
web_search,并且上游返回搜索证据,响应顶层还会出现:
{
"web_search": [
{
"title": "Current Local Time in Beijing, Beijing Municipality, China",
"link": "https://www.timeanddate.com/worldclock/china/beijing",
"refer": "ref_1"
}
]
}
Authorizations
Authorization: Bearer
Body
application/json
The body is of type object.
Response
200 - application/json
OK
The response is of type object.

