The Anthropic adapter reaches Claude at full fidelity — extended thinking, prompt caching, native tool calling. It is the only adapter that lives in its own Go module.
Installing#
go get github.com/BAGOMBEKA-JOB-DEV/skyl/provider/anthropicimport "github.com/BAGOMBEKA-JOB-DEV/skyl/provider/anthropic"import "github.com/BAGOMBEKA-JOB-DEV/skyl/provider/anthropic"Requires Go 1.24+, inherited from anthropic-sdk-go.
Reference#
Parameters
apiKey— your Anthropic credential. Sent as thex-api-keyheader.opts— functional options, applied in order.
| Option | Signature | Default | Description |
|---|---|---|---|
WithBaseURL | func WithBaseURL(url string) Option | Anthropic's own host | Overrides the API host. Point it at the sandbox to develop without a credential. |
WithHTTPClient | func WithHTTPClient(hc *http.Client) Option | http.DefaultClient | Supplies the *http.Client used for every request. This is where you set transport timeouts, proxies, or OpenTelemetry trace propagation. |
WithHeader | func WithHeader(key, value string) Option | — | Adds a fixed header to every request — beta feature flags, for instance. Headers are set at construction; ProviderOptions never sets headers on any adapter. |
Caveats
- This is a separate module.
go geton the core library does not bring it, and it raises your Go floor to 1.24. That split is deliberate — see ADR-0006. MaxTokensdefaults to 4096 when you leave it zero. Anthropic's API requires the field, so skyl supplies a value rather than failing a request every other provider would accept. It is the only substituted default in the library.ProviderOptionsuses JSON paths here, not a shallow merge — so"thinking.budget_tokens": 4096sets one nested field without disturbing its siblings. A top-level key containing a.is therefore interpreted as a path.Thinking.Effortis ignored. The SDK's adaptive thinking config has no budget or effort field.- Tool schemas are reconstructed, not forwarded.
$defs,$refandoneOfsurvive; the top-leveltypeis forced to"object"and non-string entries inrequiredare dropped.
What only this adapter does#
| Capability | Elsewhere |
|---|---|
Emits EventThinkingDelta | Never emitted by the other three |
Reports Usage.CacheWriteTokens | Always zero — no wire field |
Delivers ToolResult.IsError as a real boolean | Lossy on OpenAI, dropped on Gemini |
ProviderOptions by JSON path | Shallow top-level merge |
Reports StopStopSequence | Reported as plain stop/STOP |
Usage#
Constructing
p := anthropic.New(os.Getenv("ANTHROPIC_API_KEY"))
client := skyl.New(p)p := anthropic.New(os.Getenv("ANTHROPIC_API_KEY"))
client := skyl.New(p)Against the sandbox, with no credential
p := anthropic.New("sandbox-key",
anthropic.WithBaseURL("http://127.0.0.1:8099/anthropic"))p := anthropic.New("sandbox-key",
anthropic.WithBaseURL("http://127.0.0.1:8099/anthropic"))Prompt caching
// JSON-path options work only here, which is what makes this reachable
// without restating the whole system field.
req.ProviderOptions = map[string]any{
"system.0.cache_control": map[string]any{"type": "ephemeral"},
}// JSON-path options work only here, which is what makes this reachable
// without restating the whole system field.
req.ProviderOptions = map[string]any{
"system.0.cache_control": map[string]any{"type": "ephemeral"},
}Then Usage.CacheReadTokens tells you how much of InputTokens was discounted.
A precise thinking budget
// Effort is ignored on this adapter; the budget is reachable by path.
req.Thinking = &skyl.Thinking{Enabled: true}
req.ProviderOptions = map[string]any{"thinking.budget_tokens": 4096}// Effort is ignored on this adapter; the budget is reachable by path.
req.Thinking = &skyl.Thinking{Enabled: true}
req.ProviderOptions = map[string]any{"thinking.budget_tokens": 4096}A beta feature header
// Headers are fixed at construction. ProviderOptions never sets headers.
p := anthropic.New(key, anthropic.WithHeader("anthropic-beta", "some-feature-2026-01-01"))// Headers are fixed at construction. ProviderOptions never sets headers.
p := anthropic.New(key, anthropic.WithHeader("anthropic-beta", "some-feature-2026-01-01"))Troubleshooting#
The build fails mentioning the go directive
You are on Go 1.22 or 1.23. This module requires 1.24, inherited from the SDK. Upgrade Go — the core library still works on 1.22 if you drop this adapter.
My tool's required list is not enforced
Non-string entries in required are dropped by this adapter. A schema loaded
from JSON decodes them as []any. Convert to []string.
Setting a ProviderOptions key with a dot did something unexpected
Keys are JSON paths on this adapter. "a.b" sets b inside a, not a
top-level key literally named a.b. This is the only adapter where a key's
spelling changes its meaning.
Effort had no effect
It is dropped here. Use thinking.budget_tokens through ProviderOptions.