grok

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallGrok

func CallGrok(systemPrompt, userPrompt string) (string, error)

CallGrok sends prompts to the Grok API and returns the response string

func CallGrokConv

func CallGrokConv(systemPrompt, userPrompt, convID string) (string, error)

CallGrokConv is like CallGrok but sets the x-grok-conv-id header so requests sharing a conv ID route to the same server, maximizing prompt cache hits on a constant system prompt.

func CallGrokConvParts

func CallGrokConvParts(systemPrompt string, parts []ContentPart,
	convID string) (string, error)

CallGrokConvParts sends a multimodal user message (text + images).

Types

type ContentPart

type ContentPart struct {
	Type     string    `json:"type"`
	Text     string    `json:"text,omitempty"`
	ImageURL *ImageURL `json:"image_url,omitempty"`
}

type GrokMessage

type GrokMessage struct {
	Role    string `json:"role"`
	Content any    `json:"content"`
}

GrokMessage is a chat message. Content is either a string or []ContentPart.

type GrokRequest

type GrokRequest struct {
	Model           string        `json:"model"`
	ReasoningEffort string        `json:"reasoning_effort"`
	Messages        []GrokMessage `json:"messages"`
}

type GrokResponse

type GrokResponse struct {
	Choices []struct {
		Message struct {
			Content string `json:"content"`
		} `json:"message"`
	} `json:"choices"`
}

type ImageURL

type ImageURL struct {
	URL    string `json:"url"`
	Detail string `json:"detail,omitempty"`
}

Jump to

Keyboard shortcuts

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