grok

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package grok provides xAI Grok-backed LLM via OpenAI-compatible API.

Index

Constants

View Source
const DefaultLLMModel = "grok-2"

DefaultLLMModel is the default Grok chat model when none is specified.

Variables

This section is empty.

Functions

func NewClient

func NewClient(apiKey string) *openai.Client

NewClient returns an OpenAI-compatible client configured for xAI Grok. If apiKey is empty, config.GetEnv("XAI_API_KEY", "") is used.

Types

type LLMService

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

LLMService implements services.LLMService using xAI Grok's OpenAI-compatible chat API.

func NewLLMService

func NewLLMService(apiKey, model string) *LLMService

NewLLMService creates a Grok (xAI) LLM service. If apiKey is empty, config.GetEnv("XAI_API_KEY", "") is used. If model is empty, DefaultLLMModel is used.

func (*LLMService) Chat

func (s *LLMService) Chat(ctx context.Context, messages []map[string]any, onToken func(*frames.LLMTextFrame)) error

Chat runs a completion and calls onToken for each streamed content delta (as LLMTextFrame).

Jump to

Keyboard shortcuts

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