Anthropic Provider
Updated 19 days ago • May 3, 2026
@kortyx/anthropic is the Anthropic Claude provider package for Kortyx.
It gives you two entry points:
anthropic: a batteries-included default provider selectorcreateAnthropic(...): an explicit factory for custom setup
1. Install the package
2. What the package exports
What each export is for:
anthropic: default provider selector for the fastest startcreateAnthropic(...): custom provider instance with explicit settingsMODELS: built-in Anthropic model ids exposed by the packagePROVIDER_ID: the provider id string, currently"anthropic"
3. Basic usage in the same file
anthropic is a provider selector, which means:
- it is callable:
anthropic("claude-sonnet-4-5") - it also exposes provider metadata:
anthropic.id,anthropic.models
Good to know: The built-in model list gives autocomplete, but arbitrary Anthropic model ids are accepted as strings.
4. Shared app bootstrap usage
If you want one shared import path across your app, re-export anthropic from a bootstrap file such as src/lib/providers.ts.
Then import it from that file where you actually use it:
5. Advanced usage with explicit settings
Use createAnthropic(...) when you want app-owned configuration instead of the default environment-based setup.
Use the factory when you need to:
- pass
apiKeyexplicitly - pass
authTokenexplicitly - use a custom
baseUrl - provide a custom
fetch
Good to know:
createAnthropic(...)accepts eitherapiKeyorauthToken, not both.
6. Credentials and first-use behavior
The default anthropic export resolves credentials on first use, not at import time.
Supported API key environment variables:
ANTHROPIC_API_KEYKORTYX_ANTHROPIC_API_KEY
Supported auth token environment variables:
ANTHROPIC_AUTH_TOKENKORTYX_ANTHROPIC_AUTH_TOKEN
If no supported credential is set and you did not pass credentials to createAnthropic(...), the provider throws a configuration error the first time an Anthropic model is actually used.
7. Create model refs for workflow and node params
You can also attach default model options to the ref itself:
Those become default options for later useReason(...) calls unless you override them at call time.
8. Use the model with useReason(...)
Good to know: Provider setup is not done on
createAgent(...). Model selection happens where you calluseReason(...)by passing a model ref.
9. Supported normalized call options
Anthropic currently maps these generic Kortyx options:
temperaturestreamingmaxOutputTokensstopSequencesabortSignalreasoning.effortreasoning.maxTokensreasoning.includeThoughtsresponseFormat.type
Current Anthropic provider options:
providerOptions.anthropic.thinkingproviderOptions.anthropic.topKproviderOptions.anthropic.top_kproviderOptions.anthropic.topPproviderOptions.anthropic.top_p
Current mapping details:
- system messages map to Anthropic
system - adjacent user or assistant messages are merged for the Messages API
responseFormat.type: "json"maps through system instructionsreasoning.*maps to Anthropic thinking configuration
Current warning-backed gaps:
temperatureis omitted when Anthropic thinking is enabled- Anthropic JSON mode is instruction-based in this provider, not a provider-native JSON schema request
- generic
reasoning.effortwithoutreasoning.maxTokensmaps to the minimum supported thinking budget - unknown
providerOptionskeys are ignored and reported inresult.warnings
10. Normalized metadata you get back
Anthropic returns the normalized Kortyx result fields when the API provides them:
usagefinishReasonproviderMetadatawarningsraw
Anthropic-specific metadata currently includes fields such as:
providerIdmodelIdresponseIdresponseModelstopSequenceusagecacheReadTokenscacheWriteTokensserverToolUse
Use providerMetadata when you need debugging or observability details without coupling your app code to the raw provider payload shape.
Supported scope
@kortyx/anthropic currently supports text generation through the Anthropic Messages API via useReason(...), including streaming and non-streaming invocation.
It does not currently expose provider-native file APIs, skills, tool execution, or multimodal output APIs. Check result.warnings when you rely on advanced generic options and want to verify how Anthropic handled them.
Available built-in Anthropic model ids
claude-sonnet-4-5claude-sonnet-4-5-20250929claude-haiku-4-5claude-haiku-4-5-20251001claude-opus-4-5claude-opus-4-5-20251101claude-sonnet-4-0claude-sonnet-4-20250514claude-opus-4-1claude-opus-4-1-20250805claude-3-haiku-20240307
Next steps
- See Hooks for
useReason(...)behavior and structured output - See Provider API for the shared normalized provider contract