OpenAI 風格
使用與 OpenAI API 相容的端點
SilentAPI 提供與 OpenAI API 相容的端點;若您的程式碼使用 OpenAI SDK,只需更改基底網址與 API 金鑰,請求與回應的結構均遵循 OpenAI API。
端點
| 方法 | 路徑 | 描述 |
|---|---|---|
| POST | /v1/chat/completions | 聊天補全 |
| 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} | 取得單一模型 |
聊天補全
使用 model 與 messages 欄位傳送 OpenAI 聊天補全 API 請求:
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。
網頁搜尋
GPT 6.2 Astra、GPT 6.2 Sol、GPT 6.1 Terra 與 GPT 6 Luna 支援網頁搜尋;請設定 useWebSearch: true 或傳送 web_search_options: {},串流時也可使用相同的選項。
{
"model": "gpt-6.1-terra",
"messages": [{"role":"user","content":"Find the latest release notes for Python."}],
"useWebSearch": true
}
搜尋會在 詞元 費用之外加收模型牌價的搜尋費用;SilentAPI 依回報的搜尋次數收費(含零次)。若搜尋整合未回報次數,啟用搜尋的請求計為一次;引用資料不影響計費。在聊天中,請於模型選項開啟網頁搜尋。
嵌入
在 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 | low, medium, high, xhigh, max |
| gpt-6.2-astra | low, medium, high, xhigh, max |
| gpt-6.1-terra | none, low, medium, high, xhigh, max |
| gpt-6-luna | none, low, medium, high, xhigh, max |
推理控制因模型而異;模型清單會在 silentapi.reasoning 列出支援的等級,並在 silentapi.reasoning_default 標示文件預設值。未指定推理等級的 API 請求會使用該預設值。聊天預設使用 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 | 最大輸出 詞元 數 |
| max_completion_tokens | integer | 最大補全 詞元 數(GPT 6 模型) |
| top_p | number | 核心取樣參數 |
| reasoning_effort | string | Reasoning level: none, minimal, low, medium, high, xhigh, or max. See 推理. |
| 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 中的 參數處理。
推理
聊天模型接受推理等級,欄位依端點而異:
| 端點 | 欄位 |
|---|---|
| 聊天補全 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 | 最低 |
| low | 低 |
| medium | 中 |
| high | 高 |
| xhigh | 超高 |
| max | Max |
| on | 開啟;僅支援開關的模型使用此值。 |
每個模型支援各自的等級,請於 模型清單 的 silentapi.reasoning 查閱;SilentAPI 會調整請求以符合模型:
| 模型等級 | 結果 |
|---|---|
等級清單,例如 ["low", "medium", "high"] | 模型支援時,SilentAPI 使用請求的等級,否則使用最接近的支援等級;若有兩個等級同樣接近,則使用較高者。 |
["none", "on"] | 模型僅接受開或關;none 關閉推理,其他等級均開啟推理。 |
[] | 模型一律進行推理,SilentAPI 會忽略請求的等級。 |
| 模型等級 | 請求 | 採用的等級 |
|---|---|---|
["low", "medium", "high"] | xhigh | high |
["low", "medium", "high"] | none | low |
["none", "on"] | high | 開啟 |
[] | low | 模型預設值 |
SilentAPI 亦接受以下別名:
| 請求值 | 對應值 |
|---|---|
| on, enabled, true | on;在具備等級清單的模型上,SilentAPI 使用 medium 或最接近的支援等級。 |
| off, disabled, false | none |
SilentAPI 會忽略不在這些表格中的值,模型接著使用其預設值。
聊天補全亦接受 reasoning 物件;缺少 reasoning_effort 時,SilentAPI 會讀取它:
| 欄位 | 處理方式 |
|---|---|
| reasoning.effort | 等同於 reasoning_effort |
| reasoning.max_tokens | 詞元 預算;SilentAPI 先以 預算表 將其轉為等級,再轉為模型支援的最接近等級。 |
| reasoning.enabled | true is the same as on. false is the same as 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 | integer 或 null | 最大上下文 詞元 數 |
| max_output_tokens | integer 或 null | 最大輸出 詞元 數 |
| input_modalities | array | 輸入類型,例如 text 或 image |
| output_modalities | array | 輸出類型 |
| pricing | object | 詞元 價格;無 詞元 價格的模型不含此欄位。 |
| silentapi | object | SilentAPI 模型詳細資料 |
pricing 包含以下欄位;每個價格以字串表示美元計的單 詞元 價格,可使用指數記法,例如 9.38e-7。
| 欄位 | 類型 | 意義 |
|---|---|---|
| prompt | string | 單一輸入 詞元 的價格 |
| completion | string | 單一輸出 詞元 的價格 |
| input_cache_read | string | 單一快取輸入 詞元 的價格,僅適用時提供。 |
| input_cache_write | string | 單一快取寫入 詞元 的價格,僅適用時提供。 |
silentapi 包含以下欄位:
| 欄位 | 類型 | 意義 |
|---|---|---|
| model_name | string | 模型名稱 |
| vendor | string | 模型供應商 |
| family | string | 模型家族 |
| category | string | Service type, for example multimodal, text, image, or embedding |
| privacy | string | e2e 或 silentapi |
| privacy_label | string | 端到端零資料保留或 SilentAPI 保護,詳見 隱私權標籤。 |
| resilient | boolean | 有備援模型時為 true |
| reasoning | array | 支援的推理等級,僅限聊天模型,詳見 推理。 |
模型目錄
GET /public/catalog 無需 API 金鑰即可為每個公開模型傳回一筆機器可讀的記錄,每筆記錄列出其功能(輸入與輸出類型、串流、工具、推理等級)、上下文與輸出上限、美元計的單 詞元 價格與額度價格、隱私權標籤,以及包含 status、deprecated_at、retires_at 與 replacement 的生命週期區塊;未棄用的模型狀態為 active,日期為 null。
curl https://api.silentapi.com/public/catalog
跨風格使用
任何支援的文字或多模態模型均可搭配 OpenAI 聊天補全 API 使用,例如 gemini-4-neon 會傳回 OpenAI 回應格式。
嵌入、圖像、語音與影片請使用各自獨立的媒體端點。