api

package
v0.0.0-...-23898a9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2026 License: MIT Imports: 3 Imported by: 0

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

View Source
const (
	AuthSourceNone     = api.AuthSourceNone
	AuthSourceAPIKey   = api.AuthSourceAPIKey
	AuthSourceBearer   = api.AuthSourceBearer
	AuthSourceCombined = api.AuthSourceCombined
)
View Source
const (
	AuthMethodOAuth         = api.AuthMethodOAuth
	AuthMethodAPIKey        = api.AuthMethodAPIKey
	AuthMethodIAM           = api.AuthMethodIAM
	AuthMethodADC           = api.AuthMethodADC
	AuthMethodAzureIdentity = api.AuthMethodAzureIdentity
)
View Source
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

View Source
var APIKeyAuth = api.APIKeyAuth

APIKeyAuth returns an AuthSource using an API key.

View Source
var BearerAuth = api.BearerAuth

BearerAuth returns an AuthSource using a bearer token.

View Source
var CombinedAuth = api.CombinedAuth

CombinedAuth returns an AuthSource using both API key and bearer token.

View Source
var EnrichBearerAuthError = api.EnrichBearerAuthError

EnrichBearerAuthError adds a helpful hint for sk-ant-* bearer token misuse.

View Source
var EphemeralCacheControl = api.EphemeralCacheControl

EphemeralCacheControl returns a cache_control marker with type "ephemeral".

View Source
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.

View Source
var NoAuth = api.NoAuth

NoAuth returns an AuthSource with no credentials.

View Source
var ResolveStartupAuth = api.ResolveStartupAuth

ResolveStartupAuth resolves auth from environment variables.

View Source
var ResolveStartupAuthWithOAuth = api.ResolveStartupAuthWithOAuth

ResolveStartupAuthWithOAuth resolves auth with OAuth fallback.

View Source
var SuggestForeignProvider = api.SuggestForeignProvider

SuggestForeignProvider checks whether a foreign provider's API key is set.

Functions

This section is empty.

Types

type APIClient

type APIClient = api.APIClient

APIClient is the interface all provider clients must implement.

type APIError

type APIError = api.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 Client

type Client = api.Client

Client is the Anthropic HTTP API client.

func NewClient

func NewClient(apiKey, model string) *Client

NewClient creates a new API client with the given API key and model.

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 Delta

type Delta = api.Delta

Delta represents the delta portion of a content_block_delta event.

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 Message

type Message = api.Message

Message represents a single message in the conversation.

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 Property

type Property = api.Property

Property is a single JSON schema property definition.

type Provider

type Provider = api.Provider

Provider is the interface all AI providers must implement.

type ProviderConfig

type ProviderConfig = api.ProviderConfig

ProviderConfig holds the credentials and settings needed to create a provider client.

type SseFrame

type SseFrame = api.SseFrame

SseFrame is a raw parsed SSE frame before JSON deserialization.

type SseParser

type SseParser = api.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 Tool

type Tool = api.Tool

Tool describes a tool that can be called by the model.

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.

type UsageDelta

type UsageDelta = api.UsageDelta

UsageDelta contains token usage info.

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.
mcp
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL