Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware(cfg *config.Config) gin.HandlerFunc
AuthMiddleware returns a Gin middleware handler that authenticates requests using API keys. If no API keys are configured, it allows all requests.
Types ¶
type APIHandlers ¶
type APIHandlers struct {
// contains filtered or unexported fields
}
APIHandlers contains the handlers for API endpoints. It holds a pool of clients to interact with the backend service.
func NewAPIHandlers ¶
func NewAPIHandlers(cliClients []*client.Client, cfg *config.Config) *APIHandlers
NewAPIHandlers creates a new API handlers instance. It takes a slice of clients and a debug flag as input.
func (*APIHandlers) CLIHandler ¶ added in v1.8.2
func (h *APIHandlers) CLIHandler(c *gin.Context)
func (*APIHandlers) ChatCompletions ¶
func (h *APIHandlers) ChatCompletions(c *gin.Context)
ChatCompletions handles the /v1/chat/completions endpoint. It determines whether the request is for a streaming or non-streaming response and calls the appropriate handler.
func (*APIHandlers) GeminiHandler ¶ added in v1.9.0
func (h *APIHandlers) GeminiHandler(c *gin.Context)
func (*APIHandlers) Models ¶
func (h *APIHandlers) Models(c *gin.Context)
Models handles the /v1/models endpoint. It returns a hardcoded list of available AI models.
type ErrorDetail ¶
type ErrorDetail struct { // A human-readable message providing more details about the error. Message string `json:"message"` // The type of error that occurred (e.g., "invalid_request_error"). Type string `json:"type"` // A short code identifying the error, if applicable. Code string `json:"code,omitempty"` }
ErrorDetail provides specific information about an error that occurred. It includes a human-readable message, an error type, and an optional error code.
type ErrorResponse ¶
type ErrorResponse struct {
Error ErrorDetail `json:"error"`
}
ErrorResponse represents a standard error response format for the API. It contains a single ErrorDetail field.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the main API server. It encapsulates the Gin engine, HTTP server, handlers, and configuration.
func NewServer ¶
NewServer creates and initializes a new API server instance. It sets up the Gin engine, middleware, routes, and handlers.