直连通道
官方直连链路,适合需要原生体验与完整上下文的请求。
| 输入上下文 | 输入 | 输出 | 缓存命中 |
|---|---|---|---|
| ≤ 200K | 2.00/M | 12.00/M | 0.20/M |
| > 200K | 4.00/M | 18.00/M | 0.40/M |
Gemini 3.1 Pro Preview 是 Google 的前沿推理模型,可提供增强的软件工程性能、改进的代理可靠性以及在复杂工作流程中更有效的令牌使用。它建立在 Gemini 3 系列的多模态基础上,将文本、图像、视频、音频和代码的高精度推理与 1M 令牌上下文窗口相结合。
同一模型能力,多条服务通道;按延迟、稳定性与成本灵活选择。
价格单位:$ / 1M tokensprovider 字段,例如 "provider": { "channel": "direct" }。可选 direct / stable / economical;不传则使用默认通道。官方直连链路,适合需要原生体验与完整上下文的请求。
| 输入上下文 | 输入 | 输出 | 缓存命中 |
|---|---|---|---|
| ≤ 200K | 2.00/M | 12.00/M | 0.20/M |
| > 200K | 4.00/M | 18.00/M | 0.40/M |
gemini-3.1-pro-previewhttps://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": "gemini-3.1-pro-preview",
"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="gemini-3.1-pro-preview",
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: 'gemini-3.1-pro-preview',
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 ?? '')
}