cloudflare

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package cloudflare adapts Cloudflare AI Gateway's compatible text endpoints to sigma.

Index

Constants

View Source
const (
	DefaultAIGatewayOpenAIBaseURL    = "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/openai"
	DefaultAIGatewayAnthropicBaseURL = "https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic/v1"
	DefaultWorkersAIBaseURL          = "https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1"
)

Variables

This section is empty.

Functions

func AIGatewayProviderAuth added in v0.6.0

func AIGatewayProviderAuth() sigma.ProviderAuth

AIGatewayProviderAuth returns Cloudflare AI Gateway auth descriptors.

func RegisterAIGateway

func RegisterAIGateway(registry *sigma.Registry, opts ...ProviderOption) error

RegisterAIGateway adds a Cloudflare AI Gateway Chat Completions provider to registry.

func RegisterAIGatewayAnthropic

func RegisterAIGatewayAnthropic(registry *sigma.Registry, opts ...AnthropicProviderOption) error

RegisterAIGatewayAnthropic adds a Cloudflare AI Gateway Anthropic-compatible provider to registry.

func RegisterAIGatewayAuth added in v0.6.0

func RegisterAIGatewayAuth(registry *sigma.Registry, opts ...sigma.RegisterOption) error

RegisterAIGatewayAuth registers Cloudflare AI Gateway auth descriptors.

func RegisterAIGatewayResponses

func RegisterAIGatewayResponses(registry *sigma.Registry, opts ...ProviderOption) error

RegisterAIGatewayResponses adds a Cloudflare AI Gateway Responses provider to registry.

func RegisterDefaultAIGateway

func RegisterDefaultAIGateway(opts ...ProviderOption) error

RegisterDefaultAIGateway adds a Cloudflare AI Gateway Chat Completions provider to sigma's default registry.

func RegisterDefaultAIGatewayAnthropic

func RegisterDefaultAIGatewayAnthropic(opts ...AnthropicProviderOption) error

RegisterDefaultAIGatewayAnthropic adds a Cloudflare AI Gateway Anthropic-compatible provider to sigma's default registry.

func RegisterDefaultAIGatewayAuth added in v0.6.0

func RegisterDefaultAIGatewayAuth(opts ...sigma.RegisterOption) error

RegisterDefaultAIGatewayAuth registers Cloudflare AI Gateway auth descriptors on the default registry.

func RegisterDefaultAIGatewayResponses

func RegisterDefaultAIGatewayResponses(opts ...ProviderOption) error

RegisterDefaultAIGatewayResponses adds a Cloudflare AI Gateway Responses provider to sigma's default registry.

func RegisterDefaultWorkersAI added in v0.6.0

func RegisterDefaultWorkersAI(opts ...ProviderOption) error

RegisterDefaultWorkersAI adds a Cloudflare Workers AI Chat Completions provider to sigma's default registry.

func RegisterDefaultWorkersAIAuth added in v0.6.0

func RegisterDefaultWorkersAIAuth(opts ...sigma.RegisterOption) error

RegisterDefaultWorkersAIAuth registers Cloudflare Workers AI auth descriptors on the default registry.

func RegisterWorkersAI added in v0.6.0

func RegisterWorkersAI(registry *sigma.Registry, opts ...ProviderOption) error

RegisterWorkersAI adds a Cloudflare Workers AI Chat Completions provider to registry.

func RegisterWorkersAIAuth added in v0.6.0

func RegisterWorkersAIAuth(registry *sigma.Registry, opts ...sigma.RegisterOption) error

RegisterWorkersAIAuth registers Cloudflare Workers AI auth descriptors.

func WithAIGatewayAccountID added in v0.6.0

func WithAIGatewayAccountID(accountID string) sigma.Option

WithAIGatewayAccountID configures the request-scoped Cloudflare account ID used to resolve AI Gateway base URL placeholders.

func WithAIGatewayID added in v0.6.0

