Versions in this module Expand all Collapse all v1 v1.0.0 May 3, 2025 Changes in this version + const DefaultBaseURL + const DefaultEndpoint + const DefaultTimeout + func ValidateChatCompletionRequest(request *ChatCompletionRequest) error + func ValidateClient(client *Client) error + func ValidateImageGenerationRequest(request *ImageGenerationRequest) error + func ValidateLanguageCode(languageCode string) error + type APIErrorResponse struct + Error struct{ ... } + type APIToolCall struct + Function FunctionCall + ID string + Type string + type AssistantMessage struct + ToolCalls []ToolCall + func NewAssistantMessage(content any) AssistantMessage + type BaseMessage struct + Content any + Name string + Role string + func NewMultiContentMessage(role string, items []any) BaseMessage + func NewSystemMessage(content any) BaseMessage + func NewTextMessage(role string, text string) BaseMessage + func NewUserMessage(content any) BaseMessage + func WithName(msg BaseMessage, name string) BaseMessage + func (m BaseMessage) GetContent() any + func (m BaseMessage) GetName() string + func (m BaseMessage) GetRole() string + type ChatCompletionMessage struct + Content string + Name string + Prefix bool + Role string + ToolCallID string + ToolCalls []APIToolCall + type ChatCompletionRequest struct + AdaptivePrompt bool + BackendType string + ConversationContext string + Deferred bool + FrequencyPenalty float64 + HTTPBasedPlugins interface{} + JSONMode bool + LogitBias map[string]float64 + Logprobs bool + ManagedCredentials map[string]string + MaxTokens int + Messages []ChatCompletionMessage + Model string + PrefixTokens []int + PresencePenalty float64 + ResponseFormat *ResponseFormat + Seed int64 + SkipParameterCheck bool + Stop []string + Stream bool + StreamOptions struct{ ... } + Temperature float64 + ToolChoice interface{} + Tools []Tool + TopK int + TopLogprobs int + TopP float64 + User string + type Client struct + ApiKey string + BaseUrl string + Endpoint string + HttpClient *http.Client + Timeout time.Duration + func CreateChatCompletionClient(apiKey string, options ...ClientOption) (*Client, error) + func CreateImageGenerationClient(apiKey string, options ...ClientOption) (*Client, error) + func CreateModelsClient(apiKey string, options ...ClientOption) (*Client, error) + func NewClient(apiKey string) (*Client, error) + func NewClientWithOptions(apiKey string, options ...ClientOption) (*Client, error) + func (client *Client) Url() string + type ClientOption func(*Client) + func WithBaseURL(baseURL string) ClientOption + func WithEndpoint(endpoint string) ClientOption + func WithHTTPClient(httpClient *http.Client) ClientOption + func WithTimeout(timeout time.Duration) ClientOption + type Function struct + Description string + Name string + Parameters *FunctionParameters + type FunctionCall struct + Arguments string + Name string + type FunctionParameters struct + Properties map[string]interface{} + Required []string + Type string + type ImageGenerationData struct + B64JSON string + RevisedPrompt string + URL string + type ImageGenerationRequest struct + Model string + N int + Prompt string + Quality string + ResponseFormat string + Size string + Style string + User string + type ImageGenerationResponse struct + Created int64 + Data []ImageGenerationData + func CreateImage(ctx context.Context, client *Client, request *ImageGenerationRequest) (*ImageGenerationResponse, error) + type LanguageInfo struct + Code string + Name string + NativeName string + Supported bool + func GetLanguageInfo(ctx context.Context, client *Client, languageCode string) (*LanguageInfo, error) + type LanguageListResponse struct + Data []LanguageInfo + Object string + func ListLanguages(ctx context.Context, client *Client) (*LanguageListResponse, error) + type LogProbs struct + Content []TokenLogProb + type Message interface + GetContent func() any + GetName func() string + GetRole func() string + type Messages []Message + func NewMessageArray() Messages + func NewMessages() Messages + func (m *Messages) AddMessage(msg Message) + type ModelInfo struct + Created int64 + ID string + Object string + OwnedBy string + func GetModelInfo(ctx context.Context, client *Client, modelID string) (*ModelInfo, error) + type ModelListResponse struct + Data []ModelInfo + Object string + func ListModels(ctx context.Context, client *Client) (*ModelListResponse, error) + type Request struct + Auth string + Body []byte + Url string + func (r Request) BuildHttpRequest(ctx context.Context) (*http.Request, error) + type Response struct + Choices []ResponseChoice + Created int64 + ID string + Model string + Object string + SystemFingerprint string + Usage Usage + func CreateChatCompletion(ctx context.Context, client *Client, request *ChatCompletionRequest) (*Response, error) + type ResponseChoice struct + FinishReason string + Index int + LogProbs *LogProbs + Message ResponseMessage + type ResponseFormat struct + Type string + type ResponseMessage struct + Content string + Role string + ToolCalls []APIToolCall + type StreamChoice struct + Delta StreamMessage + FinishReason string + Index int + LogProbs *LogProbs + type StreamMessage struct + Content string + Role string + ToolCalls []APIToolCall + type StreamReader struct + func CreateChatCompletionStream(ctx context.Context, client *Client, request *ChatCompletionRequest) (*StreamReader, error) + func (s *StreamReader) Close() error + func (s *StreamReader) Recv() (*StreamResponse, error) + type StreamResponse struct + Choices []StreamChoice + Created int64 + ID string + Model string + Object string + SystemFingerprint string + Usage *Usage + type TokenLogProb struct + Bytes []int + LogProb float64 + Token string + TopLogProbs map[string]float64 + type Tool struct + Function Function + Type string + type ToolCall struct + Function struct{ ... } + ID string + Index int + Type string + type ToolCallMessage struct + ToolCallID string + func NewToolCallMessage(content any, toolCallID string) ToolCallMessage + type Usage struct + CompletionTokens int + PromptTokens int + TotalTokens int