openai

package
v0.5.0-beta Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleModelsFromRegistry

func HandleModelsFromRegistry(reg *registry.ModelRegistry) http.HandlerFunc

HandleModelsFromRegistry returns a handler that lists models from the model registry.

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"`
	DeepSearch        string        `json:"deepsearch,omitempty"` // "default" | "deeper"
}

ChatRequest represents an OpenAI-compatible chat completion request.

type Handler

type Handler struct {
	ChatFlow      *flow.ChatFlow
	VideoFlow     *flow.VideoFlow
	ImageFlow     *flow.ImageFlow
	CacheService  *cache.Service
	Cfg           *config.Config
	Runtime       *config.Runtime
	ModelRegistry *registry.ModelRegistry
}

Handler holds dependencies for OpenAI-compatible API endpoints.

func (*Handler) SetupRoutes

func (h *Handler) SetupRoutes(r chi.Router)

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"`
	Type    string `json:"type,omitempty"`
}

ModelEntry represents a single model in the OpenAI models list.

type ModelsResponse

type ModelsResponse struct {
	Object string       `json:"object"`
	Data   []ModelEntry `json:"data"`
}

ModelsResponse is the OpenAI models list response.

type VideoConfig

type VideoConfig struct {
	AspectRatio    string `json:"aspect_ratio,omitempty"`
	VideoLength    int    `json:"video_length,omitempty"`
	ResolutionName string `json:"resolution_name,omitempty"`
	Preset         string `json:"preset,omitempty"`
}

VideoConfig controls video generation in chat mode.

Jump to

Keyboard shortcuts

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