adapters

package
v0.213.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnthropicMessages

type AnthropicMessages struct {
	// contains filtered or unexported fields
}

AnthropicMessages is a removable sdk.Client decorator that reroutes agent traffic for the Anthropic provider to the gateway's native /v1/messages endpoint, enabling prompt caching via cache_control breakpoints (system prompt, last tool, and a rolling conversation breakpoint). Anthropic SSE events are translated back into OpenAI-shaped chat-completion chunks, so the agent's streaming pipeline is unaware of the endpoint switch. Every other provider - and every non-generate method - delegates to the wrapped client untouched. To remove the adapter, delete this package, unwrap the client in the container, and drop the TakeCacheCreationTokens read in storeIterationMetrics.

func NewAnthropicMessages

func NewAnthropicMessages(inner sdk.Client) *AnthropicMessages

NewAnthropicMessages wraps the raw SDK client with Anthropic /v1/messages routing.

func (*AnthropicMessages) CreateImage

func (a *AnthropicMessages) CreateImage(ctx context.Context, provider sdk.Provider, request sdk.CreateImageRequest) (*sdk.ImagesResponse, error)

func (*AnthropicMessages) CreateImageEdit

func (a *AnthropicMessages) CreateImageEdit(ctx context.Context, provider sdk.Provider, request sdk.CreateImageEditMultipartBody) (*sdk.ImagesResponse, error)

func (*AnthropicMessages) CreateMessage

func (a *AnthropicMessages) CreateMessage(ctx context.Context, provider sdk.Provider, request sdk.CreateMessagesRequest) (*sdk.MessagesResponse, error)

func (*AnthropicMessages) CreateMessageStream

func (a *AnthropicMessages) CreateMessageStream(ctx context.Context, provider sdk.Provider, request sdk.CreateMessagesRequest) (<-chan sdk.SSEvent, error)

func (*AnthropicMessages) CreateMusic added in v0.205.2

func (a *AnthropicMessages) CreateMusic(ctx context.Context, provider sdk.Provider, request sdk.CreateMusicRequest) ([]byte, error)

func (*AnthropicMessages) CreateSFX added in v0.205.2

func (a *AnthropicMessages) CreateSFX(ctx context.Context, provider sdk.Provider, request sdk.CreateSFXRequest) ([]byte, error)

func (*AnthropicMessages) CreateSpeech added in v0.186.0

func (a *AnthropicMessages) CreateSpeech(ctx context.Context, provider sdk.Provider, request sdk.CreateSpeechRequest) ([]byte, error)

func (*AnthropicMessages) CreateVideo added in v0.205.2

func (a *AnthropicMessages) CreateVideo(ctx context.Context, provider sdk.Provider, request sdk.CreateVideoRequest) (*sdk.VideoJob, error)

func (*AnthropicMessages) DownloadVideoContent added in v0.205.2

func (a *AnthropicMessages) DownloadVideoContent(ctx context.Context, provider sdk.Provider, videoID string) ([]byte, error)

func (*AnthropicMessages) GenerateContent

func (a *AnthropicMessages) GenerateContent(ctx context.Context, provider sdk.Provider, model string, messages []sdk.Message) (*sdk.CreateChatCompletionResponse, error)

GenerateContent routes Anthropic requests through /v1/messages and translates the response back into the chat-completions shape.

func (*AnthropicMessages) GenerateContentStream

func (a *AnthropicMessages) GenerateContentStream(ctx context.Context, provider sdk.Provider, model string, messages []sdk.Message) (<-chan sdk.SSEvent, error)

GenerateContentStream routes Anthropic requests through /v1/messages and translates the native Anthropic SSE events into chat-completion chunks.

func (*AnthropicMessages) GetMCPProtectedResourceMetadata added in v0.208.0

func (a *AnthropicMessages) GetMCPProtectedResourceMetadata(ctx context.Context) (*sdk.OAuthProtectedResourceMetadata, error)

func (*AnthropicMessages) HealthCheck

func (a *AnthropicMessages) HealthCheck(ctx context.Context) error

func (*AnthropicMessages) ListModels

func (*AnthropicMessages) ListProviderModels

func (a *AnthropicMessages) ListProviderModels(ctx context.Context, provider sdk.Provider, include ...sdk.ListModelsParamsInclude) (*sdk.ListModelsResponse, error)

func (*AnthropicMessages) ListTools

func (*AnthropicMessages) MCPJSONRPC added in v0.208.0

func (*AnthropicMessages) RetrieveVideo added in v0.205.2

func (a *AnthropicMessages) RetrieveVideo(ctx context.Context, provider sdk.Provider, videoID string) (*sdk.VideoJob, error)

func (*AnthropicMessages) TakeCacheCreationTokens

func (a *AnthropicMessages) TakeCacheCreationTokens() int

TakeCacheCreationTokens returns the cache-write token count of the last completed Anthropic request and resets it.

func (*AnthropicMessages) WithAuthToken

func (a *AnthropicMessages) WithAuthToken(token string) sdk.Client

func (*AnthropicMessages) WithHeader

func (a *AnthropicMessages) WithHeader(name, value string) sdk.Client

func (*AnthropicMessages) WithHeaders

func (a *AnthropicMessages) WithHeaders(headers map[string]string) sdk.Client

func (*AnthropicMessages) WithMiddlewareOptions

func (a *AnthropicMessages) WithMiddlewareOptions(options *sdk.MiddlewareOptions) sdk.Client

func (*AnthropicMessages) WithOptions

func (a *AnthropicMessages) WithOptions(options *sdk.CreateChatCompletionRequest) sdk.Client

func (*AnthropicMessages) WithTools

func (a *AnthropicMessages) WithTools(tools *[]sdk.ChatCompletionTool) sdk.Client

Jump to

Keyboard shortcuts

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