Documentation
¶
Overview ¶
Package anthropic provides a minimal Claude Messages API client.
Index ¶
Constants ¶
const (
// ModelHaiku is the default model — fast and cheap (~$0.001/command).
ModelHaiku = "claude-haiku-4-5-20251001"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
StatusCode int
Type string `json:"type"`
ErrorBody struct {
Type string `json:"type"`
Message string `json:"message"`
} `json:"error"`
}
APIError is returned when the API responds with a non-2xx status.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a minimal Anthropic Messages API client.
type ContentBlock ¶
ContentBlock is a single block in the response.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithBaseURL ¶
WithBaseURL overrides the API base URL (useful for testing).
func WithHTTPClient ¶
WithHTTPClient overrides the default HTTP client.
type Request ¶
type Request struct {
Model string `json:"model"`
MaxTokens int `json:"max_tokens"`
System string `json:"system,omitempty"`
Messages []Message `json:"messages"`
}
Request is the Messages API request body.
type Response ¶
type Response struct {
ID string `json:"id"`
Type string `json:"type"`
Role string `json:"role"`
Content []ContentBlock `json:"content"`
Model string `json:"model"`
StopReason string `json:"stop_reason"`
StopSequence *string `json:"stop_sequence"`
Usage Usage `json:"usage"`
}
Response is the Messages API response body.