xai

package module
v0.13.0 Latest Latest
Warning

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

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

Documentation

Overview

Package xai wraps xAI's (Grok) OpenAI-compatible API.

NewChat returns xAI's provider-local Chat, backed by the shared OpenAI Chat Completions protocol.

Current Grok models support text, image input, structured outputs, reasoning effort, and custom function calling through the Chat Completions surface. xAI's server-side Web Search, X Search, code execution, and collections tools belong to its Responses API surface and are not represented as Core custom functions by this adapter.

See https://docs.x.ai/ for the full API reference.

Index

Constants

View Source
const (
	OpenAIRequestExtensionKey     = "xai/openai_request"
	OpenAIResponseExtensionKey    = "xai/openai_response"
	OpenAIStreamChunkExtensionKey = "xai/openai_stream_chunk"
)
View Source
const (
	Provider = "xAI"

	BaseURL = "https://api.x.ai/v1"
)
View Source
const (
	ModelGrok45      = "grok-4.5"
	ModelGrok43      = "grok-4.3"
	ModelGrokBuild01 = "grok-build-0.1"
	ModelGrok4       = "grok-4"
)

See https://docs.x.ai/developers/models for the current catalog.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chat added in v0.13.0

type Chat = openai.ChatCompletions

Chat implements xAI's chat endpoint.

func NewChat added in v0.13.0

func NewChat(config ChatConfig) (*Chat, error)

type ChatConfig added in v0.13.0

type ChatConfig struct {
	APIKey         string
	DefaultOptions corechat.Options
	BaseURL        string
	HTTPClient     *http.Client
}

func (ChatConfig) Validate added in v0.13.0

func (c ChatConfig) Validate() error

Jump to

Keyboard shortcuts

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