Class OpenAIModel

java.lang.Object
ai.singlr.openai.OpenAIModel
All Implemented Interfaces:
ai.singlr.core.model.Model, AutoCloseable

public class OpenAIModel extends Object implements ai.singlr.core.model.Model
OpenAI model implementation using the Responses API.

All requests use SSE streaming internally for robust timeout handling. Synchronous chat(List, List) methods stream under the hood and accumulate the response, avoiding HTTP read timeouts on long-running generations. A per-line idle timeout detects stalled streams and throws a retryable OpenAIException.

  • Method Summary

    Modifier and Type
    Method
    Description
    ai.singlr.core.model.Response<Void>
    chat(List<ai.singlr.core.model.Message> messages, List<ai.singlr.core.tool.Tool> tools)
     
    <T> ai.singlr.core.model.Response<T>
    chat(List<ai.singlr.core.model.Message> messages, List<ai.singlr.core.tool.Tool> tools, ai.singlr.core.schema.OutputSchema<T> outputSchema)
     
    ai.singlr.core.model.CloseableIterator<ai.singlr.core.model.StreamEvent>
    chatStream(List<ai.singlr.core.model.Message> messages, List<ai.singlr.core.tool.Tool> tools)
     
    void
     
    int
     
    id()
     
    int
     
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface ai.singlr.core.model.Model

    chat, chat, chatStream, chatStream, chatStream
  • Method Details

    • id

      public String id()
      Specified by:
      id in interface ai.singlr.core.model.Model
    • provider

      public String provider()
      Specified by:
      provider in interface ai.singlr.core.model.Model
    • contextWindow

      public int contextWindow()
      Specified by:
      contextWindow in interface ai.singlr.core.model.Model
    • maxOutputTokens

      public int maxOutputTokens()
      Specified by:
      maxOutputTokens in interface ai.singlr.core.model.Model
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface ai.singlr.core.model.Model
    • chat

      public ai.singlr.core.model.Response<Void> chat(List<ai.singlr.core.model.Message> messages, List<ai.singlr.core.tool.Tool> tools)
      Specified by:
      chat in interface ai.singlr.core.model.Model
    • chat

      public <T> ai.singlr.core.model.Response<T> chat(List<ai.singlr.core.model.Message> messages, List<ai.singlr.core.tool.Tool> tools, ai.singlr.core.schema.OutputSchema<T> outputSchema)
      Specified by:
      chat in interface ai.singlr.core.model.Model
    • chatStream

      public ai.singlr.core.model.CloseableIterator<ai.singlr.core.model.StreamEvent> chatStream(List<ai.singlr.core.model.Message> messages, List<ai.singlr.core.tool.Tool> tools)
      Specified by:
      chatStream in interface ai.singlr.core.model.Model