cavi-ai/
@cavi-ai/api-clientv0.11.0 stable
GitHub ↗

@cavi-ai/api-client/providers/claude/messages

Package subpath: ./providers/claude/messages

CLAUDE_RUNTIME_SUPPORT

Kind: variable

ts
export declare const CLAUDE_RUNTIME_SUPPORT: Readonly<{
    runs: true;
    streaming: true;
    batch: true;
}>;

ClaudeApiClient

Kind: class

ts
export declare class ClaudeApiClient extends BaseHttpApiClient implements RuntimeClient {
    readonly request: HttpApiTransport;
    private readonly defaultModel?;
    private readonly defaultMaxTokens;
    constructor(options: ClaudeApiClientOptions);
    getRuntimeCapabilities(): Promise<RuntimeCapabilities>;
    startRun(body: RuntimeRunStartBody): Promise<RuntimeRunStatus>;
    /**
     * Start a run and stream it as canonical RunStreamEvents. Anthropic starts
     * and streams in one POST (stream:true), so there is no prior runId — it is
     * captured from the message_start event. (Finding F4: this is why Claude uses
     * streamRun rather than RunEventStreamProvider.subscribe(runId).)
     */
    streamRun(body: RuntimeRunStartBody, handlers: RunEventStreamHandlers, options?: {
        signal?: AbortSignal;
    }): Promise<void>;
    getRun(_runId: string): Promise<RuntimeRunStatus>;
    cancelRun(_runId: string): Promise<{
        status: string;
    }>;
    submitBatch(requests: RuntimeBatchRequest[]): Promise<RuntimeBatchStatus>;
    getBatch(batchId: string): Promise<RuntimeBatchStatus>;
    cancelBatch(batchId: string): Promise<RuntimeBatchStatus>;
    getBatchResults(batchId: string): Promise<RuntimeBatchResult[]>;
    private stateless;
}

ClaudeApiClientOptions

Kind: type

ts
export type ClaudeApiClientOptions = {
    apiKey: string;
    /** Default model when a run does not specify one. */
    defaultModel?: string;
    /** Default max_tokens when a run does not specify one (Anthropic requires it). */
    defaultMaxTokens?: number;
    anthropicVersion?: string;
    baseUrl?: string;
    fetchImpl?: typeof fetch;
    onTrace?: HttpApiClientOptions["onTrace"];
};

createClaudeProviderModule

Kind: function

ts
/**
 * Build the runtime-only Claude (Anthropic) provider module. The Anthropic API
 * key is captured here, so `createApiClient` needs no cast — the registry's
 * HttpApiClientOptions (baseUrl/fetchImpl/onTrace) merge over the captured
 * config. (Resolves spike finding F2b.)
 *
 * Claude is not a gateway — no teams, kanban, workspace, or WS-RPC. It
 * implements the universal RuntimeClient only and registers via
 * createRuntimeProviderRegistry (F2).
 */
export declare function createClaudeProviderModule(config: ClaudeApiClientOptions): RuntimeProviderModule;

mapAnthropicStreamEvent

Kind: function

ts
/**
 * Map one Anthropic Messages SSE event to a canonical RunStreamEvent.
 * Returns null for events with no RunStreamEvent equivalent (message_start,
 * ping, content_block_start/stop, message_delta) — the caller skips those.
 * `runId` is supplied by the caller (captured from `message_start`).
 */
export declare function mapAnthropicStreamEvent(sse: SseMessage, runId: string): RunStreamEvent | null;

readAnthropicRunId

Kind: function

ts
/** Extract the run id from an Anthropic `message_start` SSE event, if present. */
export declare function readAnthropicRunId(sse: SseMessage): string | null;