Documentation
¶
Index ¶
- func InjectClient(cmd *cobra.Command, client *AdminClient)
- func NewProviderCmd() *cobra.Command
- func NewRouteCmd() *cobra.Command
- func NewSettingsCmd() *cobra.Command
- func NewSystemCmd() *cobra.Command
- func ResolveAdminURL(configPath, urlFlag string) (string, error)
- func RunREPL(rootCmd *cobra.Command, in io.Reader, out io.Writer) error
- type APIError
- type APIResponse
- type AdminClient
- func (c *AdminClient) Delete(ctx context.Context, path string) (json.RawMessage, error)
- func (c *AdminClient) Get(ctx context.Context, path string) (json.RawMessage, error)
- func (c *AdminClient) Post(ctx context.Context, path string, body any) (json.RawMessage, error)
- func (c *AdminClient) Put(ctx context.Context, path string, body any) (json.RawMessage, error)
- type CreateProviderReq
- type CreateRouteReq
- type DefaultRouteItem
- type Formatter
- type OutputFormat
- type PresetItem
- type ProviderItem
- type RouteItem
- type SettingsItem
- type StatusItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InjectClient ¶
func InjectClient(cmd *cobra.Command, client *AdminClient)
InjectClient stores an AdminClient in the cobra command's context.
func NewProviderCmd ¶
func NewRouteCmd ¶
func NewSettingsCmd ¶
func NewSystemCmd ¶
func ResolveAdminURL ¶
ResolveAdminURL returns the admin API base URL (e.g. "http://127.0.0.1:12345/api"). Priority: urlFlag > config file > defaults (127.0.0.1:12345).
Types ¶
type APIResponse ¶
type APIResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data json.RawMessage `json:"data"`
}
APIResponse mirrors the server's unified response envelope.
type AdminClient ¶
type AdminClient struct {
// contains filtered or unexported fields
}
AdminClient is an HTTP client for the ais admin API.
func ClientFromCmd ¶
func ClientFromCmd(cmd *cobra.Command) *AdminClient
ClientFromCmd retrieves the AdminClient from the cobra command's context. Panics with a clear message if the client was not injected.
func NewAdminClient ¶
func NewAdminClient(baseURL string) *AdminClient
NewAdminClient creates a client targeting the given base URL (e.g. "http://127.0.0.1:12345/api").
func (*AdminClient) Delete ¶
func (c *AdminClient) Delete(ctx context.Context, path string) (json.RawMessage, error)
Delete sends a DELETE request.
func (*AdminClient) Get ¶
func (c *AdminClient) Get(ctx context.Context, path string) (json.RawMessage, error)
Get sends a GET request.
func (*AdminClient) Post ¶
func (c *AdminClient) Post(ctx context.Context, path string, body any) (json.RawMessage, error)
Post sends a POST request with a JSON body.
func (*AdminClient) Put ¶
func (c *AdminClient) Put(ctx context.Context, path string, body any) (json.RawMessage, error)
Put sends a PUT request with a JSON body.
type CreateProviderReq ¶
type CreateProviderReq struct {
Key string `json:"key"`
Name string `json:"name"`
BaseURL string `json:"base_url"`
APIKey string `json:"api_key"`
Format string `json:"format"`
Path string `json:"path,omitempty"`
LogoURL string `json:"logo_url,omitempty"`
ThinkTag string `json:"think_tag,omitempty"`
FallbackKeys []string `json:"fallback_keys,omitempty"`
Models []string `json:"models,omitempty"`
DefaultModel string `json:"default_model,omitempty"`
EnableProxy bool `json:"enable_proxy"`
}
CreateProviderReq is the request body for POST /admin/providers.
type CreateRouteReq ¶
type CreateRouteReq struct {
Key string `json:"key"`
Provider string `json:"provider"`
DefaultModel string `json:"default_model,omitempty"`
Disabled bool `json:"disabled"`
}
CreateRouteReq is the request body for POST /admin/routes.
type DefaultRouteItem ¶
type DefaultRouteItem struct {
DefaultRoute string `json:"default_route"`
DefaultAnthropicRoute string `json:"default_anthropic_route"`
DefaultResponsesRoute string `json:"default_responses_route"`
DefaultChatRoute string `json:"default_chat_route"`
}
DefaultRouteItem mirrors the default route fields in status API response.
type Formatter ¶
type Formatter struct {
Format OutputFormat
Out io.Writer
}
Formatter renders data in the configured output format.
func FormatterFromCmd ¶
FormatterFromCmd creates a Formatter from the command's --output flag.
func (*Formatter) PrintMessage ¶
PrintMessage prints a plain text message.
type OutputFormat ¶
type OutputFormat string
OutputFormat controls how data is rendered.
const ( FormatTable OutputFormat = "table" FormatJSON OutputFormat = "json" )
func ParseOutputFormat ¶
func ParseOutputFormat(s string) (OutputFormat, error)
ParseOutputFormat validates and returns an OutputFormat.
type PresetItem ¶
type PresetItem struct {
Key string `json:"key"`
Name string `json:"name"`
BaseURL string `json:"base_url"`
Format string `json:"format"`
Category string `json:"category"`
IsPartner bool `json:"is_partner"`
}
PresetItem mirrors the API response for GET /admin/presets.
type ProviderItem ¶
type ProviderItem struct {
Key string `json:"key"`
Name string `json:"name"`
BaseURL string `json:"base_url"`
Format string `json:"format"`
Models []string `json:"models"`
EnableProxy bool `json:"enable_proxy"`
APIKey string `json:"api_key"`
Path string `json:"path"`
LogoURL string `json:"logo_url"`
ThinkTag string `json:"think_tag"`
}
ProviderItem is a single provider in list output.
type RouteItem ¶
type RouteItem struct {
Key string `json:"key"`
Provider string `json:"provider"`
DefaultModel string `json:"default_model"`
Disabled bool `json:"disabled"`
SceneMap map[string]string `json:"scene_map"`
ModelMap map[string]string `json:"model_map"`
LongContextThreshold int `json:"long_context_threshold"`
}
RouteItem is a single route in list output.
type SettingsItem ¶
type SettingsItem struct {
Host string `json:"host"`
Port int `json:"port"`
AllowedIPs []string `json:"allowed_ips"`
LogRetentionDays int `json:"log_retention_days"`
ProxyURL string `json:"proxy_url"`
}
SettingsItem mirrors the API response for GET /admin/settings.
type StatusItem ¶
type StatusItem struct {
Server any `json:"server"`
DefaultRoute string `json:"default_route"`
DefaultAnthropicRoute string `json:"default_anthropic_route"`
DefaultResponsesRoute string `json:"default_responses_route"`
DefaultChatRoute string `json:"default_chat_route"`
ProviderCount int `json:"provider_count"`
RouteCount int `json:"route_count"`
}
StatusItem mirrors the API response for GET /admin/status.