Documentation
¶
Overview ¶
Package api re-exports the internal/api surface via type aliases. External consumers (e.g., iterion) import this package; the ~50 internal consumers continue importing internal/api unchanged. Type aliases ensure identical types at compile time — no conversion needed.
Index ¶
- Constants
- Variables
- type APIClient
- type APIError
- type AuthMethod
- type AuthSource
- type AuthSourceKind
- type CacheControlMarker
- type Client
- type ContentBlock
- type ContentBlockInfo
- type CreateMessageRequest
- type Delta
- type ForeignProviderEnvVar
- type ImageSource
- type InputSchema
- type Message
- type MessageDelta
- type ModelPricing
- type OAuthTokenSet
- type Property
- type Provider
- type ProviderConfig
- type SseFrame
- type SseParser
- type StreamEvent
- type StreamEventType
- type Tool
- type ToolChoice
- type ToolResult
- type UsageDelta
Constants ¶
const ( AuthSourceNone = api.AuthSourceNone AuthSourceAPIKey = api.AuthSourceAPIKey AuthSourceBearer = api.AuthSourceBearer AuthSourceCombined = api.AuthSourceCombined )
const ( AuthMethodOAuth = api.AuthMethodOAuth AuthMethodAPIKey = api.AuthMethodAPIKey AuthMethodIAM = api.AuthMethodIAM AuthMethodADC = api.AuthMethodADC AuthMethodAzureIdentity = api.AuthMethodAzureIdentity )
const ( EventMessageStart = api.EventMessageStart EventContentBlockStart = api.EventContentBlockStart EventContentBlockDelta = api.EventContentBlockDelta EventContentBlockStop = api.EventContentBlockStop EventMessageDelta = api.EventMessageDelta EventMessageStop = api.EventMessageStop EventError = api.EventError EventPing = api.EventPing )
Variables ¶
var APIKeyAuth = api.APIKeyAuth
APIKeyAuth returns an AuthSource using an API key.
var BearerAuth = api.BearerAuth
BearerAuth returns an AuthSource using a bearer token.
var CombinedAuth = api.CombinedAuth
CombinedAuth returns an AuthSource using both API key and bearer token.
var EnrichBearerAuthError = api.EnrichBearerAuthError
EnrichBearerAuthError adds a helpful hint for sk-ant-* bearer token misuse.
var EphemeralCacheControl = api.EphemeralCacheControl
EphemeralCacheControl returns a cache_control marker with type "ephemeral".
var IsRetryableStatus = api.IsRetryableStatus
IsRetryableStatus returns true for HTTP status codes that warrant a retry (408, 409, 429, 5xx). Providers that build *APIError values populate the Retryable field from this function.
var NoAuth = api.NoAuth
NoAuth returns an AuthSource with no credentials.
var ResolveStartupAuth = api.ResolveStartupAuth
ResolveStartupAuth resolves auth from environment variables.
var ResolveStartupAuthWithOAuth = api.ResolveStartupAuthWithOAuth
ResolveStartupAuthWithOAuth resolves auth with OAuth fallback.
var SuggestForeignProvider = api.SuggestForeignProvider
SuggestForeignProvider checks whether a foreign provider's API key is set.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
APIError is the typed error returned by provider clients when an upstream API call yields a non-2xx HTTP response. Detect it via errors.As to drive retry / classification logic on top.
type AuthMethod ¶
type AuthMethod = api.AuthMethod
AuthMethod describes how a provider authenticates.
type AuthSource ¶
type AuthSource = api.AuthSource
AuthSource holds authentication credentials for API requests.
type AuthSourceKind ¶
type AuthSourceKind = api.AuthSourceKind
AuthSourceKind discriminates AuthSource variants.
type CacheControlMarker ¶
type CacheControlMarker = api.CacheControlMarker
CacheControlMarker is the Anthropic prompt caching marker.
type ContentBlock ¶
type ContentBlock = api.ContentBlock
ContentBlock represents a single content block in a message.
type ContentBlockInfo ¶
type ContentBlockInfo = api.ContentBlockInfo
ContentBlockInfo holds info about a starting content block.
type CreateMessageRequest ¶
type CreateMessageRequest = api.CreateMessageRequest
CreateMessageRequest is the request body for /v1/messages.
type ForeignProviderEnvVar ¶
type ForeignProviderEnvVar = api.ForeignProviderEnvVar
ForeignProviderEnvVar describes a non-Anthropic provider's env var.
func ForeignProviderEnvVars ¶
func ForeignProviderEnvVars() []ForeignProviderEnvVar
ForeignProviderEnvVars returns a defensive copy of the foreign provider env var list. This prevents callers from mutating the backing slice.
type ImageSource ¶
type ImageSource = api.ImageSource
ImageSource is the "source" object on an Anthropic image content block. See https://docs.anthropic.com/en/docs/build-with-claude/vision.
type InputSchema ¶
type InputSchema = api.InputSchema
InputSchema is the JSON schema for tool inputs.
type MessageDelta ¶
type MessageDelta = api.MessageDelta
MessageDelta is the delta in a message_delta event.
type ModelPricing ¶
type ModelPricing struct {
InputUSDPerMillion float64
OutputUSDPerMillion float64
Source string // "live" when sourced from the OpenRouter cache; "" if not found
}
ModelPricing is the per-million-token cost for a model in USD. Zero on either field means "unknown" — the live source did not publish pricing for that model and the caller should treat zero as "skip cost emission" rather than reporting $0.
func LookupModelPricing ¶
func LookupModelPricing(model string) (ModelPricing, bool)
LookupModelPricing returns the per-million-token cost for the given model, sourced from claw's live registry cache (OpenRouter, refreshed async every 24h). Provider-prefixed and tenant-prefixed model specs are stripped down to the trailing canonical name so callers can pass either "anthropic/claude-sonnet-4-6" or "claude-sonnet-4-6".
Returns ok=false when:
- the live cache has not yet been populated (cold start, no network) and the model is not in the embed registry
- the cache exists but the model has no pricing field
- the live registry was disabled via CLAW_DISABLE_LIVE_REGISTRY=1
Callers concerned with hard budget tracking should still pull authoritative rates from their provider's invoices — this is a best-effort observability hint that follows OpenRouter's posted pricing.
type OAuthTokenSet ¶
type OAuthTokenSet = api.OAuthTokenSet
OAuthTokenSet represents a saved OAuth token set for auth resolution.
type ProviderConfig ¶
type ProviderConfig = api.ProviderConfig
ProviderConfig holds the credentials and settings needed to create a provider client.
type SseParser ¶
SseParser is a byte-buffer state machine for parsing Server-Sent Events.
func NewSseParser ¶
func NewSseParser() *SseParser
NewSseParser creates a new SSE parser with an empty buffer.
type StreamEvent ¶
type StreamEvent = api.StreamEvent
StreamEvent is a parsed SSE event from the streaming API.
type StreamEventType ¶
type StreamEventType = api.StreamEventType
StreamEventType enumerates the SSE event types.
type ToolChoice ¶
type ToolChoice = api.ToolChoice
ToolChoice controls which tool the model must use.
type ToolResult ¶
type ToolResult = api.ToolResult
ToolResult is a convenience wrapper for building tool_result content blocks.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package hooks is the public façade over the internal lifecycle hooks runner.
|
Package hooks is the public façade over the internal lifecycle hooks runner. |
|
Package lsp is the public façade over the internal LSP subsystem that backs the `lsp` tool.
|
Package lsp is the public façade over the internal LSP subsystem that backs the `lsp` tool. |
|
Package mcp is the public façade over the internal MCP subsystem that backs the list_mcp_resources / read_mcp_resource / mcp_auth tools and the SSE/HTTP transports.
|
Package mcp is the public façade over the internal MCP subsystem that backs the list_mcp_resources / read_mcp_resource / mcp_auth tools and the SSE/HTTP transports. |
|
oauth
Package oauth is the public façade over the internal MCP OAuth broker.
|
Package oauth is the public façade over the internal MCP OAuth broker. |
|
providers
|
|
|
anthropic
Package anthropic re-exports the internal Anthropic provider via type alias.
|
Package anthropic re-exports the internal Anthropic provider via type alias. |
|
bedrock
Package bedrock re-exports the internal Bedrock provider via type alias.
|
Package bedrock re-exports the internal Bedrock provider via type alias. |
|
foundry
Package foundry re-exports the internal Azure AI Foundry provider via type alias.
|
Package foundry re-exports the internal Azure AI Foundry provider via type alias. |
|
openai
Package openai re-exports the internal OpenAI provider via type alias.
|
Package openai re-exports the internal OpenAI provider via type alias. |
|
vertex
Package vertex re-exports the internal Vertex AI provider via type alias.
|
Package vertex re-exports the internal Vertex AI provider via type alias. |
|
Package task is the public façade over the internal task subsystem that backs the task_* tools.
|
Package task is the public façade over the internal task subsystem that backs the task_* tools. |
|
Package team is the public façade over the internal team subsystem that backs the team_* and cron_* tools.
|
Package team is the public façade over the internal team subsystem that backs the team_* and cron_* tools. |
|
Package tools exposes a stable public-API surface over the built-in tool implementations that ship with claw-code-go.
|
Package tools exposes a stable public-API surface over the built-in tool implementations that ship with claw-code-go. |
|
Package worker is the public façade over the internal worker subsystem that backs the worker_* tools.
|
Package worker is the public façade over the internal worker subsystem that backs the worker_* tools. |