对话(chat)

基本信息

Path: /v1/chat/completions

Method: POST

调用说明:


curl --location 'https://api.atomecho.cn/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ${API-Sercet}' \
--data '{
    "model": "Atom-7B-Chat",
    "messages": [{
        "role": "user",
        "content": "介绍一下Llama社区"
    }],
    "temperature": 0.3,
    "stream": true
}'

stream 为true时流式返回如下


data: {"id":"Atom-sZZCBhOLuK","object":"chat.completion.chunk","created":1710497120245,"model":"Atom-7B-Chat","choices":[{"index":0,"delta":{"role":"assistant","content":"在闰年的二月,"}}],"usage":{"prompt_tokens":74,"completion_tokens":5,"total_tokens":79}}
data: {"id":"Atom-sZZCBhOLuK","object":"chat.completion.chunk","created":1710497120330,"model":"Atom-7B-Chat","choices":[{"index":0,"delta":{"role":"assistant","content":"你的月薪是80元。"},"finish_reason":"stop"}],"usage":{"prompt_tokens":74,"completion_tokens":14,"total_tokens":88}}
data: [DONE]

stream 为false时流式返回如下


{"id":"Atom-ISSbmGVKwh","created":1710497244256,"choices":[{"index":0,"finish_reason":"stop","message":{"role":"assistant","content":"假设您是2023年2月的月薪,那么在闰年的二月,您的月薪应该是8块钱乘以21天,即168元。"}}],"model":"Atom-7B-Chat","object":"chat.completion","usage":{"prompt_tokens":74,"completion_tokens":39,"total_tokens":113}}

请求参数

Headers

参数名称参数值是否必须示例备注
Content-Typeapplication/json

Body

名称类型是否必须默认值备注其他信息
modelstring非必须"Atom-13B-Chat","Atom-7B-Chat","Atom-1B-Chat","Llama3-Chinese-8B-Instruct"
messagesobject []非必须

item 类型: object

├─ rolestring非必须支持 "system","user","assistant"
├─ contentstring非必须
temperaturenumber非必须默认0.3,介于 0 和 1 之间。较高的值(如 0.7)将使输出更加随机,而较低的值(如 0.2)将使其更加集中和确定性。
top_pnumber非必须默认0.95,建议temperature和top_p只修改其中一种
repetition_penaltynumber非必须默认为 0。介于 -2.0 和 2.0 之间的数字。正值会根据新标记在迄今为止的文本中出现的频率惩罚新标记,增加模型谈论新话题的可能性。
streamboolean非必须是否开启流式

返回数据

名称类型是否必须默认值备注其他信息
id string 非必须
created number 非必须 对话完成时间
choicesobject []非必须

item 类型: object

├─ indexnumber非必须
├─ finish_reasonstring非必须完成原因
├─ messageobject非必须
├─ rolestring非必须
├─ contentstring非必须
modelstring非必须对话使用的模型
objectstring非必须
usageobject非必须消耗的tokens
├─ prompt_tokensnumber非必须
├─ completion_tokensnumber非必须
├─ total_tokensnumber非必须