compatapi

package
v0.32.8 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: Apache-2.0 Imports: 17 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 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
	DefaultChainRef    string
	DefaultFIMChainRef string
	DefaultModel       string
	DefaultProvider    string
	DefaultMaxTokens   string
	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