Claude

constructor(name: String, client: AnthropicClient, maxTokens: Int = DEFAULT_MAX_TOKENS, effort: OutputConfig.Effort? = null)

Parameters

client

The Anthropic SDK client that sends the requests; the caller owns and closes it.

maxTokens

The default max_tokens (8192), used when the request config sets none.

effort

How much reasoning effort Claude spends on each request; null leaves the model's default. While effort or thinking is on, temperature, topP, and topK are not sent.


constructor(name: String, apiKey: String? = null, maxTokens: Int = DEFAULT_MAX_TOKENS, effort: OutputConfig.Effort? = null)

Creates a Claude model that calls the Anthropic API directly. The SDK client it creates is closed when the model is garbage collected; pass your own AnthropicClient to close it sooner.

Parameters

name

The Claude model name (e.g. claude-sonnet-4-5).

apiKey

The Anthropic API key; when null or blank, the SDK reads credentials from the environment, such as ANTHROPIC_API_KEY.

maxTokens

The default max_tokens (8192), used when the request config sets none.

effort

How much reasoning effort Claude spends on each request; null leaves the model's default. While effort or thinking is on, temperature, topP, and topK are not sent.

Throws

If no API key is passed and the environment has no credential.


constructor(name: String, vertexCredentials: VertexCredentials, maxTokens: Int = DEFAULT_MAX_TOKENS, effort: OutputConfig.Effort? = null)

Creates a Claude model served through Vertex AI. The SDK client it creates is closed when the model is garbage collected; pass your own AnthropicClient to close it sooner.

Parameters

name

The Claude model id as published on Vertex AI (e.g. claude-haiku-4-5), or its full resource name, which also names the project and location.

vertexCredentials

The Vertex AI project, location, and credentials. Project and location fall back to those in a resource name, then to the GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION environment variables; credentials default to Application Default Credentials.

maxTokens

The default max_tokens (8192), used when the request config sets none.

effort

How much reasoning effort Claude spends on each request; null leaves the model's default. While effort or thinking is on, temperature, topP, and topK are not sent.

Throws

If no project or location is set.

If no credentials are set and Application Default Credentials are unavailable.