Tạo chat completion

post/v1/chat/completions

Tạo phản hồi của mô hình từ lịch sử hội thoại. Hỗ trợ cả phản hồi truyền trực tuyến và không truyền trực tuyến.

Tương thích với OpenAI Chat Completions API.

Xác thực

Gửi khóa API OLETOKEN dưới dạng token Bearer. Khóa được tạo tại trang API Keys trong bảng điều khiển.

Authorization: Bearer $OLETOKEN_API_KEY

Nội dung yêu cầu

Content-Type:application/json

TrườngKiểuBắt buộcMô tả
modelstringID mô hình
messagesMessage[]Các tin nhắn hội thoại
rolestringsystemuserassistanttooldeveloperVai trò của tin nhắn
contentstring | MessageContent[]Nội dung tin nhắn
typestringtextimage_urlinput_audiofilevideo_url——
textstring——
image_urlobject——
urlstring—URL hình ảnh hoặc dữ liệu base64
detailstringlowhighauto——
input_audioobject——
datastring—Dữ liệu âm thanh mã hóa Base64
formatstringwavmp3——
fileobject——
filenamestring——
file_datastring——
file_idstring——
video_urlobject——
urlstring——
namestring—Tên người gửi
tool_callsToolCall[]——
idstring——
typestring——
functionobject——
namestring——
argumentsstring——
tool_call_idstring—ID gọi công cụ (cho tin nhắn có vai trò tool)
reasoning_contentstring—Nội dung suy luận
temperaturenumber0–2default: 1—Nhiệt độ lấy mẫu
top_pnumber0–1default: 1—Tham số lấy mẫu nucleus
ninteger≥ 1default: 1—Số lượng completion cần tạo
streambooleandefault: false—Có truyền trực tuyến phản hồi hay không
stream_optionsobject——
include_usageboolean——
stopstring | string[]—Các chuỗi dừng
max_tokensinteger—Số token tối đa cần tạo
max_completion_tokensinteger—Số token completion tối đa
presence_penaltynumber-2–2default: 0——
frequency_penaltynumber-2–2default: 0——
logit_biasobject——
userstring——
toolsTool[]——
typestring——
functionobject——
namestring——
descriptionstring——
parametersobject—Định nghĩa tham số theo định dạng JSON Schema
tool_choicestring | objectnoneautorequired——
typestring——
functionobject——
namestring——
response_formatResponseFormat——
typestringtextjson_objectjson_schema——
json_schemaobject—Định nghĩa JSON Schema
seedinteger——
reasoning_effortstringlowmediumhigh—Mức độ suy luận (cho các mô hình hỗ trợ suy luận)
modalitiesstring[]——
audioobject——
voicestring——
formatstring——

Phản hồi

200Đã tạo phản hồi

TrườngKiểuBắt buộcMô tả
idstring——
objectstring——
createdinteger——
modelstring——
choicesobject[]——
indexinteger——
messageMessage——
rolestringsystemuserassistanttooldeveloperVai trò của tin nhắn
contentstring | MessageContent[]Nội dung tin nhắn
typestringtextimage_urlinput_audiofilevideo_url——
textstring——
image_urlobject——
urlstring—URL hình ảnh hoặc dữ liệu base64
detailstringlowhighauto——
input_audioobject——
datastring—Dữ liệu âm thanh mã hóa Base64
formatstringwavmp3——
fileobject——
filenamestring——
file_datastring——
file_idstring——
video_urlobject——
urlstring——
namestring—Tên người gửi
tool_callsToolCall[]——
idstring——
typestring——
functionobject——
namestring——
argumentsstring——
tool_call_idstring—ID gọi công cụ (cho tin nhắn có vai trò tool)
reasoning_contentstring—Nội dung suy luận
finish_reasonstringstoplengthtool_callscontent_filter——
usageUsage——
prompt_tokensinteger—Số token prompt
completion_tokensinteger—Số token completion
total_tokensinteger—Tổng số token
prompt_tokens_detailsobject——
cached_tokensinteger——
text_tokensinteger——
audio_tokensinteger——
image_tokensinteger——
completion_tokens_detailsobject——
text_tokensinteger——
audio_tokensinteger——
reasoning_tokensinteger——
system_fingerprintstring——

400Tham số yêu cầu không hợp lệ

TrườngKiểuBắt buộcMô tả
errorobject——
messagestring—Thông báo lỗi
typestring—Loại lỗi
paramstring | null—Tham số liên quan
codestring | null—Mã lỗi

429Vượt quá giới hạn tần suất

TrườngKiểuBắt buộcMô tả
errorobject——
messagestring—Thông báo lỗi
typestring—Loại lỗi
paramstring | null—Tham số liên quan
codestring | null—Mã lỗi

Ví dụ yêu cầu

curl -X POST 'https://api.oletoken.ai/v1/chat/completions' \
  -H "Authorization: Bearer $OLETOKEN_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gpt-4",
    "messages": []
  }'