Documentation
¶
Overview ¶
Package cloudflaregateway provides Cloudflare AI Gateway's documented OpenAI, Responses, and Anthropic proxy endpoints.
Index ¶
- func New(selected model.Model, key auth.APIKey, options ...Option) (inference.Client, error)
- func NewCounter(_ auth.APIKey) (contextcount.ContextCounter, error)
- type ConfigurationError
- type ConfigurationReason
- type Option
- func WithAccountID(account string) Option
- func WithCacheKey(key string) Option
- func WithCacheTTL(seconds int) Option
- func WithCollectLog(collect bool) Option
- func WithGatewayID(gateway string) Option
- func WithHeader(name, value string) Option
- func WithMetadata(metadata map[string]string) Option
- func WithReasoningEffort(value string) Option
- func WithSkipCache(skip bool) Option
- func WithThinkingBudget(budget int) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New constructs a Cloudflare AI Gateway client. A caller-supplied BaseURL is honored for private gateways and deterministic tests; otherwise the account ID is resolved from the option or CLOUDFLARE_ACCOUNT_ID.
func NewCounter ¶
func NewCounter(_ auth.APIKey) (contextcount.ContextCounter, error)
Types ¶
type ConfigurationError ¶
type ConfigurationError struct {
Reason ConfigurationReason
}
func (*ConfigurationError) Error ¶
func (e *ConfigurationError) Error() string
type ConfigurationReason ¶
type ConfigurationReason string
const (
AccountMissing ConfigurationReason = "account ID is missing"
)
type Option ¶
type Option func(*config)
Option customizes Cloudflare account routing, gateway headers, and documented per-request cache/log/metadata controls.
func WithAccountID ¶
WithAccountID sets the Cloudflare account used when Model.BaseURL is empty.
func WithCacheKey ¶
WithCacheKey sets the stable cache key used by the gateway.
func WithCacheTTL ¶
WithCacheTTL sets the gateway cache TTL in seconds.
func WithCollectLog ¶
WithCollectLog enables or disables request log collection.
func WithGatewayID ¶
WithGatewayID selects the configured AI Gateway. It takes precedence over CLOUDFLARE_AI_GATEWAY_ID.
func WithHeader ¶
WithHeader adds a provider-supported request header.
func WithMetadata ¶
WithMetadata attaches Cloudflare AI Gateway metadata as the documented JSON request header. The input map is serialized at option application time.
func WithReasoningEffort ¶
func WithSkipCache ¶
WithSkipCache controls whether the gateway bypasses its cache.