Documentation
¶
Overview ¶
Package openai provides HTTP handlers for OpenAI API endpoints. This package implements the OpenAI-compatible API interface, including model listing and chat completion functionality. It supports both streaming and non-streaming responses, and manages a pool of clients to interact with backend services. The handlers translate OpenAI API requests to the appropriate backend format and convert responses back to OpenAI-compatible format.
Package openai provides HTTP handlers for OpenAIResponses API endpoints. This package implements the OpenAIResponses-compatible API interface, including model listing and chat completion functionality. It supports both streaming and non-streaming responses, and manages a pool of clients to interact with backend services. The handlers translate OpenAIResponses API requests to the appropriate backend format and convert responses back to OpenAIResponses-compatible format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OpenAIAPIHandler ¶
type OpenAIAPIHandler struct {
*handlers.BaseAPIHandler
}
OpenAIAPIHandler contains the handlers for OpenAI API endpoints. It holds a pool of clients to interact with the backend service.
func NewOpenAIAPIHandler ¶
func NewOpenAIAPIHandler(apiHandlers *handlers.BaseAPIHandler) *OpenAIAPIHandler
NewOpenAIAPIHandler creates a new OpenAI API handlers instance. It takes an BaseAPIHandler instance as input and returns an OpenAIAPIHandler.
Parameters:
- apiHandlers: The base API handlers instance
Returns:
- *OpenAIAPIHandler: A new OpenAI API handlers instance
func (*OpenAIAPIHandler) ChatCompletions ¶
func (h *OpenAIAPIHandler) 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 based on the model provider.
Parameters:
- c: The Gin context containing the HTTP request and response
func (*OpenAIAPIHandler) Completions ¶
func (h *OpenAIAPIHandler) Completions(c *gin.Context)
Completions handles the /v1/completions endpoint. It determines whether the request is for a streaming or non-streaming response and calls the appropriate handler based on the model provider. This endpoint follows the OpenAI completions API specification.
Parameters:
- c: The Gin context containing the HTTP request and response
func (*OpenAIAPIHandler) HandlerType ¶
func (h *OpenAIAPIHandler) HandlerType() string
HandlerType returns the identifier for this handler implementation.
func (*OpenAIAPIHandler) Models ¶
func (h *OpenAIAPIHandler) Models() []map[string]any
Models returns the OpenAI-compatible model metadata supported by this handler.
func (*OpenAIAPIHandler) OpenAIModels ¶
func (h *OpenAIAPIHandler) OpenAIModels(c *gin.Context)
OpenAIModels handles the /v1/models endpoint. It returns a list of available AI models with their capabilities and specifications in OpenAI-compatible format.
type OpenAIResponsesAPIHandler ¶
type OpenAIResponsesAPIHandler struct {
*handlers.BaseAPIHandler
}
OpenAIResponsesAPIHandler contains the handlers for OpenAIResponses API endpoints. It holds a pool of clients to interact with the backend service.
func NewOpenAIResponsesAPIHandler ¶
func NewOpenAIResponsesAPIHandler(apiHandlers *handlers.BaseAPIHandler) *OpenAIResponsesAPIHandler
NewOpenAIResponsesAPIHandler creates a new OpenAIResponses API handlers instance. It takes an BaseAPIHandler instance as input and returns an OpenAIResponsesAPIHandler.
Parameters:
- apiHandlers: The base API handlers instance
Returns:
- *OpenAIResponsesAPIHandler: A new OpenAIResponses API handlers instance
func (*OpenAIResponsesAPIHandler) HandlerType ¶
func (h *OpenAIResponsesAPIHandler) HandlerType() string
HandlerType returns the identifier for this handler implementation.
func (*OpenAIResponsesAPIHandler) Models ¶
func (h *OpenAIResponsesAPIHandler) Models() []map[string]any
Models returns the OpenAIResponses-compatible model metadata supported by this handler.
func (*OpenAIResponsesAPIHandler) OpenAIResponsesModels ¶
func (h *OpenAIResponsesAPIHandler) OpenAIResponsesModels(c *gin.Context)
OpenAIResponsesModels handles the /v1/models endpoint. It returns a list of available AI models with their capabilities and specifications in OpenAIResponses-compatible format.
func (*OpenAIResponsesAPIHandler) Responses ¶
func (h *OpenAIResponsesAPIHandler) Responses(c *gin.Context)
Responses handles the /v1/responses endpoint. It determines whether the request is for a streaming or non-streaming response and calls the appropriate handler based on the model provider.
Parameters:
- c: The Gin context containing the HTTP request and response