grok

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package grok provides a Grok (xAI) Model implementation for agentic-go. Grok models are accessed via the xAI API, which exposes an OpenAI-compatible endpoint at https://api.x.ai/v1.

The provider wraps the OpenAI provider with Grok-specific defaults and inherits both streaming and non-streaming capabilities.

Index

Constants

View Source
const DefaultBaseURL = "https://api.x.ai/v1"

DefaultBaseURL is the xAI API endpoint.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	*oaiProvider.Model
}

Model wraps the OpenAI provider for Grok (xAI). It inherits all methods including Request and RequestStream.

func MustNew

func MustNew(model string, opts ...Option) *Model

MustNew is like New but panics on error.

func New

func New(model string, opts ...Option) (*Model, error)

New creates a new Grok Model.

Examples:

model, err := grok.New("grok-3-mini")
model, err := grok.New("grok-3", grok.WithAPIKey("xai-..."))

type Option

type Option func(*config)

Option configures the Grok Model.

func WithAPIKey

func WithAPIKey(apiKey string) Option

WithAPIKey sets the API key. If not set, the GROK_API_KEY or XAI_API_KEY env var is used.

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL overrides the default xAI base URL.

Jump to

Keyboard shortcuts

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