メインコンテンツへスキップ
POST
/
v1
/
chat
/
completions
curl -X POST "https://api.lemondata.cc/v1/chat/completions" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ],
    "temperature": 0.7,
    "max_tokens": 1000
  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1706000000,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 9,
    "total_tokens": 29
  }
}

リクエストボディ

model
string
必須
使用するモデルの ID。利用可能なオプションについては Models を参照してください。
messages
array
必須
会話を構成するメッセージのリスト。各メッセージオブジェクトには以下が含まれます:
  • role (string): systemuser、または assistant
  • content (string | array): メッセージの内容
temperature
number
デフォルト:"1"
0 から 2 の間のサンプリング温度。値が高いほど出力がランダムになります。
max_tokens
integer
生成するトークンの最大数。
stream
boolean
デフォルト:"false"
true の場合、メッセージの部分的な差分が SSE イベントとして送信されます。
stream_options
object
ストリーミングのオプション。ストリームチャンクでトークン使用量を受け取るには include_usage: true を設定します。
top_p
number
デフォルト:"1"
核サンプリング(Nucleus sampling)パラメータ。これまたは temperature のいずれか一方のみを変更することをお勧めします。
frequency_penalty
number
デフォルト:"0"
-2.0 から 2.0 の間の数値。正の値は、繰り返されるトークンにペナルティを課します。
presence_penalty
number
デフォルト:"0"
-2.0 から 2.0 の間の数値。正の値は、既にテキスト内に存在するトークンにペナルティを課します。
stop
string | array
API がトークンの生成を停止する最大 4 つのシーケンス。
tools
array
モデルが呼び出す可能性のあるツールのリスト(function calling)。
tool_choice
string | object
モデルがツールをどのように使用するかを制御します。オプション:autononerequired、または特定のツールオブジェクト。
parallel_tool_calls
boolean
デフォルト:"true"
並列関数呼び出しを有効にするかどうか。関数を順次呼び出す場合は false に設定します。
max_completion_tokens
integer
補完の最大トークン数。max_tokens の代替であり、o1/o3 などの新しいモデルで推奨されます。
reasoning_effort
string
o1/o3 モデルの推論の取り組み(Reasoning effort)。オプション:lowmediumhigh
seed
integer
決定論的なサンプリングのためのランダムシード。
n
integer
デフォルト:"1"
生成する補完の数(1-128)。
logprobs
boolean
対数確率を返すかどうか。
top_logprobs
integer
返される上位の対数確率の数(0-20)。logprobs: true が必要です。
top_k
integer
Top-K サンプリングパラメータ(Anthropic/Gemini モデル用)。
response_format
object
レスポンス形式の指定。JSON モードの場合は {"type": "json_object"} を、構造化出力の場合は {"type": "json_schema", "json_schema": {...}} を使用します。
logit_bias
object
特定のトークンが出現する可能性を変更します。トークン ID(文字列として)を -100 から 100 のバイアス値にマッピングします。
user
string
不正利用監視のためにエンドユーザーを表す一意の識別子。
cache_control
object
LemonData のキャッシュ制御オプション。
  • type (string): キャッシュ戦略 - defaultno_cacheno_storeresponse_onlysemantic_only
  • max_age (integer): 秒単位のキャッシュ TTL(最大 86400)

レスポンス

id
string
補完の一意の識別子。
object
string
常に chat.completion
created
integer
補完が作成された時の Unix タイムスタンプ。
model
string
補完に使用されたモデル。
choices
array
補完の選択肢のリスト。各選択肢には以下が含まれます:
  • index (integer): 選択肢のインデックス
  • message (object): 生成されたメッセージ
  • finish_reason (string): モデルが停止した理由(stoplengthtool_calls
usage
object
トークン使用統計。
  • prompt_tokens (integer): プロンプト内のトークン数
  • completion_tokens (integer): 補完内のトークン数
  • total_tokens (integer): 使用された合計トークン数
curl -X POST "https://api.lemondata.cc/v1/chat/completions" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ],
    "temperature": 0.7,
    "max_tokens": 1000
  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1706000000,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 9,
    "total_tokens": 29
  }
}