Class ChatCompletionsRequest

java.lang.Object
io.agentscope.core.chat.completions.model.ChatCompletionsRequest

public class ChatCompletionsRequest extends Object
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:

  1. Append the assistant message (with tool_calls) to history
  2. Append tool result messages for each tool call
  3. Send the updated history in the next request
  • Constructor Details

    • ChatCompletionsRequest

      public ChatCompletionsRequest()
  • Method Details