Class ChatCompletionsRequest
java.lang.Object
io.agentscope.core.chat.completions.model.ChatCompletionsRequest
Request payload for the Chat Completions HTTP API.
This request is 100% compatible with OpenAI's Chat Completions API. All fields follow the official OpenAI specification exactly.
Stateless Operation:
This API is fully stateless, just like OpenAI's standard API. The client is responsible for
maintaining conversation history and sending the complete messages array with each
request.
Example Request:
{
"model": "gpt-4",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What's the weather in Hangzhou?"},
{"role": "assistant", "content": "Let me check...", "tool_calls": [...]},
{"role": "tool", "tool_call_id": "call_xxx", "content": "25°C sunny"},
{"role": "user", "content": "Thanks! And tomorrow?"}
],
"stream": false
}
Tool Call Flow:
When the assistant calls tools, the response includes tool_calls. The client should:
- Append the assistant message (with tool_calls) to history
- Append tool result messages for each tool call
- Send the updated history in the next request
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetModel()getTools()voidsetMessages(List<ChatMessage> messages) voidvoidvoidsetTools(List<OpenAITool> tools)
-
Constructor Details
-
ChatCompletionsRequest
public ChatCompletionsRequest()
-
-
Method Details
-
getModel
-
setModel
-
getMessages
-
setMessages
-
getStream
-
setStream
-
getTools
-
setTools
-