SilentAPI ロゴ SilentAPI

Anthropic形式

Anthropic Messages API形式を使用します

SilentAPIはAnthropic Messages APIと互換性のあるエンドポイントを/v1/messagesで提供しています。Anthropic SDKをSilentAPIに向けて、APIキーを送信してください。

エンドポイント

メソッドパス説明
POST/v1/messagesメッセージを作成(Anthropic Messages API)

基本リクエスト

curl https://api.silentapi.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-5.5",
    "max_tokens": 1024,
    "messages": [{"role":"user","content":"What is zero data retention (ZDR)?"}]
  }'

Response:

{
  "id": "msg_1719584000",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-5.5",
  "content": [{
    "type": "text",
    "text": "Zero data retention means no prompts or outputs are kept."
  }],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 7,
    "output_tokens": 89
  },
  "silentapi": {
    "cost": 0.000084,
    "fallback": null
  }
}

Anthropic SDKの使用

Python

import anthropic

client = anthropic.Anthropic(
    api_key="YOUR_API_KEY",
    base_url="https://api.silentapi.com"
)

message = client.messages.create(
    model="claude-sonnet-5.5",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Explain quantum computing"}
    ]
)
print(message.content[0].text)

TypeScript

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
    apiKey: "YOUR_API_KEY",
    baseURL: "https://api.silentapi.com"
});

const message = await client.messages.create({
    model: "claude-sonnet-5.5",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Explain quantum computing" }]
});
const responseText = message.content[0].text;

対応パラメーター

パラメーター種類説明
モデル文字列対応するテキストまたはマルチモーダルモデルのID
メッセージ配列複数ターンの会話メッセージ
システム文字列システム指示
max_tokens整数最大出力トークン数(Anthropic APIで必須)
温度数値サンプリング温度
top_p数値核サンプリングパラメーター
stop_sequences配列生成を停止するシーケンス
ツール配列名前とinput_schemaを含む関数定義
tool_choiceオブジェクトauto、any、none、または名前付きツールのいずれかを選択します
思考オブジェクト思考設定。推論を参照してください。
ストリーム真偽値SSEストリーミングを有効化します(ストリーミングを参照)

推論

思考をtype: "enabled"付きで送信します。SilentAPIはbudget_tokensを推論レベルに変換します。

budget_tokens推論レベル
なしmedium
1から2,048へlow
2,049から8,192へmedium
8,193から32,768へhigh
32,769から65,536へxhigh
65,536超max

各モデルは独自のレベルセットに対応しており、SilentAPIは未対応のレベルを最も近い対応レベルに変換します。詳細は推論をご覧ください。

パラメーター処理

リクエスト処理
thinking.type: "disabled"レベルnone。無効化できるモデルでは推論がオフになります。その他のモデルでは最低レベルを使用します。
thinking.type: "adaptive"をbudget_tokensなしで指定した場合の動作についてレベルmedium
output_config.effortレベルとして使用します:low、medium、high、xhigh、max。budget_tokensより優先されます。thinking.type: "disabled"はこれよりさらに優先されます。
任意のモデルにおけるbudget_tokens上の表に従ってレベルに変換され、さらにモデルが対応する最も近いレベルに変換されます
温度が2を上回る場合2に制限されます。パラメーター処理を参照してください。
curl https://api.silentapi.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "model": "claude-sonnet-5.5",
    "max_tokens": 4096,
    "thinking": {"type": "enabled", "budget_tokens": 4096},
    "messages": [{"role":"user","content":"Compare two sorting algorithms."}]
  }'

クロススタイルの利用

Anthropic Messages APIでは、対応するテキストモデルやマルチモーダルモデルを自由に使用できます。応答はAnthropic Messages形式になります。

ストリーミング

stream: trueを設定すると、Anthropic Messages API形式のサーバー送信イベント(SSE)を受信できます。イベントの順序はストリーミングを参照してください。