OpenAI 风格
使用兼容 OpenAI API 的端点
SilentAPI 提供兼容 OpenAI API 的端点。如果你的代码使用 OpenAI SDK,只需修改 base URL 和 API 密钥。请求和响应结构遵循 OpenAI API。
端点
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /v1/chat/completions | Chat 补全 |
| POST | /v1/completions | 旧版文本补全 |
| POST | /v1/responses | Responses API 接口 |
| POST | /v1/embeddings | 创建嵌入 |
| POST | /v1/audio/speech | 文字转语音 |
| POST | /v1/audio/transcriptions | 语音转文字 |
| POST | /v1/images/generations | 图像生成 |
| POST | /v1/images/edits | 图像编辑 |
| GET | /v1/models | 列出可用模型 |
| GET | /v1/models/{id} | 获取单个模型 |
Chat Completions 补全
发送一个 OpenAI Chat Completions API 请求,请求中需要包含 model 和 messages 这两个必填字段:
curl https://api.silentapi.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-6.1-terra",
"messages": [{"role":"user","content":"Explain how APIs work."}]
}'
Response:
{
"id": "chatcmpl_1719584000",
"object": "chat.completion",
"created": 1719584000,
"model": "gpt-6.1-terra",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "An API is like a waiter in a restaurant..."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 8,
"completion_tokens": 156,
"total_tokens": 164
},
"silentapi": {
"cost": 0.000117,
"fallback": null
}
}
使用 OpenAI SDK
Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.silentapi.com/v1"
)
response = client.chat.completions.create(
model="gpt-6.1-terra",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
请在 messages 中发送对话消息。系统指令请作为一条 role: "system" 的消息发送。prompt 字段只能在 Completions API 中使用。
Web Search
GPT 6.2 Astra、GPT 6.2 Sol、GPT 6.1 Terra 和 GPT 6 Luna 等模型支持网页搜索功能,可返回 Web 搜索结果。设置 useWebSearch: true 或发送 web_search_options: {} 即可启用,流式输出时同样适用,也能获取实时网络信息。
{
"model": "gpt-6.1-terra",
"messages": [{"role":"user","content":"Find the latest release notes for Python."}],
"useWebSearch": true
}
搜索会在 token 费用之外加上该模型标注的搜索价格。SilentAPI 按报告的搜索调用次数计费,包括零次。当搜索集成未报告次数时,每个启用了搜索的请求按一次调用计。引用数量不影响费用。在聊天中,请在模型选项里启用 Web 搜索。
嵌入
请在 input 字段中发送需要处理的文本内容。向量嵌入请使用 gemini-embedding-2 或 text-embedding-3-small 模型。
curl https://api.silentapi.com/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"model":"gemini-embedding-2","input":"SilentAPI API documentation"}'
encoding_format: "base64" 适用于所有模型。dimensions 会发送给支持它的模型。请参阅参数处理中的嵌入。
文字转语音
在 input 字段中发送文本,响应为音频。
curl https://api.silentapi.com/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{"model":"gemini-3.8-flash-tts","input":"Your request is ready.","voice":"Kore","response_format":"wav"}' \
-o speech.wav
语音合成请求接受 mp3、wav、opus、aac、flac 和 pcm,包括 audio/wav、audio/mpeg 和 .MP3 等常见别名。如果请求的格式不可用,SilentAPI 会返回一种支持的格式。X-SilentAPI-Format 显示实际格式,X-SilentAPI-Notice 说明格式的替换。音频字节和 Content-Type 始终与返回的格式一致。请参阅参数处理中的语音合成。
语音转文字
请在 multipart 表单的 file 字段中发送音频文件,并使用 gpt-transcribe 模型。
curl https://api.silentapi.com/v1/audio/transcriptions \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@recording.mp3" \
-F "model=gpt-transcribe"
在所有模型上,response_format 都可以是 json、text、verbose_json、srt 或 vtt。请参阅参数处理中的语音转写。
当前模型
均衡类工作请使用 gpt-6.2-sol。可用的 GPT 模型如下:
| 模型 | 推理级别 |
|---|---|
| gpt-6.2-sol | 低、中等、高、极高、最高 |
| gpt-6.2-astra | 低、中等、高、极高、最高 |
| gpt-6.1-terra | 无、低、中等、高、极高、最高 |
| gpt-6-luna | 无、低、中等、高、极高、最高 |
各模型的推理控制方式不同。模型列表在 silentapi.reasoning 中列出支持的级别,并在 silentapi.reasoning_default 中给出文档规定的默认值。未指定推理级别的 API 请求使用该默认值。Chat 默认使用 Kimi K3.1 Pro 和 High 推理;你保存的偏好设置优先。Kimi K3、Kimi K3.1 Pro、GLM 5.3 和 GLM 5.3 Flash 支持 low、high 和 max,其 API 默认值为 max。仅支持开关的模型使用 On 和 Off。推理固定的模型不接受强度控制。
gpt-6.2-sol 支持函数调用。在 tools 中发送函数定义,由你的应用运行模型请求的函数。
支持的参数
| 参数 | 类型 | 说明 |
|---|---|---|
| model | string | 模型 ID(请参阅服务) |
| messages | array | 多轮对话消息 |
| temperature | number | 采样温度(0 至 2) |
| max_tokens | integer | 最大输出 token 数 |
| max_completion_tokens | integer | 最大补全 token 数(GPT 6 模型) |
| top_p | number | 核采样参数 |
| reasoning_effort | string | 推理强度支持以下档位:none、minimal、low、medium、high、xhigh 或 max,共七个级别,可按需选择。具体含义参见 推理。 |
| response_format | object | JSON Schema 或 JSON 对象模式 |
| tools | array | 函数调用的工具定义 |
| stream | boolean | 启用 SSE 流式输出(请参阅流式输出) |
| webhook_url | string | 以 POST 回调的形式接收响应内容 |
参数处理
有些值在 OpenAI API 中有效,但并非所有模型都支持。SilentAPI 会调整这些值,避免请求失败:
| 参数 | 处理方式 |
|---|---|
| temperature | 限制为 0 至 2 |
| top_p, min_p | 限制为 0 至 1 |
| frequency_penalty, presence_penalty | 限制为 -2 至 2 |
| repetition_penalty | 限制为 0 至 2 |
| max_tokens, max_completion_tokens | 小数会向下取整,小于 1 的值会被忽略。 |
| 以文本形式发送的数字 | 会转换为数字,例如 "0.5" 变为 0.5。非数字的值会被忽略。 |
| reasoning_effort、reasoning.effort | 支持的值保持不变。不支持的值会上调到下一个支持的级别,或停在最高可用级别。不支持的 none 使用最低级别。缺失或无法识别的值使用文档规定的模型默认值。超高、extra-high 和 x_high 均表示 xhigh。请参阅推理。 |
媒体端点请参阅媒体与 OCR 中的参数处理。
推理
Chat 模型接受推理级别,所用字段取决于端点:
| 端点 | 字段 |
|---|---|
| Chat Completions API 接口 | reasoning_effort |
| Responses API 接口 | reasoning.effort |
原生模型路由,例如 /v1/google/gemini-4-neon | reasoning_effort,或别名 thinkingLevel |
| Anthropic Messages API 接口 | thinking。请参阅Anthropic 风格。 |
Gemini generateContent | 推理配置位于 generationConfig.thinkingConfig 字段中,写法与 Gemini 风格 一致,详情参见相关文档。 |
curl https://api.silentapi.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-6.2-sol",
"messages": [{"role":"user","content":"Plan a three-step database migration."}],
"reasoning_effort": "high"
}'
| 值 | 标签 |
|---|---|
| none | 无。对于仅支持开关的模型即为关闭。 |
| minimal | Minimal |
| low | Low |
| medium | Medium |
| high | High |
| xhigh | 超高 |
| max | Max |
| on | 开启。用于仅支持开关的模型。 |
每个模型支持各自的一组级别,可在模型列表的 silentapi.reasoning 中查看。SilentAPI 会调整请求以适配模型:
| 模型级别 | 结果 |
|---|---|
级别列表,例如 [“低”、“中等”、“高”] | 模型支持所请求的级别时,SilentAPI 使用该级别,否则使用最接近的支持级别。两个级别同样接近时,使用较高的级别。 |
[“无”、“开”] | 该模型只接受开启或关闭。none 关闭推理,其他任何级别都会开启推理。 |
[] | 该模型始终进行推理。SilentAPI 会忽略所请求的级别。 |
| 模型级别 | 请求 | 实际使用的级别 |
|---|---|---|
[“低”、“中等”、“高”] | xhigh | high |
[“低”、“中等”、“高”] | none | low |
[“无”、“开”] | high | On |
[] | low | 模型默认值 |
SilentAPI 还接受以下别名:
| 请求值 | 等同于 |
|---|---|
| on、enabled、true | on。对于有级别列表的模型,SilentAPI 使用 medium 或最接近的支持级别。 |
| off、disabled、false | none |
SilentAPI 会忽略不在这些表中的值,模型随后使用其默认值。
Chat Completions 也接受 reasoning 对象。当 reasoning_effort 不存在时,SilentAPI 会读取该对象:
| 字段 | 处理方式 |
|---|---|
| reasoning.effort | 等同于 reasoning_effort |
| reasoning.max_tokens | token 预算。SilentAPI 会先根据预算表将其转换为级别,再转换为模型支持的最接近级别。 |
| reasoning.enabled | true 与 on 相同,两者可以互换。false 与 none 相同,两者可以互换。 |
无法关闭推理的模型在收到 none 时使用其最低级别。始终以固定级别推理的模型不会收到推理字段。reasoning 中的其他字段(如 exclude)会保留。
图像生成
curl https://api.silentapi.com/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-image-2.6-flare",
"prompt": "A serene mountain landscape at sunset",
"n": 1,
"size": "1024x1024"
}'
SilentAPI 会调整 size、aspect_ratio、n、response_format 和 output_format 以适配每个图像模型。请参阅参数处理中的图像生成。
视频
视频生成以任务形式运行。先创建任务,轮询其状态直到完成,然后下载 MP4 文件。
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /v1/videos | 创建视频任务 |
| GET | /v1/videos/{id} | 获取任务状态 |
| GET | /v1/videos/{id}/content | 下载完成的视频(MP4) |
curl https://api.silentapi.com/v1/videos \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "grok-imagine-video-1.5-lite",
"prompt": "A paper boat drifting down a rainy street",
"duration": 6,
"resolution": "720p",
"aspect_ratio": "16:9"
}'
API 会返回 202 Accepted:
{
"id": "video_abc123",
"status": "processing",
"status_url": "/v1/videos/video_abc123"
}
轮询状态,直到任务完成:
curl https://api.silentapi.com/v1/videos/video_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
下载视频:
curl https://api.silentapi.com/v1/videos/video_abc123/content \
-H "Authorization: Bearer YOUR_API_KEY" \
-o video.mp4
模型发现
GET /public/models 以 OpenAI 列表格式列出所有模型,无需 API 密钥。可在读取模型列表的工具和应用中使用。浏览器应用可从任意来源调用。
curl https://api.silentapi.com/public/models
GET /v1/models 返回相同的列表,但需要 API 密钥;GET /v1/models/{id} 返回单个条目。
curl https://api.silentapi.com/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"
响应为 {"object": "list", "data": [...]}。条目示例如下,价格仅为示例:
{
"id": "gemini-4-neon",
"object": "model",
"created": 1790000000,
"owned_by": "silentapi",
"name": "Gemini 4 Neon",
"display_name": "Gemini 4 Neon",
"context_length": 1048576,
"max_output_tokens": 65536,
"input_modalities": ["text", "image", "video", "file", "audio"],
"output_modalities": ["text"],
"pricing": {
"prompt": "0.00000375",
"completion": "0.0000188",
"input_cache_read": "1.88e-7"
},
"silentapi": {
"model_name": "Gemini 4 Neon",
"vendor": "Google AI",
"family": "Gemini 4",
"category": "multimodal",
"resilient": true,
"privacy": "e2e",
"privacy_label": "End-to-end ZDR",
"reasoning": ["low", "medium", "high", "xhigh"]
}
}
| 字段 | 类型 | 含义 |
|---|---|---|
| id | string | 模型 ID,在 model 字段中发送。 |
| object | string | 始终为 model |
| created | integer | Unix 时间(秒) |
| owned_by | string | 始终为 silentapi |
| name | string | 模型名称 |
| display_name | string | 模型名称,与 name 相同。 |
| context_length | 整数或 null | 最大上下文(token) |
| max_output_tokens | 整数或 null | 最大输出 token 数 |
| input_modalities | array | 输入类型,例如 text 或 image |
| output_modalities | array | 输出类型 |
| pricing | object | token 价格。模型没有 token 价格时不出现。 |
| silentapi | object | SilentAPI 模型详情 |
pricing 包含以下字段。每个价格均为每 token 的美元价格,以字符串表示。价格可能使用指数表示法,例如 9.38e-7。
| 字段 | 类型 | 含义 |
|---|---|---|
| prompt | string | 每个输入 token 的价格 |
| completion | string | 每个输出 token 的价格 |
| input_cache_read | string | 每个缓存输入 token 的价格,仅在适用时出现。 |
| input_cache_write | string | 每个缓存写入 token 的价格,仅在适用时出现。 |
silentapi 包含以下字段:
| 字段 | 类型 | 含义 |
|---|---|---|
| model_name | string | 模型名称 |
| vendor | string | 模型厂商 |
| family | string | 模型系列 |
| category | string | 服务类型,用于区分服务种类,例如 multimodal 多模态、text 文本、image 图像或 embedding 向量嵌入。 |
| privacy | string | e2e 或 silentapi |
| privacy_label | string | 端到端 ZDR 或 SilentAPI 保护。请参阅隐私标签。 |
| resilient | boolean | 存在回退模型时为 true |
| reasoning | array | 支持的推理级别,仅限 Chat 模型。请参阅推理。 |
模型目录
GET /public/catalog 无需 API 密钥,为每个公开模型返回一条机器可读的条目。每个条目列出其能力(输入和输出类型、流式输出、工具和推理级别)、上下文和输出上限、以每 token 美元和额度表示的价格、隐私标签,以及包含 status、deprecated_at、retires_at 和 replacement 的生命周期信息。未弃用的模型状态为 active,日期为 null。
curl https://api.silentapi.com/public/catalog
跨风格使用
通过 OpenAI Chat Completions API 使用任何支持的文本或多模态模型。例如,gemini-4-neon 会返回 OpenAI 响应格式。
嵌入、图像、语音合成和视频请使用单独的媒体端点。