Documentation
¶
Overview ¶
Package anthropic is a thin wrapper around the official Anthropic SDK (github.com/anthropics/anthropic-sdk-go), used to validate a user-supplied API key (via ListModels, a zero-token metadata call) and to run single-turn, non-streaming completions (via Complete) for the tract engine's "Call LLM" step.
No streaming, no tool use, no multi-turn conversation — deliberately out of scope for this first pass. See docs/byok/04_tract_llm_step.md for the full design rationale.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StatusCode ¶
StatusCode extracts the HTTP status code from an error returned by this client, when the error originated from an actual API response (as opposed to a network-level failure like a timeout or DNS error, which the SDK does not wrap in *sdk.Error). ok is false for those network-level cases.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Anthropic SDK client with the narrow surface the connection service and tract engine actually need.
func New ¶
New constructs a Client authenticated with apiKey. If baseUrl is non-empty, it overrides the SDK's default API host (e.g. for a proxy or regional endpoint).
func (*Client) Complete ¶
func (c *Client) Complete(ctx context.Context, req CompleteRequest) (CompleteResult, error)
Complete performs a single-turn, non-streaming call to the Messages API.
func (*Client) ListModels ¶
ListModels wraps the SDK's models-list call (GET /v1/models). It is a metadata endpoint — no beta header, zero tokens billed — so it doubles as the key-validation call: an auth failure surfaces here as an error before any completion is ever attempted.
func (*Client) Ping ¶
Ping confirms apiKey authenticates and model is usable by sending the cheapest possible completion request, discarding the reply. It exists as a fallback key-validation path for providers whose Anthropic-compatible endpoint doesn't implement GET /v1/models (ListModels) — common for third-party proxies that only mirror the Messages API surface.
type CompleteRequest ¶
CompleteRequest is a single-turn, non-streaming completion request: one user message (Prompt), an optional SystemPrompt, and a model. No tool use, no thinking, no history.
type CompleteResult ¶
CompleteResult is the text of the model's reply plus its token usage.