func WithAIGatewayID(gatewayID string) sigma.Option

WithAIGatewayID configures the request-scoped Cloudflare AI Gateway ID used to resolve AI Gateway base URL placeholders.

func WithWorkersAIAccountID added in v0.6.0

func WithWorkersAIAccountID(accountID string) sigma.Option

WithWorkersAIAccountID configures the request-scoped Cloudflare account ID used to resolve Workers AI base URL placeholders.

func WorkersAIProviderAuth added in v0.6.0

func WorkersAIProviderAuth() sigma.ProviderAuth

WorkersAIProviderAuth returns Cloudflare Workers AI auth descriptors.

Types

type AnthropicProvider

type AnthropicProvider = anthropic.Provider

AnthropicProvider adapts Cloudflare AI Gateway's Anthropic-compatible Messages endpoint.

func NewAIGatewayAnthropicProvider

func NewAIGatewayAnthropicProvider(opts ...AnthropicProviderOption) *AnthropicProvider

NewAIGatewayAnthropicProvider constructs a Cloudflare AI Gateway Anthropic-compatible provider.

type AnthropicProviderOption

type AnthropicProviderOption = anthropic.ProviderOption

AnthropicProviderOption configures an AnthropicProvider.

func WithAnthropicBaseURL

func WithAnthropicBaseURL(baseURL string) AnthropicProviderOption

WithAnthropicBaseURL configures the Anthropic-compatible provider base URL.

func WithAnthropicHTTPClient

func WithAnthropicHTTPClient(client *http.Client) AnthropicProviderOption

WithAnthropicHTTPClient configures the Anthropic-compatible provider fallback HTTP client.

func WithAnthropicHeader

func WithAnthropicHeader(key, value string) AnthropicProviderOption

WithAnthropicHeader configures an Anthropic-compatible provider default request header.

func WithAnthropicHeaders

func WithAnthropicHeaders(headers map[string]string) AnthropicProviderOption

WithAnthropicHeaders configures Anthropic-compatible provider default request headers.

func WithAnthropicMessagesCompat

func WithAnthropicMessagesCompat(compat anthropic.MessagesCompat) AnthropicProviderOption

WithAnthropicMessagesCompat overrides detected Anthropic-compatible endpoint behavior.

type Provider

type Provider = openai.Provider

Provider adapts Cloudflare AI Gateway's OpenAI-compatible Chat Completions endpoint.

func NewAIGatewayProvider

func NewAIGatewayProvider(opts ...ProviderOption) *Provider

NewAIGatewayProvider constructs a Cloudflare AI Gateway Chat Completions provider.

func NewWorkersAIProvider added in v0.6.0

func NewWorkersAIProvider(opts ...ProviderOption) *Provider

NewWorkersAIProvider constructs a Cloudflare Workers AI Chat Completions provider.

type ProviderOption

type ProviderOption = openai.ProviderOption

ProviderOption configures a Provider.

func WithBaseURL

func WithBaseURL(baseURL string) ProviderOption

WithBaseURL configures the provider base URL, for example an httptest server URL.

func WithHTTPClient

func WithHTTPClient(client *http.Client) ProviderOption

WithHTTPClient configures the provider fallback HTTP client.

func WithHeader

func WithHeader(key, value string) ProviderOption

WithHeader configures a provider default request header.

func WithHeaders

func WithHeaders(headers map[string]string) ProviderOption

WithHeaders configures provider default request headers.

type ResponsesProvider

type ResponsesProvider = openai.ResponsesProvider

ResponsesProvider adapts Cloudflare AI Gateway's OpenAI-compatible Responses endpoint.

func NewAIGatewayResponsesProvider

func NewAIGatewayResponsesProvider(opts ...ProviderOption) *ResponsesProvider

NewAIGatewayResponsesProvider constructs a Cloudflare AI Gateway Responses provider.

Jump to

Keyboard shortcuts

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