Skip to content

リクエストテスト ​

Linux Shell または Windows CMD ターミナルを開き、以下のコマンドをターミナルに貼り付けて最初の API リクエストを実行してください。YOUR_API_KEY を必ずご自身の API キーに置き換えてください。

curl リクエスト例 ​

bash
curl https://ai-tokenhub.ai/api/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -d '{
  "model": "dola-seed-2-1-turbo-260628",
  "messages": [{"role": "user", "content": "Say this is a test!"}],
  "temperature": 0.7
}'

レスポンス例 ​

このリクエストは、dola-seed-2-1-turbo-260628 モデルを使用してプロンプト「Say this is a test!」の補完をモデルに要求します。以下のようなレスポンスが返されます:

json
{
   "id":"chatcmpl-abc123",
   "object":"chat.completion",
   "created":1677858242,
   "model":"dola-seed-2-1-turbo-260628",
   "usage":{
      "prompt_tokens":13,
      "completion_tokens":7,
      "total_tokens":20
   },
   "choices":[
      {
         "message":{
            "role":"assistant",
            "content":"\n\nThis is a test!"
         },
         "finish_reason":"stop",
         "index":0
      }
   ]
}

レスポンスフィールドの説明 ​

フィールド説明
idリクエストの一意の識別子
object返されるオブジェクトの種類。ここでは chat.completion
createdリクエスト作成時刻の Unix タイムスタンプ
model実際に処理したモデル名
usageToken の使用統計
choicesモデルが生成した返信のリスト
finish_reason生成終了の理由。stop は正常に完了したことを示す

これで最初のチャットリクエストが完了しました。finish_reason が stop であることは、API がモデル生成の完全な出力を返したことを意味します。