xai

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

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

func New(selected model.Model, key auth.APIKey, options ...Option) (inference.Client, error)

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

func WithPromptCacheKey(key string) Option

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"
)

Jump to

Keyboard shortcuts

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