Appearance
Chat Completions
通过 OpenAI 兼容的 chat/completions 接口调用 GLM。
POST /v1/chat/completions 是 Fhddos 接入 GLM 的默认入口。
基础请求
bash
curl -X POST "https://aiapi.fhddos.com/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 对象:
json
{
"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,并且上游返回搜索证据,响应顶层还会出现:
json
{
"web_search": [
{
"title": "Current Local Time in Beijing, Beijing Municipality, China",
"link": "https://www.timeanddate.com/worldclock/china/beijing",
"refer": "ref_1"
}
]
}OpenAPI
yaml
openapi: 3.0.3
info:
title: Fhddos Core API
version: '1.0'
description: >-
Core OpenAI-compatible and model-family endpoints used by the Fhddos user
docs.
servers:
- url: https://aiapi.fhddos.com
security:
- BearerAuth: []
paths:
/v1/chat/completions:
post:
tags:
- OpenAI
summary: Chat completions
requestBody:
$ref: '#/components/requestBodies/JsonObject'
responses:
'200':
$ref: '#/components/responses/JsonObject'
components:
requestBodies:
JsonObject:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/GenericObject'
responses:
JsonObject:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/GenericObject'
schemas:
GenericObject:
type: object
additionalProperties: true
securitySchemes:
BearerAuth:
type: http
scheme: bearer
description: 'Authorization: Bearer <token>'