Documentation
¶
Overview ¶
Package bedrocksig holds the shared AWS SigV4 signing and Bedrock Mantle routing helpers used by both the anthropic-go and openai-go interceptors. It depends only on stdlib and the AWS SDK so it can be imported from either SDK-specific interceptor package without pulling in the other SDK.
Index ¶
Constants ¶
const PRMUserAgent = "sdk-ua-app-id/APN_1.1%2Fpc_cdfmjwn8i6u8l9fwz8h82e4w3%24"
PRMUserAgent is Coder's AWS Partner Revenue Measurement (PRM) attribution marker for outbound Bedrock requests. It is appended to the User-Agent header so AWS can recognize the traffic as Coder-associated Bedrock usage.
const SigningService = "bedrock-mantle"
SigningService is the AWS SigV4 service name for Bedrock Mantle.
Variables ¶
This section is empty.
Functions ¶
func AppendPRMUserAgent ¶
AppendPRMUserAgent appends the Coder PRM attribution marker to the request's User-Agent header.
func BaseURLForModel ¶
BaseURLForModel resolves the upstream Mantle base URL for a given model. It parses rawBase, trims any existing vendor path segment, then re-appends the one the model requires: "anthropic." models use /anthropic, "openai." models use /openai/v1, and anything else (third-party) uses /v1 so the SDK's /chat/completions route hits the root /v1/chat/completions endpoint.
func SignMiddleware ¶
func SignMiddleware(creds aws.CredentialsProvider, region string) func(req *http.Request, next func(*http.Request) (*http.Response, error)) (*http.Response, error)
SignMiddleware returns an stdlib HTTP middleware that SigV4-signs the request for the Bedrock Mantle service. It appends the PRM user-agent, reads and restores the body for hashing, then signs with the given credentials and region. Callers wrap it in their SDK-specific option.WithMiddleware adapter.
Types ¶
This section is empty.