Documentation
¶
Overview ¶
Package api implements the OpenAI-compatible HTTP API for MaritacaProxy. It exposes /v1/chat/completions, /v1/models, /health and other endpoints compatible with OpenAI SDK clients.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoCreator ¶ added in v0.3.0
AutoCreator is the interface implemented by the autocreate.Creator. We use an interface so the server can work without autocreate enabled.
type OpenAIRequest ¶
type OpenAIRequest struct {
Model string `json:"model"`
Messages []map[string]interface{} `json:"messages"`
Stream bool `json:"stream"`
Tools []tools.FunctionToolDefinition `json:"tools"`
ToolChoice interface{} `json:"tool_choice"`
ParallelToolCalls *bool `json:"parallel_tool_calls"`
StreamOptions *struct {
IncludeUsage bool `json:"include_usage"`
} `json:"stream_options"`
}
OpenAIRequest is the OpenAI-compatible chat completion request.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the HTTP API server.
func (*Server) AuthMiddleware ¶
func (s *Server) AuthMiddleware(next http.HandlerFunc) http.HandlerFunc
AuthMiddleware wraps the handler with API key authentication.
func (*Server) RegisterDefaultAccountsCreate ¶ added in v0.3.0
RegisterDefaultAccountsCreate registers the default (no-op) accounts/create handler. Called by main.go when AUTO_ACCOUNT_ENABLED=false.
func (*Server) RegisterRoutes ¶
RegisterRoutes mounts all API routes on the provided mux. Note: /v1/accounts/create is intentionally NOT registered here so that main.go can override it with the autocreate-enabled version when AUTO_ACCOUNT_ENABLED=true. If autocreate is disabled, the default (not-implemented) handler is registered via RegisterDefaultAccountsCreate.
func (*Server) SetAutoCreator ¶ added in v0.3.0
func (s *Server) SetAutoCreator(c AutoCreator)
SetAutoCreator injects an autocreate.Creator for on-demand account creation.