API

5 分で完了する完全な Model Gate API リファレンス。

API

Model Gate は、2 つの互換性のある推論インターフェイスを公開します。

  • 人間的POST /v1/messages Anthropic SDK、Claude Code、および互換性のあるクライアント用。
  • OpenAIPOST /v1/chat/completions OpenAI SDK と互換性のあるクライアント用。

1つ mg_live_... キーは両方のモードで機能します。ルーティングと請求は Model Gate によって処理されます。

ベースURL

https://api.model-gate.com

OpenAI 互換クライアントは通常、 https://api.model-gate.com/v1

クイックスタート

カール: 人間的

curl https://api.model-gate.com/v1/messages \
  -H "x-api-key: mg_live_..." \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model":"claude-opus-4.8","max_tokens":1024,"messages":[{"role":"user","content":"Hello"}]}'

カール: OpenAI

curl https://api.model-gate.com/v1/chat/completions \
  -H "Authorization: Bearer mg_live_..." \
  -H "content-type: application/json" \
  -d '{"model":"claude-opus-4.8","messages":[{"role":"user","content":"Hello"}]}'

Python: OpenAI SDK

from openai import OpenAI
client = OpenAI(api_key="mg_live_...", base_url="https://api.model-gate.com/v1")
response = client.chat.completions.create(model="claude-opus-4.8", messages=[{"role":"user","content":"Hello"}])
print(response.choices[0].message.content)

Python: Anthropic SDK

from anthropic import Anthropic
client = Anthropic(api_key="mg_live_...", base_url="https://api.model-gate.com")
response = client.messages.create(model="claude-opus-4.8", max_tokens=1024, messages=[{"role":"user","content":"Hello"}])
print(response.content[0].text)

サポートされている機能

ストリーミング、プロンプト キャッシュ、ビジョン、ツールの使用/関数呼び出し、拡張思考、ラージ コンテキスト モデルは、選択したモデルでサポートされている場合にパススルーされます。

限界

RPM と同時実行性は、アカウントごと、キーごとに構成できます。キーには、リセット可能な使用量カウンターと有効期限もあります。 total_spent カウンタ。レート制限を超えると返品される 429Retry-After

次のステップ