Documentation
¶
Overview ¶
Package xai provides xAI Chat Completions and Responses API clients. The selected model's APIFormat chooses the codec; this package owns xAI's endpoint, bearer authentication, options, and one native Responses reasoning stream-event alias.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New constructs an xAI Chat Completions or Responses API client. The selected model's APIFormat chooses the bundled wire codec and route; an empty model base URL uses xAI's canonical API root.
func NewCounter ¶
func NewCounter(_ auth.APIKey) (contextcount.ContextCounter, error)
NewCounter reports xAI's deliberate counter boundary. xAI documents text tokenization, but not an exact full Responses-input counter that includes the same messages, tools, and provider options as inference; silently estimating here would violate the ContextCounter contract.
Types ¶
type Option ¶
type Option func(*config)
Option customizes an xAI Responses client at construction time.
func WithPromptCacheKey ¶
WithPromptCacheKey sets the stable Responses prompt-cache routing key.
func WithReasoning ¶
func WithReasoning(options ReasoningOptions) Option
WithReasoning sets xAI's reasoning effort.
func WithServiceTier ¶
func WithServiceTier(tier ServiceTier) Option
WithServiceTier opts into xAI's default or priority processing tier.
type ReasoningOptions ¶
type ReasoningOptions struct {
Effort string `json:"effort,omitempty"`
}
ReasoningOptions controls xAI reasoning. It is encoded as the Responses reasoning object or Chat Completions reasoning_effort field, as selected by the model APIFormat.
type ServiceTier ¶
type ServiceTier string
ServiceTier selects xAI Responses processing priority.
const ( ServiceTierDefault ServiceTier = "default" ServiceTierPriority ServiceTier = "priority" )