Documentation
¶
Overview ¶
Package sap provides SAP AI Core's orchestration chat endpoint. SAP AI Core uses a service-key OAuth client-credentials flow, deployment discovery, and the deployment URL's /v2/chat route; it is not treated as a generic hosted API-key provider.
Index ¶
- func New(selected model.Model, serviceKey ServiceKey, options ...Option) (inference.Client, error)
- func NewCounter(_ auth.APIKey) (contextcount.ContextCounter, error)
- func NewFromEnvironment(selected model.Model, options ...Option) (inference.Client, error)
- type AuthError
- type Client
- type ConfigurationError
- type ConfigurationReason
- type CounterSupportError
- type Option
- type RequestError
- type ServiceKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New constructs an SAP AI Core client. If Model.BaseURL or WithDeploymentURL is absent, the first request discovers a running orchestration deployment through the service key's AI_API_URL; construction itself performs no I/O.
func NewCounter ¶
func NewCounter(_ auth.APIKey) (contextcount.ContextCounter, error)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client lazily resolves SAP's deployment URL and then delegates message encoding, decoding, SSE, usage, tools, and errors to the shared OpenAI codec and transport.
type ConfigurationError ¶
type ConfigurationError struct {
Reason ConfigurationReason
Err error
}
func (*ConfigurationError) Error ¶
func (e *ConfigurationError) Error() string
func (*ConfigurationError) Unwrap ¶
func (e *ConfigurationError) Unwrap() error
type ConfigurationReason ¶
type ConfigurationReason string
const ( ServiceKeyMissing ConfigurationReason = "service key is missing" InvalidServiceKey ConfigurationReason = "service key is invalid" InvalidModelParams ConfigurationReason = "model parameters are invalid" DeploymentMissing ConfigurationReason = "no running orchestration deployment was found" )
type CounterSupportError ¶
type CounterSupportError = llm.CounterSupportError
type Option ¶
type Option func(*config)
func WithDeploymentID ¶
WithDeploymentID selects a deployment from SAP's /v2/lm/deployments list.
func WithDeploymentURL ¶
WithDeploymentURL bypasses deployment discovery and uses the already-known orchestration deployment URL. It is also useful for private SAP landscapes.
func WithHeader ¶
func WithModelParam ¶
WithModelParam adds one SAP Harmonized API model parameter.
func WithModelParams ¶
WithModelParams merges documented SAP Harmonized API model parameters into the /v2/chat request. Keys are forwarded verbatim in snake_case so SAP can apply model-specific parameters outside the shared inference fields.
func WithResourceGroup ¶
WithResourceGroup sets the AI-Resource-Group header used for discovery and inference. SAP defaults this value to "default".
type RequestError ¶
func (*RequestError) Error ¶
func (e *RequestError) Error() string
func (*RequestError) Unwrap ¶
func (e *RequestError) Unwrap() error
type ServiceKey ¶
type ServiceKey struct {
ClientID string `json:"clientid"`
ClientSecret string `json:"clientsecret"`
TokenURL string `json:"url"`
ServiceURLs struct {
AIAPIURL string `json:"AI_API_URL"`
} `json:"serviceurls"`
}
ServiceKey is the client-secret form of an SAP AI Core service key.
func ParseServiceKey ¶
func ParseServiceKey(raw []byte) (ServiceKey, error)
ParseServiceKey parses the JSON value accepted by AICORE_SERVICE_KEY.