aiproxy

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package aiproxy serves the openai and exa addons: apps call it with a per-space token, which it checks against the bindings donkey issued and swaps for the platform's real credential. The key never leaves donkey-system, and removing the service revokes the space's access.

It runs as its own workload (donkey-ai) rather than inside donkey-server, because this is the one donkey endpoint tenant code is *meant* to reach. Keeping it out of the admin API's process means a flaw in the part apps can talk to does not sit in the process that can write to the cluster.

Index

Constants

View Source
const ExaPrefix = "/exa/"
View Source
const Prefix = "/v1/"

Prefix is where the proxy is mounted. donkey-ai serves it at the root of its own listener, so an app's OPENAI_BASE_URL is an ordinary /v1 endpoint.

Variables

This section is empty.

Functions

func ExaHandler

func ExaHandler(upstreamBase, upstreamKey string, valid Tokens) (http.Handler, error)

ExaHandler fronts only search and contents; account-management APIs never receive the platform credential. Custom bases may include a gateway prefix.

func Handler

func Handler(upstreamBase, upstreamKey string, valid Tokens) (http.Handler, error)

Handler is the proxy. upstream/key are the platform's own endpoint and credential; valid answers which per-space tokens the bindings currently hold.

func Run

func Run(ctx context.Context, cfg *Config, provider rt.Provider) error

Run serves the proxy until the context is cancelled. The provider supplies the valid per-space tokens — the only thing this process asks the cluster for, and read-only.

Types

type Config

type Config struct {
	Listen string
	// UpstreamURL/UpstreamKey are the platform's own AI endpoint and
	// credential. The credential never travels past this process.
	UpstreamURL string
	UpstreamKey string
	ExaURL      string
	ExaKey      string
}

Config is what donkey-ai reads from its environment: the endpoints it fronts, the credentials it swaps in, and where to look for the per-space tokens. No session key, no registry, no builder — this process holds nothing the admin API holds.

func ConfigFromEnv

func ConfigFromEnv() (*Config, error)

type Tokens

type Tokens func(context.Context) ([]string, error)

Tokens lists the space credentials currently bound to this proxy endpoint.

Jump to

Keyboard shortcuts

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