import type * as plugins from './plugins.js'; /** The Anthropic API every OAuth and API-key request goes to; the AI SDK's versioned base URL. */ export declare const ANTHROPIC_API_BASE_URL = "https://api.anthropic.com/v1"; /** * The beta a Claude subscription OAuth access token is accepted under. Claude Code 2.1.282 adds it to its own * requests exactly when it holds such a token (its `oauth_auth` beta, `oauth-2025-04-20`). */ export declare const ANTHROPIC_OAUTH_BETA = "oauth-2025-04-20"; /** The Messages API version Claude Code and the AI SDK send. */ export declare const ANTHROPIC_API_VERSION = "2023-06-01"; /** Whether a failed request reached the provider: `notSent` never did, `outcomeUnknown` may have. */ export type TAnthropicOAuthRequestOutcome = 'notSent' | 'outcomeUnknown'; export declare class AnthropicOAuthAuthError extends Error { status?: number; requestOutcome?: TAnthropicOAuthRequestOutcome; constructor(message: string, options?: { status?: number; requestOutcome?: TAnthropicOAuthRequestOutcome; }); } /** The Claude account and organization a connection is pinned to for its lifetime, as the authority states them. */ export interface IAnthropicOAuthIdentity { readonly accountUuid: string; readonly organizationUuid: string; } /** A Claude subscription OAuth access token, read for itself alone. */ export interface IAnthropicOAuthReadAccess { readonly accessToken: string; } /** Access to one Claude account, as an account authority resolves it. */ export interface IAnthropicOAuthAccessGrant extends IAnthropicOAuthReadAccess, IAnthropicOAuthIdentity { /** * The authority's generation of this access token. When it is set and the provider rejects the token, the * connection resolves once more naming this generation, so the authority can renew exactly that token. */ readonly generation?: number; } export interface IAnthropicOAuthAccessResolveRequest { /** The provider request signal. A resolver should pass it through to its authority. */ readonly signal: AbortSignal; /** The generation of the access token the provider has just rejected with 401. */ readonly rejectedGeneration?: number; } export interface IAnthropicOAuthResolvingConnectionOptions { /** Every resolved access must state exactly this account and organization. */ readonly expectedIdentity: IAnthropicOAuthIdentity; /** Resolves current access immediately before every provider request. */ readonly resolveAccess: (request: IAnthropicOAuthAccessResolveRequest) => Promise; /** Optional underlying transport. Defaults to the current global fetch. */ readonly fetch?: typeof fetch; } /** The provider owns inference; an authentication component supplies this connection. */ export interface IAnthropicModelConnection { settings: plugins.AnthropicProviderSettings; middleware?: plugins.LanguageModelV4Middleware; /** Reads this connection's own limit dialect first; the Anthropic API dialect handles the rest. */ classifyLimit?: plugins.TModelLimitClassifier; } /** Whether a request URL is under `ANTHROPIC_API_BASE_URL` and carries no credentials. Shared by both kinds of login. */ export declare function isAnthropicApiRequestUrl(urlArg: string): boolean; /** A comma-separated `anthropic-beta` value with the OAuth beta added once, keeping the caller's order. */ export declare function mergeAnthropicOAuthBeta(valueArg: string | null): string; /** * The headers an OAuth request authenticates with, over the request's own: the bearer token replaces any * credential the request carried (an `x-api-key` included), the OAuth beta joins the request's betas, and the API * version is the request's or `2023-06-01`. Shared by inference and the model list. */ export declare function createAnthropicOAuthHeaders(accessArg: IAnthropicOAuthReadAccess, headersArg?: HeadersInit): Headers; /** * An Anthropic API connection on a Claude subscription OAuth login that resolves its access before every request. * * Requests go only to `https://api.anthropic.com/v1`. The account and organization are pinned at construction; * an access that states another stops the request before the transport is called. A provider 401 is answered * once: when the rejected access carried a `generation`, the connection resolves again with `rejectedGeneration` * and sends the request a second time with the new access. A 401 that cannot be retried, and a second 401, fail * with an `AnthropicOAuthAuthError` whose `status` is 401. Every other status is the caller's. */ export declare const createAnthropicOAuthResolvingConnection: (optionsArg: IAnthropicOAuthResolvingConnectionOptions) => IAnthropicModelConnection; /** An effort level a request can ask a model for: the Messages API's `output_config.effort`, as the AI SDK sends it. */ export type TAnthropicEffort = NonNullable; /** Every effort level a request can name, lowest first. */ export declare const ANTHROPIC_EFFORTS: readonly TAnthropicEffort[]; /** A model an account may use, as the Anthropic API lists it. */ export interface IAnthropicOAuthModel { providerId: 'anthropic'; modelId: string; displayName: string; /** RFC 3339 release time, when the API states one. */ createdAt?: string; /** The context window in tokens, when the API states it. */ maxInputTokens?: number; /** The output limit in tokens, when the API states it. */ maxOutputTokens?: number; /** * The effort levels the model accepts, lowest first, when the API states its effort capability; empty when it * states the model takes none. Only levels a request can name (`ANTHROPIC_EFFORTS`) are listed. */ efforts?: TAnthropicEffort[]; /** Whether the model accepts adaptive thinking (`thinking: { type: 'adaptive' }`), when the API states it. */ adaptiveThinking?: boolean; } /** * Why a model list read failed, other than a rejected access token or an abort. * * - `NETWORK_FAILED`: the request did not complete. * - `HTTP_ERROR`: the API answered with an error status other than 401; `status` names it. * - `PROTOCOL_ERROR`: the answer was oversized or not a model list this package can read. */ export type TAnthropicOAuthModelListErrorCode = 'NETWORK_FAILED' | 'HTTP_ERROR' | 'PROTOCOL_ERROR'; export declare class AnthropicOAuthModelListError extends Error { readonly code: TAnthropicOAuthModelListErrorCode; readonly status?: number; constructor(codeArg: TAnthropicOAuthModelListErrorCode, statusArg?: number); } export interface IAnthropicOAuthModelListOptions { signal?: AbortSignal; /** Optional underlying transport. Defaults to the current global fetch. */ fetch?: typeof fetch; } /** * Reads the models a Claude subscription OAuth login may use: `GET /v1/models` with the bearer token and the * OAuth beta, as Claude Code's model-capability read does (`models.list({ betas: [oauth-2025-04-20], limit: 1000 })`), * following `has_more` with `after_id` across at most ten pages. A rejected access token fails with an * `AnthropicOAuthAuthError` whose `status` is 401, so a caller that holds a renewable access resolves it again * and repeats the read. An abort rejects with the signal's reason; every other failure is an * `AnthropicOAuthModelListError`. */ export declare function listAnthropicOAuthModels(accessArg: IAnthropicOAuthReadAccess, optionsArg?: IAnthropicOAuthModelListOptions): Promise; /** * Reads `GET /v1/models` with the headers a login authenticates with, following `has_more` with `after_id` across at * most ten pages. A 401 fails with the login's own error; an abort rejects with the signal's reason; every other * failure is an `AnthropicOAuthModelListError`. Shared by both kinds of login. */ export declare function readAnthropicModelList(headersArg: Headers, transportArg: typeof fetch, signalArg: AbortSignal | undefined, rejectedArg: () => Error): Promise;