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

    Class ClaudeAdapter

    Claude/Anthropic model adapter.

    Provides a unified interface for interacting with Anthropic's Claude models. Supports completion, streaming, tool use, and vision capabilities.

    const adapter = new ClaudeAdapter({
    modelId: 'claude-sonnet-4',
    apiKey: process.env.ANTHROPIC_API_KEY,
    });

    const result = await adapter.complete({
    messages: [{ role: 'user', content: 'Hello!' }],
    maxTokens: 1024,
    });

    if (result.ok) {
    console.log(result.value.content);
    }

    Hierarchy (View Summary)

    Index

    Constructors

    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

    logger: ILogger

    Logger for request/response logging

    Configuration for the adapter

    Methods

    • Transform a provider-specific error into a standardized ModelError.

      Maps common error patterns to appropriate error codes:

      • Rate limiting (429, quota exceeded)
      • Timeouts (ETIMEDOUT, ESOCKETTIMEDOUT)
      • Authentication (401, 403)
      • Model unavailable (503, 502)

      Parameters

      • error: unknown

        The original error from the provider

      Returns ModelError

      A standardized ModelError

    • Count tokens in text using Claude-specific estimation.

      Claude uses a custom tokenizer. This provides a more accurate estimate than the base adapter's generic calculation.

      Parameters

      • text: string

        Text to count tokens for

      Returns Promise<number>

      Approximate token count

    • (#2540) List models the Anthropic API currently exposes. Wraps client.models.list(). Cached for 5 min, in-flight promise shared across concurrent callers, throws on non-2xx so the harness-side identity resolver knows to fall back.

      Returns Promise<readonly ModelMetadata[]>