Chat Completions
Tạo chat completion từ danh sách messages — tương thích hoàn toàn với OpenAI API.
Request Body
ID của model muốn sử dụng. Xem danh sách models. Ví dụ: deepseek/deepseek-chat-v3-0324:free, openai/gpt-4o, anthropic/claude-sonnet-4
Danh sách messages theo chuẩn OpenAI. Mỗi message có role (system, user, assistant) và content (string hoặc array multimodal).
Độ ngẫu nhiên từ 0 → 2. Mặc định: 1. Giá trị thấp → câu trả lời chính xác hơn. Giá trị cao → sáng tạo hơn.
Giới hạn tokens tối đa cho response. Mặc định phụ thuộc model.
Nếu true, response sẽ gửi dạng SSE (Server-Sent Events). Xem Streaming.
Nucleus sampling. Giá trị 0.1 → chỉ lấy top 10% tokens. Thường dùng temperature HOẶC top_p, không dùng cả hai.
Chuỗi hoặc mảng chuỗi để dừng generation. Tối đa 4 stop sequences.
Danh sách tool/function definitions theo chuẩn OpenAI function calling. Model sẽ trả về tool_calls nếu cần gọi tool.
Ví dụ: Chat đơn giản
curl -X POST https://bizgpt.vn/wp-json/bizcity/v1/llm/chat \ -H "Authorization: Bearer biz-YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "openai/gpt-4o", "messages": [ { "role": "system", "content": "Bạn là trợ lý AI thông minh." }, { "role": "user", "content": "Giải thích blockchain trong 3 câu." } ], "temperature": 0.7, "max_tokens": 500 }'
Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1711684800,
"model": "openai/gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Blockchain là một chuỗi các khối dữ liệu..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 145,
"total_tokens": 173
}
}
Multimodal (Vision)
Để gửi ảnh kèm text, sử dụng content dạng array:
{
"model": "openai/gpt-4o",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Hình này là gì?" },
{
"type": "image_url",
"image_url": {
"url": "https://example.com/image.jpg"
}
}
]
}
]
}
Function Calling / Tools
BizCity hỗ trợ đầy đủ function calling theo chuẩn OpenAI:
{
"model": "openai/gpt-4o",
"messages": [
{ "role": "user", "content": "Thời tiết Hà Nội hôm nay?" }
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Lấy thời tiết hiện tại",
"parameters": {
"type": "object",
"properties": {
"city": { "type": "string", "description": "Tên thành phố" }
},
"required": ["city"]
}
}
}
]
}







