cloudflaregateway

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cloudflaregateway provides Cloudflare AI Gateway's documented OpenAI, Responses, and Anthropic proxy endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(selected model.Model, key auth.APIKey, options ...Option) (inference.Client, error)

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.

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

func WithAccountID(account string) Option

WithAccountID sets the Cloudflare account used when Model.BaseURL is empty.

func WithCacheKey

func WithCacheKey(key string) Option

WithCacheKey sets the stable cache key used by the gateway.

func WithCacheTTL

func WithCacheTTL(seconds int) Option

WithCacheTTL sets the gateway cache TTL in seconds.

func WithCollectLog

func WithCollectLog(collect bool) Option

WithCollectLog enables or disables request log collection.

func WithGatewayID

func WithGatewayID(gateway string) Option

WithGatewayID selects the configured AI Gateway. It takes precedence over CLOUDFLARE_AI_GATEWAY_ID.

func WithHeader

func WithHeader(name, value string) Option

WithHeader adds a provider-supported request header.

func WithMetadata

func WithMetadata(metadata map[string]string) Option

WithMetadata attaches Cloudflare AI Gateway metadata as the documented JSON request header. The input map is serialized at option application time.

func WithReasoningEffort

func WithReasoningEffort(value string) Option

func WithSkipCache

func WithSkipCache(skip bool) Option

WithSkipCache controls whether the gateway bypasses its cache.

func WithThinkingBudget

func WithThinkingBudget(budget int) Option

Jump to

Keyboard shortcuts

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