gemini

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GeminiAPIURL = "https://generativelanguage.googleapis.com/v1beta/openai/chat/completions"

GeminiAPIURL is the correct API endpoint for Gemini.

Functions

This section is empty.

Types

type Choice

type Choice struct {
	Index        int     `json:"index"`
	Message      Message `json:"message"`
	FinishReason string  `json:"finish_reason"`
}

Choice represents an answer choice in the response.

type Client

type Client struct {
	URL        *url.URL
	HTTPClient *http.Client
	APIKey     string
}

Client handles requests to the Gemini API.

func NewClient

func NewClient(urlStr, apiKey string) (*Client, error)

NewClient creates a new Gemini client.

func (*Client) Chat

func (c *Client) Chat(ctx context.Context, param *Payload) (*Response, error)

Chat sends a request to the Gemini API and returns the response.

type Message

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

Message represents a chat message.

type Payload

type Payload struct {
	Model    string    `json:"model"`
	Messages []Message `json:"messages"`
}

Payload is the request body for the Gemini API. Note the use of "messages" to match the API specification.

type Response

type Response struct {
	ID      string   `json:"id"`
	Object  string   `json:"object"`
	Created int64    `json:"created"`
	Model   string   `json:"model"`
	Choices []Choice `json:"choices"`
}

Response is the API response from Gemini.

Jump to

Keyboard shortcuts

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