xai.go

 1// Package xai provides a Fantasy provider for the xAI API.
 2package xai
 3
 4import (
 5	"charm.land/fantasy"
 6	"charm.land/fantasy/providers/openaicompat"
 7)
 8
 9const (
10	// Name is the provider identifier for xAI.
11	Name = "xai"
12	// BaseURL is the default xAI API base URL.
13	BaseURL = "https://api.x.ai/v1"
14)
15
16// Option configures the xAI provider via OpenAI-compatible options.
17type Option = openaicompat.Option
18
19// New creates a new xAI provider using OpenAI-compatible transport/options.
20func New(opts ...Option) (fantasy.Provider, error) {
21	options := []Option{
22		openaicompat.WithName(Name),
23		openaicompat.WithBaseURL(BaseURL),
24	}
25	options = append(options, opts...)
26	return openaicompat.New(options...)
27}