xai

package
v0.37.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package xai implements the public xAI Responses API transport.

Index

Constants

View Source
const ConsumerBaseURL = consumerBaseURL

ConsumerBaseURL is the pinned Grok consumer proxy. It is exported for read-only integrations such as plan usage; API-key traffic must not use it.

Variables

This section is empty.

Functions

func SetConsumerHeaders

func SetConsumerHeaders(r *http.Request, token, accept, contentType string)

SetConsumerHeaders applies the compatibility contract required by the Grok consumer proxy. Keep all proxy callers on this single implementation.

Types

type XAI

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

XAI is the xAI public API-key provider. It deliberately has no custom-base URL constructor: alternate routes and credentials are distinct xAI products, not OpenAI-compatible configuration.

func New

func New(apiKey string) *XAI

New creates an xAI provider for XAI_API_KEY credentials.

func NewOAuth

func NewOAuth(accessToken string, refresh func(rejectedToken string) (string, error)) *XAI

NewOAuth creates an xAI consumer provider. Consumer OAuth is intentionally pinned to the Grok CLI proxy; it must never fall back to api.x.ai.

func (*XAI) Stream

func (x *XAI) Stream(ctx context.Context, req core.Request) (<-chan core.AssistantEvent, error)

Stream sends a stateless request to xAI's public Responses endpoint.

func (*XAI) SupportsDocuments

func (*XAI) SupportsDocuments() bool

SupportsDocuments is false until xAI input_file support is verified. Images are Responses input_image parts and remain supported by the shared codec.

Jump to

Keyboard shortcuts

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