Class OpenAIChatModel

java.lang.Object
io.agentscope.core.model.ChatModelBase
io.agentscope.extensions.model.openai.OpenAIChatModel
All Implemented Interfaces:
io.agentscope.core.model.Model

public class OpenAIChatModel extends io.agentscope.core.model.ChatModelBase
OpenAI Chat Model using native HTTP API.

This implementation uses direct HTTP calls to OpenAI-compatible APIs.

Features:

  • Streaming and non-streaming modes
  • Tool calling support
  • Automatic message format conversion
  • Timeout and retry configuration
  • Multi-provider support via different Formatters

Provider-specific behavior is handled by the Formatter. Use the appropriate formatter for your provider:

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Builder for OpenAIChatModel.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new builder for OpenAIChatModel.
    protected reactor.core.publisher.Flux<io.agentscope.core.model.ChatResponse>
    doStream(List<io.agentscope.core.message.Msg> messages, List<io.agentscope.core.model.ToolSchema> tools, io.agentscope.core.model.GenerateOptions options)
     
    protected reactor.core.publisher.Flux<io.agentscope.core.model.ChatResponse>
    doStream0(List<io.agentscope.core.message.Msg> messages, List<io.agentscope.core.model.ToolSchema> tools, io.agentscope.core.model.GenerateOptions options)
     
    Gets the model name for logging and identification.

    Methods inherited from class io.agentscope.core.model.ChatModelBase

    getContextWindowSize, setContextWindowSize, setNativeStructuredOutput, setNativeStructuredOutputWithTools, stream, supportsNativeStructuredOutput, supportsNativeStructuredOutputWithTools

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • doStream

      protected reactor.core.publisher.Flux<io.agentscope.core.model.ChatResponse> doStream(List<io.agentscope.core.message.Msg> messages, List<io.agentscope.core.model.ToolSchema> tools, io.agentscope.core.model.GenerateOptions options)
      Specified by:
      doStream in class io.agentscope.core.model.ChatModelBase
    • doStream0

      protected reactor.core.publisher.Flux<io.agentscope.core.model.ChatResponse> doStream0(List<io.agentscope.core.message.Msg> messages, List<io.agentscope.core.model.ToolSchema> tools, io.agentscope.core.model.GenerateOptions options)
    • getModelName

      public String getModelName()
      Gets the model name for logging and identification.
      Returns:
      the model name, or null if not configured
    • builder

      public static OpenAIChatModel.Builder builder()
      Creates a new builder for OpenAIChatModel.
      Returns:
      a new Builder instance