Skip to content

Create Chat Completion

  • Endpoint: POST https://api.olddog.shop/v1/chat/completions
  • Authentication: Authorization: Bearer <API_KEY>
  • Content-Type: application/json

Generate a model response from a list of chat messages (compatible with OpenAI chat.completions).

Request parameters

NameTypeRequiredDescription
modelstringYesModel ID, e.g. gpt-4o-mini (subject to what’s available in the console).
messagesarrayYesChat message list. Each item includes role and content.
temperaturenumberNoSampling temperature, typically (0~2). Higher is more random.
top_pnumberNoNucleus sampling probability, typically (0~1). Usually tune either this or temperature.
max_tokensintegerNoMaximum tokens to generate (limits vary by model).
streambooleanNoEnable streaming. Default false.
stopstring / arrayNoStop sequence(s). Generation stops early when matched.
presence_penaltynumberNoTopic novelty penalty, typically (-2~2).
frequency_penaltynumberNoRepetition penalty, typically (-2~2).
userstringNoEnd-user identifier for abuse monitoring and analytics.

messages fields

FieldTypeRequiredDescription
rolestringYessystem / user / assistant / tool.
contentstring / arrayYesText content, or a multimodal content array (if supported by the model).
namestringNoOptional author name (compat field).

cURL example

bash
curl --request POST "https://api.olddog.shop/v1/chat/completions" \
  --header "Authorization: Bearer $OLD_DOG_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "gpt-4o-mini",
    "messages": [
      { "role": "system", "content": "你是一个专业的中文技术写作助手。" },
      { "role": "user", "content": "用三句话解释什么是向量嵌入。" }
    ],
    "temperature": 0.7
  }'