nexus-agents - v2.80.0
    Preparing search index...

    Interface IModelAdapter

    Unified interface for all model adapters.

    interface IModelAdapter {
        providerId: string;
        modelId: string;
        capabilities: readonly ModelCapability[];
        complete(
            request: CompletionRequest,
        ): Promise<Result<CompletionResponse, ModelError>>;
        stream(request: CompletionRequest): AsyncIterable<StreamChunk>;
        countTokens(text: string): Promise<number>;
        validateConfig(): Result<void, ConfigError>;
        listModels?(): Promise<readonly ModelMetadata[]>;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    providerId: string

    Provider identifier (e.g., 'anthropic', 'openai')

    modelId: string

    Model identifier (e.g., 'claude-sonnet-4', 'gpt-4o')

    capabilities: readonly ModelCapability[]

    Capabilities this model supports

    Methods

    • (Optional, #2529) List models served by this adapter's endpoint.

      Implemented by adapters facing OpenAI-compatible endpoints (the upstream OpenAI API, OpenRouter, vLLM, custom gateways, etc.) — usually wraps GET /v1/models. Result is the harness-side identity resolver's most-trusted signal for "what model is actually being served behind this adapter."

      Subprocess-CLI adapters (claude / codex / gemini / opencode) leave this undefined; identity for those falls back to modelId parse.

      Implementations should cache the result for ~5 minutes — operators shouldn't pay round-trip latency on every resolve. Failures (network error, endpoint unsupported, auth missing) should throw so the caller can fall back; do NOT silently return an empty list.

      Returns Promise<readonly ModelMetadata[]>