Documentation
¶
Overview ¶
Package api provides OpenAI-compatible image generation API types.
Index ¶
- func HandleGenerateRequest(c *gin.Context, scheduler RunnerScheduler, modelName, prompt string, ...)
- func ImageGenerationHandler(c *gin.Context, scheduler RunnerScheduler)
- func RegisterRoutes(r gin.IRouter, scheduler RunnerScheduler)
- type GenerateResponse
- type ImageData
- type ImageGenerationRequest
- type ImageGenerationResponse
- type ImageProgressEvent
- type RunnerScheduler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleGenerateRequest ¶
func HandleGenerateRequest(c *gin.Context, scheduler RunnerScheduler, modelName, prompt string, keepAlive *api.Duration, streamFn func(c *gin.Context, ch chan any))
HandleGenerateRequest handles Ollama /api/generate requests for image gen models. This allows routes.go to delegate image generation with minimal code.
func ImageGenerationHandler ¶
func ImageGenerationHandler(c *gin.Context, scheduler RunnerScheduler)
ImageGenerationHandler handles OpenAI-compatible image generation requests.
func RegisterRoutes ¶
func RegisterRoutes(r gin.IRouter, scheduler RunnerScheduler)
RegisterRoutes registers the image generation API routes.
Types ¶
type GenerateResponse ¶
type GenerateResponse struct {
Model string `json:"model"`
CreatedAt time.Time `json:"created_at"`
Response string `json:"response"`
Done bool `json:"done"`
}
GenerateResponse matches api.GenerateResponse structure for streaming.
type ImageData ¶
type ImageData struct {
URL string `json:"url,omitempty"`
B64JSON string `json:"b64_json,omitempty"`
RevisedPrompt string `json:"revised_prompt,omitempty"`
}
ImageData contains the generated image data.
type ImageGenerationRequest ¶
type ImageGenerationRequest struct {
Model string `json:"model"`
Prompt string `json:"prompt"`
N int `json:"n,omitempty"`
Size string `json:"size,omitempty"`
ResponseFormat string `json:"response_format,omitempty"`
Stream bool `json:"stream,omitempty"`
}
ImageGenerationRequest is an OpenAI-compatible image generation request.
type ImageGenerationResponse ¶
type ImageGenerationResponse struct {
Created int64 `json:"created"`
Data []ImageData `json:"data"`
}
ImageGenerationResponse is an OpenAI-compatible image generation response.
type ImageProgressEvent ¶
ImageProgressEvent is sent during streaming to indicate generation progress.
type RunnerScheduler ¶
type RunnerScheduler interface {
ScheduleImageGenRunner(ctx *gin.Context, modelName string, opts api.Options, keepAlive *api.Duration) (llm.LlamaServer, error)
}
RunnerScheduler is the interface for scheduling a model runner. This is implemented by server.Server to avoid circular imports.