compatapi

package
v0.35.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOllamaRoutes

func AddOllamaRoutes(mux *http.ServeMux, deps CompatDeps)

func AddOpenAIRoutes

func AddOpenAIRoutes(mux *http.ServeMux, deps CompatDeps)

AddOpenAIRoutes registers the OpenAI-compatible routes on mux (apiMux, paths without /api prefix). Existing GET /openai/v1/models routes are NOT registered here — they already exist in backendapi.

func AddRootRoutes

func AddRootRoutes(mux *http.ServeMux, deps CompatDeps)

AddRootRoutes registers root-level /v1/* aliases on rootMux for clients that set api_url: http://host (e.g. tools pointed at port 11434 expecting OpenAI-compat routes).

Types

type ChatCompletionRequest

type ChatCompletionRequest struct {
	Model               string        `json:"model"`
	Messages            []ChatMessage `json:"messages"`
	Stream              bool          `json:"stream"`
	Temperature         *float64      `json:"temperature,omitempty"`
	MaxTokens           *int          `json:"max_tokens,omitempty"`
	MaxCompletionTokens *int          `json:"max_completion_tokens,omitempty"`
	Stop                []string      `json:"stop,omitempty"`
}

ChatCompletionRequest is the OpenAI /v1/chat/completions request body.

type ChatMessage

type ChatMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

ChatMessage is a single message in the OpenAI chat format.

type CompatDeps

type CompatDeps struct {
	Agent        agentservice.Agent
	Chains       taskchainservice.Service
	StateService stateservice.Service
	Defaults     stateservice.RuntimeDefaults
	Auth         middleware.AuthZReader // nil = no auth required on compat routes
	Token        string                 // protects root-level mutating compat routes when set
}

CompatDeps holds the dependencies required by the OpenAI/Ollama compat handlers.

type FIMCompletionRequest

type FIMCompletionRequest struct {
	Model       string   `json:"model"`
	Prompt      string   `json:"prompt"`
	Suffix      string   `json:"suffix,omitempty"`
	Temperature *float64 `json:"temperature,omitempty"`
	MaxTokens   *int     `json:"max_tokens,omitempty"`
	Stream      bool     `json:"stream"`
	Stop        []string `json:"stop,omitempty"`
}

FIMCompletionRequest is the OpenAI /v1/fim/completions (and legacy /v1/completions) request body.

Jump to

Keyboard shortcuts

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