Class AbstractOpenAICompatProvider

java.lang.Object
net.thevpc.naru.api.model.AbstractNaruModelProvider
net.thevpc.naru.ext.models.openapi.AbstractOpenAICompatProvider
All Implemented Interfaces:
NaruModelProvider, net.thevpc.nuts.spi.NComponent
Direct Known Subclasses:
NaruCerebrasProvider, NaruColibriProvider, NaruCustomProvider, NaruGeminiProvider, NaruGitHubModelsProvider, NaruGroqProvider, NaruMistralProvider, NaruOllamaProvider, NaruOpenRouterProvider, NaruXaiProvider

public abstract class AbstractOpenAICompatProvider extends AbstractNaruModelProvider
Base class for OpenAI-compatible cloud providers (Groq, Cerebras, OpenRouter, GitHub Models, ...). Subclasses provide a name, a default base url, a model list and static capabilities; the wire protocol and auth handling are inherited.
  • Field Details

  • Constructor Details

    • AbstractOpenAICompatProvider

      protected AbstractOpenAICompatProvider(String name, String[] defaultEnvKeys)
  • Method Details

    • chatPath

      protected String chatPath()
    • baseUrl

      protected abstract String baseUrl(NaruSession session)
      Fallback base url when <name>.url config is not set.
    • resolveCapabilities

      protected abstract NaruModelCapabilities resolveCapabilities(String modelName, NaruSession session)
      Statically maps capabilities since cloud-hosted capabilities cannot be polled natively.
    • createProtocol

      protected NaruModelProtocol createProtocol(NaruModelConfig model, NaruModelCapabilities capabilities, NaruSession session)
    • getProtocol

      public net.thevpc.nuts.util.NOptional<NaruModelProtocol> getProtocol(NaruModelConfig model, NaruSession session)
    • isApiKeySet

      public boolean isApiKeySet(NaruSession session)
    • findModelIds

      public List<String> findModelIds(NaruSession session)
    • connectTimeout

      protected net.thevpc.nuts.time.NDuration connectTimeout(NaruSession session)
    • readTimeout

      protected net.thevpc.nuts.time.NDuration readTimeout(NaruSession session)
    • modelsPath

      protected String modelsPath()
    • fetchLiveModelIds

      protected List<String> fetchLiveModelIds(NaruSession session)
    • findModelIdsWithLiveFallback

      protected List<String> findModelIdsWithLiveFallback(NaruSession session, List<String> staticFallback)
    • isReachable

      protected boolean isReachable(String url)
      Short-timeout liveness probe on the given url with a small TTL cache. Any HTTP response (even 4xx/5xx) means the endpoint is reachable; connection failures/timeouts mean it is not.