直连通道
官方直连链路,适合需要原生体验与完整上下文的请求。
| 输入 | 输出 | 缓存命中 |
|---|---|---|
| 0.29/M | 0.88/M | 0.06/M |
GLM-4.6 是智谱最新的旗舰模型,其总参数量 355B,激活参数 32B,上下文提升至 200K,8 大权威基准全面提升。在编程、推理、搜索、写作、智能体应用等核心能力均完成对 GLM-4.5 的超越。
同一模型能力,多条服务通道;按延迟、稳定性与成本灵活选择。
价格单位:$ / 1M tokensprovider 字段,例如 "provider": { "channel": "direct" }。可选 direct / stable / economical;不传则使用默认通道。官方直连链路,适合需要原生体验与完整上下文的请求。
| 输入 | 输出 | 缓存命中 |
|---|---|---|
| 0.29/M | 0.88/M | 0.06/M |
GLM-4.6https://api.haijingai.com/v2/"provider": { "channel": "direct" }海鲸AI 兼容 OpenAI 接口协议,可直接使用 OpenAI SDK 或 HTTP 请求接入,默认开启流式输出。
curl https://api.haijingai.com/v2/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <API_KEY>" \
-d '{
"model": "GLM-4.6",
"messages": [
{"role": "system", "content": "你是一个有帮助的助手。"},
{"role": "user", "content": "你好!"}
],
"provider": { "channel": "direct" },
"stream": true
}'
# provider 为可选字段,删除该行即使用默认通道from openai import OpenAI
client = OpenAI(
base_url="https://api.haijingai.com/v2",
api_key="<API_KEY>",
)
stream = client.chat.completions.create(
model="GLM-4.6",
messages=[
{"role": "system", "content": "你是一个有帮助的助手。"},
{"role": "user", "content": "你好!"},
],
stream=True,
# 可选:指定服务通道,不传则使用默认通道
extra_body={"provider": {"channel": "direct"}},
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)import OpenAI from 'openai'
const client = new OpenAI({
baseURL: 'https://api.haijingai.com/v2',
apiKey: '<API_KEY>',
})
const stream = await client.chat.completions.create({
model: 'GLM-4.6',
messages: [
{ role: 'system', content: '你是一个有帮助的助手。' },
{ role: 'user', content: '你好!' },
],
stream: true,
// 可选:指定服务通道,不传则使用默认通道
// @ts-expect-error provider 为海鲸AI 扩展字段,不在 OpenAI SDK 类型定义内
provider: { channel: 'direct' },
})
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? '')
}