Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleModels ¶
func HandleModels(registry *ModelRegistry) http.HandlerFunc
HandleModels returns an http.HandlerFunc that lists all models. The response follows OpenAI's /v1/models format.
func HandleModelsFromConfig ¶
func HandleModelsFromConfig(cfg *config.Config) http.HandlerFunc
HandleModelsFromConfig returns a handler that rebuilds the model list from config on each request, enabling hot-reload of model groups.
Types ¶
type ChatMessage ¶
type ChatMessage struct {
Role string `json:"role"`
Content any `json:"content"`
ToolCalls []flow.ToolCall `json:"tool_calls,omitempty"`
Name string `json:"name,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
}
ChatMessage represents a single message in the conversation.
type ChatRequest ¶
type ChatRequest struct {
Model string `json:"model"`
Messages []ChatMessage `json:"messages"`
Stream *bool `json:"stream,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
Stop []string `json:"stop,omitempty"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
Tools []flow.Tool `json:"tools,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
ParallelToolCalls *bool `json:"parallel_tool_calls,omitempty"`
ImageConfig *ImageConfig `json:"image_config,omitempty"`
VideoConfig *VideoConfig `json:"video_config,omitempty"`
}
ChatRequest represents an OpenAI-compatible chat completion request.
type Handler ¶
type Handler struct {
ChatFlow *flow.ChatFlow
VideoFlow *flow.VideoFlow
ImageFlow *flow.ImageFlow
Cfg *config.Config
}
Handler holds dependencies for OpenAI-compatible API endpoints.
func (*Handler) SetupRoutes ¶
SetupRoutes registers OpenAI-compatible API endpoints on the given router.
type ImageConfig ¶
type ImageConfig struct {
N int `json:"n,omitempty"`
Size string `json:"size,omitempty"`
ResponseFormat string `json:"response_format,omitempty"`
EnableNSFW *bool `json:"enable_nsfw,omitempty"`
}
ImageConfig controls image generation in chat multimodal mode.
type ModelEntry ¶
type ModelEntry struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
OwnedBy string `json:"owned_by"`
}
ModelEntry represents a single model in the OpenAI models list.
type ModelRegistry ¶
type ModelRegistry struct {
// contains filtered or unexported fields
}
ModelRegistry holds available models.
func NewModelRegistry ¶
func NewModelRegistry() *ModelRegistry
NewModelRegistry creates an empty model registry.
func NewModelRegistryFromConfig ¶
func NewModelRegistryFromConfig(cfg *config.TokenConfig) *ModelRegistry
NewModelRegistryFromConfig builds a model registry from config. Model entries with "#N" cost suffixes are stripped to expose clean model IDs.
func (*ModelRegistry) Add ¶
func (r *ModelRegistry) Add(info ModelInfo)
Add adds a model to the registry.
func (*ModelRegistry) All ¶
func (r *ModelRegistry) All() []ModelInfo
All returns all models in the registry.
type ModelsResponse ¶
type ModelsResponse struct {
Object string `json:"object"`
Data []ModelEntry `json:"data"`
}
ModelsResponse is the OpenAI models list response.