Documentation
¶
Overview ¶
Copyright 2023-2025 Hanzo AI Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func ConvertMessageDataToJSON(data string) ([]byte, error)
- func DenyRequest(ctx *web.Context)
- func FamilyModelGated(model string) bool
- func FilterStoresByHomepage(stores []*object.Store, user *iam.User) []*object.Store
- func GetUserByAccessKey(accessKey string) (*iam.User, error)
- func GetUserName(user *iam.User) string
- func InitAuthConfig()
- func InitBillingQueue() *util.BillingQueue
- func InitForwardBridge(h http.Handler)
- func InitInterserviceZap()
- func InitModelConfig(path string) error
- func InitZapHandlers()
- func QueryCarrierText(question string, writer *RefinedWriter, history []*model.RawMessage, ...) (*model.ModelResult, error)
- func RefineMessageImage(message *object.Message, lang string) error
- func SeedInternalTrainingConsent()
- func StartRouterJudge()
- func StartRouterProbe()
- func StartRouterTrainer()
- func StopInterserviceZap()
- func TraceServedUsage(ctx context.Context, in ServedUsage)
- type AnthropicContentBlock
- type AnthropicErrorBody
- type AnthropicMessage
- type AnthropicRequest
- type AnthropicResponse
- type AnthropicTool
- type AnthropicUsage
- type AnthropicWriter
- type ApiController
- func (c *ApiController) ActivateFile()
- func (c *ApiController) AddAIConnection()
- func (c *ApiController) AddApplication()
- func (c *ApiController) AddArticle()
- func (c *ApiController) AddAsset()
- func (c *ApiController) AddCaase()
- func (c *ApiController) AddChat()
- func (c *ApiController) AddConnection()
- func (c *ApiController) AddConsultation()
- func (c *ApiController) AddDoctor()
- func (c *ApiController) AddFile()
- func (c *ApiController) AddForm()
- func (c *ApiController) AddGraph()
- func (c *ApiController) AddHospital()
- func (c *ApiController) AddMessage()
- func (c *ApiController) AddModelRoute()
- func (c *ApiController) AddNode()
- func (c *ApiController) AddNodeTunnel()
- func (c *ApiController) AddPatient()
- func (c *ApiController) AddPermission()
- func (c *ApiController) AddProvider()
- func (c *ApiController) AddRecord()
- func (c *ApiController) AddRecords()
- func (c *ApiController) AddRoutingReward()
- func (c *ApiController) AddScale()
- func (c *ApiController) AddScan()
- func (c *ApiController) AddSession()
- func (c *ApiController) AddStore()
- func (c *ApiController) AddTask()
- func (c *ApiController) AddTemplate()
- func (c *ApiController) AddTreeFile()
- func (c *ApiController) AddVector()
- func (c *ApiController) AddVideo()
- func (c *ApiController) AddWorkflow()
- func (c *ApiController) AdminGrantModelAccess()
- func (c *ApiController) AdminListModelAccess()
- func (c *ApiController) AnalyzeTask()
- func (c *ApiController) AnthropicCountTokens()
- func (c *ApiController) AnthropicMessages()
- func (c *ApiController) AudioMedia()
- func (c *ApiController) AudioSpeech()
- func (c *ApiController) CallbackAIProvider()
- func (c *ApiController) CancelFinetuneJob()
- func (c *ApiController) ChatCompletions()
- func (c *ApiController) CheckSignedIn() (string, bool)
- func (c *ApiController) CommitRecord()
- func (c *ApiController) CommitRecordSecond()
- func (c *ApiController) ConnectAIProvider()
- func (c *ApiController) Crawl()
- func (c *ApiController) CreateFinetuneJob()
- func (c *ApiController) DeleteAIConnection()
- func (c *ApiController) DeleteAllVectors()
- func (c *ApiController) DeleteApplication()
- func (c *ApiController) DeleteArticle()
- func (c *ApiController) DeleteAsset()
- func (c *ApiController) DeleteCaase()
- func (c *ApiController) DeleteChat()
- func (c *ApiController) DeleteConnection()
- func (c *ApiController) DeleteConsultation()
- func (c *ApiController) DeleteDoctor()
- func (c *ApiController) DeleteFile()
- func (c *ApiController) DeleteForm()
- func (c *ApiController) DeleteGraph()
- func (c *ApiController) DeleteHospital()
- func (c *ApiController) DeleteMessage()
- func (c *ApiController) DeleteModelRoute()
- func (c *ApiController) DeleteMyRoutingData()
- func (c *ApiController) DeleteNode()
- func (c *ApiController) DeletePatient()
- func (c *ApiController) DeletePermission()
- func (c *ApiController) DeleteProvider()
- func (c *ApiController) DeleteRecord()
- func (c *ApiController) DeleteScale()
- func (c *ApiController) DeleteScan()
- func (c *ApiController) DeleteSession()
- func (c *ApiController) DeleteStore()
- func (c *ApiController) DeleteTask()
- func (c *ApiController) DeleteTemplate()
- func (c *ApiController) DeleteTreeFile()
- func (c *ApiController) DeleteVector()
- func (c *ApiController) DeleteVideo()
- func (c *ApiController) DeleteWelcomeMessage()
- func (c *ApiController) DeleteWorkflow()
- func (c *ApiController) DeployApplication()
- func (c *ApiController) DeployFinetuneJob()
- func (c *ApiController) DevBridge()
- func (c *ApiController) Embeddings()
- func (c *ApiController) EnforceStoreIsolation(requestedStoreName string) (string, bool)
- func (c *ApiController) ExportMyRoutingData()
- func (c *ApiController) Finish()
- func (c *ApiController) GenerateTextToSpeechAudio()
- func (c *ApiController) GenerateTextToSpeechAudioStream()
- func (c *ApiController) GetAIConnectionUsage()
- func (c *ApiController) GetAIConnections()
- func (c *ApiController) GetAcceptLanguage() string
- func (c *ApiController) GetAccount()
- func (c *ApiController) GetActiveFile()
- func (c *ApiController) GetActivities()
- func (c *ApiController) GetAdminProviders()
- func (c *ApiController) GetAgentsDashboardUrl()
- func (c *ApiController) GetAnswer()
- func (c *ApiController) GetApplication()
- func (c *ApiController) GetApplications()
- func (c *ApiController) GetArticle()
- func (c *ApiController) GetArticles()
- func (c *ApiController) GetAsset()
- func (c *ApiController) GetAssets()
- func (c *ApiController) GetCaase()
- func (c *ApiController) GetCaases()
- func (c *ApiController) GetChat()
- func (c *ApiController) GetChats()
- func (c *ApiController) GetCloudUsages()
- func (c *ApiController) GetConnection()
- func (c *ApiController) GetConnections()
- func (c *ApiController) GetConsultation()
- func (c *ApiController) GetConsultations()
- func (c *ApiController) GetDoctor()
- func (c *ApiController) GetDoctors()
- func (c *ApiController) GetFileMy()
- func (c *ApiController) GetFiles()
- func (c *ApiController) GetFinetuneJob()
- func (c *ApiController) GetFinetunePresets()
- func (c *ApiController) GetForm()
- func (c *ApiController) GetFormData()
- func (c *ApiController) GetForms()
- func (c *ApiController) GetGlobalArticles()
- func (c *ApiController) GetGlobalChats()
- func (c *ApiController) GetGlobalFiles()
- func (c *ApiController) GetGlobalForms()
- func (c *ApiController) GetGlobalGraphs()
- func (c *ApiController) GetGlobalMessages()
- func (c *ApiController) GetGlobalProviders()
- func (c *ApiController) GetGlobalScales()
- func (c *ApiController) GetGlobalStores()
- func (c *ApiController) GetGlobalTasks()
- func (c *ApiController) GetGlobalVectors()
- func (c *ApiController) GetGlobalVideos()
- func (c *ApiController) GetGlobalWorkflows()
- func (c *ApiController) GetGraph()
- func (c *ApiController) GetGraphs()
- func (c *ApiController) GetHfRepo()
- func (c *ApiController) GetHospital()
- func (c *ApiController) GetHospitals()
- func (c *ApiController) GetK8sStatus()
- func (c *ApiController) GetMessage()
- func (c *ApiController) GetMessageAnswer()
- func (c *ApiController) GetMessages()
- func (c *ApiController) GetMetrics()
- func (c *ApiController) GetModelAccessStatus()
- func (c *ApiController) GetModelRoute()
- func (c *ApiController) GetModelRoutes()
- func (c *ApiController) GetNode()
- func (c *ApiController) GetNodeTunnel()
- func (c *ApiController) GetNodes()
- func (c *ApiController) GetOrg() string
- func (c *ApiController) GetPatient()
- func (c *ApiController) GetPatients()
- func (c *ApiController) GetPermission()
- func (c *ApiController) GetPermissions()
- func (c *ApiController) GetPrometheusInfo()
- func (c *ApiController) GetProvider()
- func (c *ApiController) GetProviderFlags()
- func (c *ApiController) GetProviders()
- func (c *ApiController) GetPublicScales()
- func (c *ApiController) GetRangeUsages()
- func (c *ApiController) GetRecord()
- func (c *ApiController) GetRecords()
- func (c *ApiController) GetRequestTenantOrgID() string
- func (c *ApiController) GetRequestTenantProjectID() string
- func (c *ApiController) GetRouterHistory()
- func (c *ApiController) GetRouterJudgePanel()
- func (c *ApiController) GetRouterStats()
- func (c *ApiController) GetScale()
- func (c *ApiController) GetScales()
- func (c *ApiController) GetScan()
- func (c *ApiController) GetScans()
- func (c *ApiController) GetScopedOwner() (string, bool)
- func (c *ApiController) GetSessionClaims() *iam.Claims
- func (c *ApiController) GetSessionOwner() string
- func (c *ApiController) GetSessionUser() *iam.User
- func (c *ApiController) GetSessionUsername() string
- func (c *ApiController) GetSessions()
- func (c *ApiController) GetSingleSession()
- func (c *ApiController) GetStorageProviders()
- func (c *ApiController) GetStore()
- func (c *ApiController) GetStoreNames()
- func (c *ApiController) GetStores()
- func (c *ApiController) GetSystemInfo()
- func (c *ApiController) GetTask()
- func (c *ApiController) GetTasks()
- func (c *ApiController) GetTemplate()
- func (c *ApiController) GetTemplates()
- func (c *ApiController) GetTrafficGlobe()
- func (c *ApiController) GetTrainingContribution()
- func (c *ApiController) GetUsages()
- func (c *ApiController) GetUserTableInfos()
- func (c *ApiController) GetUsers()
- func (c *ApiController) GetVector()
- func (c *ApiController) GetVectors()
- func (c *ApiController) GetVersionInfo()
- func (c *ApiController) GetVideo()
- func (c *ApiController) GetVideos()
- func (c *ApiController) GetVmDashboardUrl()
- func (c *ApiController) GetWorkflow()
- func (c *ApiController) GetWorkflows()
- func (c *ApiController) Health()
- func (c *ApiController) ImagesGenerations()
- func (c *ApiController) IndexDocs()
- func (c *ApiController) IngestDocs()
- func (c *ApiController) InstallPatch()
- func (c *ApiController) IsAdmin() bool
- func (c *ApiController) IsCurrentUser(usernameInput string) bool
- func (c *ApiController) IsPreviewMode() bool
- func (c *ApiController) IsSessionDuplicated()
- func (c *ApiController) ListFinetuneJobs()
- func (c *ApiController) ListModels()
- func (c *ApiController) MemoryDelete()
- func (c *ApiController) MemoryFacts()
- func (c *ApiController) MemoryList()
- func (c *ApiController) MemoryRecall()
- func (c *ApiController) MemoryRemember()
- func (c *ApiController) MemorySearch()
- func (c *ApiController) MemoryUpdate()
- func (c *ApiController) PostBackfillDOUsage()
- func (c *ApiController) ProcessSpeechToText()
- func (c *ApiController) QueryRecord()
- func (c *ApiController) QueryRecordSecond()
- func (c *ApiController) RagContext()
- func (c *ApiController) RagDelete()
- func (c *ApiController) RagDeleteDocuments()
- func (c *ApiController) RagDocumentContext()
- func (c *ApiController) RagEmbed()
- func (c *ApiController) RagEmbedMultipart()
- func (c *ApiController) RagQuery()
- func (c *ApiController) RagQueryCompat()
- func (c *ApiController) RagQueryMultiple()
- func (c *ApiController) RagQueryMultipleCompat()
- func (c *ApiController) RefreshFileVectors()
- func (c *ApiController) RefreshMcpTools()
- func (c *ApiController) RefreshModelPricing()
- func (c *ApiController) RefreshStoreVectors()
- func (c *ApiController) ReloadModelConfig()
- func (c *ApiController) RequestModelAccess()
- func (c *ApiController) RequireAdmin() bool
- func (c *ApiController) RequirePrincipal() (*iam.User, bool)
- func (c *ApiController) RequireSessionOwner() (string, bool)
- func (c *ApiController) RequireSignedIn() (string, bool)
- func (c *ApiController) RequireSignedInUser() (*iam.User, bool)
- func (c *ApiController) RequireSuperAdmin() bool
- func (c *ApiController) Rerank()
- func (c *ApiController) ResponseAudio(audioData []byte, contentType string, filename string)
- func (c *ApiController) ResponseAuthError(err error)
- func (c *ApiController) ResponseError(error string, data ...interface{})
- func (c *ApiController) ResponseErrorStream(message *object.Message, errorText string)
- func (c *ApiController) ResponseErrorWithStatus(status int, error string, data ...interface{})
- func (c *ApiController) ResponseForbidden(error string, data ...interface{})
- func (c *ApiController) ResponseOk(data ...interface{})
- func (c *ApiController) ResponseUnauthorized(error string, data ...interface{})
- func (c *ApiController) Responses()
- func (c *ApiController) RetrieveVideo()
- func (c *ApiController) RouterConfigBridge()
- func (c *ApiController) ScanAsset()
- func (c *ApiController) ScanAssets()
- func (c *ApiController) ScrapeDocs()
- func (c *ApiController) ScrapePreview()
- func (c *ApiController) SearchDocs()
- func (c *ApiController) SearchDocsStats()
- func (c *ApiController) SearchHfDatasets()
- func (c *ApiController) SearchHfModels()
- func (c *ApiController) SetPrimaryAdminProvider()
- func (c *ApiController) SetSessionClaims(claims *iam.Claims)
- func (c *ApiController) SetSessionUser(user *iam.User)
- func (c *ApiController) Signin()
- func (c *ApiController) Signout()
- func (c *ApiController) StartConnection()
- func (c *ApiController) StopConnection()
- func (c *ApiController) T(error string) string
- func (c *ApiController) ToggleAdminProvider()
- func (c *ApiController) TunnelMonitor()
- func (c *ApiController) UndeployApplication()
- func (c *ApiController) UpdateApplication()
- func (c *ApiController) UpdateArticle()
- func (c *ApiController) UpdateAsset()
- func (c *ApiController) UpdateCaase()
- func (c *ApiController) UpdateChat()
- func (c *ApiController) UpdateConnection()
- func (c *ApiController) UpdateConsultation()
- func (c *ApiController) UpdateDoctor()
- func (c *ApiController) UpdateFile()
- func (c *ApiController) UpdateForm()
- func (c *ApiController) UpdateGraph()
- func (c *ApiController) UpdateHospital()
- func (c *ApiController) UpdateMessage()
- func (c *ApiController) UpdateModelRoute()
- func (c *ApiController) UpdateNode()
- func (c *ApiController) UpdatePatient()
- func (c *ApiController) UpdatePermission()
- func (c *ApiController) UpdatePreferences()
- func (c *ApiController) UpdateProvider()
- func (c *ApiController) UpdateRecord()
- func (c *ApiController) UpdateScale()
- func (c *ApiController) UpdateScan()
- func (c *ApiController) UpdateSession()
- func (c *ApiController) UpdateStore()
- func (c *ApiController) UpdateTask()
- func (c *ApiController) UpdateTemplate()
- func (c *ApiController) UpdateTrainingContribution()
- func (c *ApiController) UpdateTreeFile()
- func (c *ApiController) UpdateVector()
- func (c *ApiController) UpdateVideo()
- func (c *ApiController) UpdateWorkflow()
- func (c *ApiController) UploadFile()
- func (c *ApiController) UploadTaskDocument()
- func (c *ApiController) UploadVideo()
- func (c *ApiController) VideoContent()
- func (c *ApiController) VideosGenerations()
- func (c *ApiController) WecomBotHandleMessage()
- func (c *ApiController) WecomBotVerifyUrl()
- type BrandIAM
- type CacheTTLs
- type CarrierWriter
- type Cleaner
- type DOBackfillOptions
- type DOBackfillPlan
- type DOBackfillRow
- type FallbackDef
- type FeatureFlags
- type GuacamoleHandler
- type ModelConfig
- func (mc *ModelConfig) AutoRoutingActive(orgPref string) bool
- func (mc *ModelConfig) ConfRouterPolicy() (map[string][]string, float64)
- func (mc *ModelConfig) ContextWindow(model string) int
- func (mc *ModelConfig) GetPrice(model string) modelPrice
- func (mc *ModelConfig) GetPriceOK(model string) (modelPrice, bool)
- func (mc *ModelConfig) LastPricingRefresh() time.Time
- func (mc *ModelConfig) ListModels() []modelInfo
- func (mc *ModelConfig) ListModelsWithUpstream() []zapModelEntry
- func (mc *ModelConfig) PremiumGateEnabled() bool
- func (mc *ModelConfig) Reload() error
- func (mc *ModelConfig) ResolveRoute(model string) *modelRoute
- func (mc *ModelConfig) RetryConfig() RetryDef
- func (mc *ModelConfig) RouteForContext(model string, tokens int) (provider, upstream string, window int, ok bool)
- func (mc *ModelConfig) RouterClient(known func(string) bool) router.Client
- func (mc *ModelConfig) RouterEnabled() bool
- func (mc *ModelConfig) Status() string
- func (mc *ModelConfig) Stop()
- type ModelConfigFile
- type ModelDef
- type ModelPriceDef
- type OpenAIResponsesRequest
- type OpenAIWriter
- type PanelJudge
- type ProviderUsage
- type ProviderUsageModelSpend
- type ProviderUsageSeriesPoint
- type ProviderUsageTotals
- type RefinedWriter
- type Response
- type RetryDef
- type RouterConfigDef
- type ServedUsage
- type ServiceEndpoints
- type TextToSpeechRequest
Constants ¶
const ( TunnelClosed int = -1 Normal int = 0 ConnectionNotFound int = 800 NewTunnelError int = 801 ForcedDisconnect int = 802 NodeNotActive int = 803 ParametersError int = 804 NodeNotFound int = 805 ConnectionUpdateError int = 806 )
const DefaultFreeTierFlashCeilingPerMillion = 3.00
DefaultFreeTierFlashCeilingPerMillion caps the FREE tier's `auto` routing to the flash pool. It is a BLENDED $/1M bound ((input+output)/2 — the blendedPriceForOrg unit). It sits deliberately ABOVE the synthesized default price (default_pricing 1/4 ⇒ blended 2.50), so a servable model with no explicit price (a zen champion, enso-flash) is treated as flash and never dropped, while EVERY premium model sits far above it (glm-5.2 ~6.3, gpt-5.x ~10, o3 ~25, opus/fable ~45) and is excluded with wide margin — as are the pricey non-premium ids (qwen3-coder ~3.6, kimi ~5, deepseek-reasoner ~5.5). The cheap pool (gpt-4o-mini ~0.38, the gemma/mistral/nemotron/llama pool ~0.1–0.35, deepseek-v3.2 ~0.69) is well within it. The family-tier gate already keeps free callers off the enso ladder above enso-flash; this ceiling is the complementary bound that keeps them off the do-ai premium models (not family SKUs).
const DefaultRouterQualityBias = 1.0
DefaultRouterQualityBias is the dial applied when an org AND the "*" row both leave it unset. It is 1.0 (max quality) on purpose: at bias ≥ 1 applyRouterQualityBias is INERT, so an org that never touches the dial routes EXACTLY as before (the bandit's quality- leaning pick within the cost ceiling) — the dial is strictly opt-in, never a fleet-wide behavior change. An org dials toward savings by explicitly lowering it.
const MsgTypeCloudOps uint16 = 110
MsgTypeCloudOps is the ZAP message type for inter-service cloud operations.
const RoutedModelHeader = "X-Routed-Model"
RoutedModelHeader is the transparency header the chat controller sets when a virtual `auto`/`zen-router` request was resolved to a concrete model. Callers read it to see which model actually served (the response body echoes the same id in its `model` field).
const SourceExplicit = "explicit"
SourceExplicit marks a routing event for a request whose model the CALLER chose (not the virtual `auto`). Recorded so EVERY request — not only auto — is a labeled data point the moment the caller rates it: up/down feedback works for ALL models, and the ledger captures which model was selected for which task.
const SourceMeanField = "meanfield"
SourceMeanField labels a RoutingEvent whose model the congestion layer chose OFF the base champion — an honest origin tag in the ledger, distinct from engine/heuristic/ explore, set ONLY when the mean-field re-rank actually changed the pick.
Variables ¶
Functions ¶
func DenyRequest ¶
func FamilyModelGated ¶ added in v1.809.2
FamilyModelGated reports whether a model id is a gated family SKU per discovery. Exported so the balance filter (routers) can ask without knowing the family layout. Access to a gated SKU still requires a grant (familyAccessAllowed), but a gated SKU is PAID like any other model — a grant unlocks access, never free billing.
func FilterStoresByHomepage ¶
FilterStoresByHomepage filters stores based on user's Homepage field.
func GetUserByAccessKey ¶ added in v1.807.1
GetUserByAccessKey resolves an hk- IAM API key to its owning user via Hanzo IAM. Exported so the authz filter and the balance gate (package routers) resolve the key path to the same verified principal as the JWT path — ONE credential resolver, one tenant, one billing subject, one IAM transport.
func GetUserName ¶
func InitAuthConfig ¶
func InitAuthConfig()
InitAuthConfig establishes the IAM signing cert this process validates every bearer token against. It PANICS when IAM is configured but the cert cannot be established.
It used to warn and return. That is a fail-open on the security boundary of the whole platform, and it cost us a full day: IAM tightened authorization on the application read, GetApplication started coming back 403, this function printed "(auth features disabled)" and let the process serve anyway. With no cert, every bearer failed to validate, so EVERY authenticated route answered 401 — including free ones like /v1/models. The pod stayed Running and passed its probes the whole time, so nothing caught it: no crashloop, no failed rollout, no alert. A pod that is up and 401ing everything is strictly worse than a pod that is visibly down.
Refusing to boot is the honest signal. It surfaces as a crashloop, which the operator already knows how to revert, and Kubernetes backoff absorbs a transient IAM blip on the way up. The one thing it must never do is serve traffic with authentication silently switched off.
A deployment with no IAM_URL is a legitimate no-auth configuration (dev, tests) and returns cleanly — that is the ONLY path that leaves auth unconfigured.
func InitBillingQueue ¶
func InitBillingQueue() *util.BillingQueue
InitBillingQueue creates the billing queue from app config. Must be called once during startup. Returns the queue so main.go can call Shutdown().
func InitForwardBridge ¶ added in v1.785.4
InitForwardBridge registers the canonical HTTP-over-ZAP terminal on the inference node, dispatching every Forward to h. Pass routers.App (the fully-wrapped native router) so all BeforeRouter filters — the balance gate and auth/tenant filters — run on the bridged request before the route dispatches.
No-op when the node is absent (ZAP_ENABLED != true) or h is nil, mirroring InitZapHandlers; ai's :8000 HTTP behavior is unchanged either way.
func InitInterserviceZap ¶
func InitInterserviceZap()
InitInterserviceZap starts a dedicated ZAP node for inter-service operations. Separate from the main inference ZAP node (port 9999).
func InitModelConfig ¶
InitModelConfig loads the YAML config and optionally starts a background refresh goroutine (when live_mode is true). Returns an error if the file cannot be read or parsed. This is non-fatal — the caller can log and fall back to static maps.
func InitZapHandlers ¶
func InitZapHandlers()
InitZapHandlers registers native ZAP service handlers on the node.
func QueryCarrierText ¶
func QueryCarrierText(question string, writer *RefinedWriter, history []*model.RawMessage, prompt string, knowledge []*model.RawMessage, modelProviderObj model.ModelProvider, needTitle bool, suggestionCount int, lang string) (*model.ModelResult, error)
func SeedInternalTrainingConsent ¶ added in v1.826.4
func SeedInternalTrainingConsent()
SeedInternalTrainingConsent sets TrainingContribution=enabled on the OrgSettings row of every reserved INTERNAL org (reservedInternalOrgs) — our own admin/dev orgs — so their turns are EXPLICITLY opted in. This matters because the per-request EU/EEA/UK judge guard requires EXPLICIT consent (not the opt-out default), so our own traffic stays unambiguously contributable everywhere. Idempotent: an org already "enabled" is left untouched; a missing row is created, any other row is updated in place (preserving its other settings). It ONLY ever touches OUR reserved orgs — it NEVER bulk-enables customer orgs. Best-effort at boot: a per-org failure logs and never blocks startup.
func StartRouterJudge ¶ added in v1.826.1
func StartRouterJudge()
StartRouterJudge arms the LLM-as-a-judge reward path from DYNAMIC, DB-backed config — no env, no restart. Called once at boot (Bootstrap, next to StartRouterProbe/StartRouterTrainer). It loads the config ONCE synchronously (so the judge is armed before the server serves) then refreshes it on a ticker; admin.hanzo.ai edits to the "*" row take effect within one refresh window. ON by default (object.GetCachedJudgeConfig's built-in defaults run the diverse panel on ~10% of eligible traffic); an admin disables or retunes it live. Never fails boot.
func StartRouterProbe ¶ added in v1.815.0
func StartRouterProbe()
StartRouterProbe launches the background self-probe loop when configured. Called once at boot (cmd/aid). Never fails boot: misconfiguration logs and disables. The loop jitters ±20% so probes never synchronize across replicas.
func StartRouterTrainer ¶ added in v1.816.0
func StartRouterTrainer()
StartRouterTrainer schedules the fit→gate→deploy→publish loop when enabled. Called once at boot (cmd/aid). Never fails boot.
func StopInterserviceZap ¶
func StopInterserviceZap()
StopInterserviceZap gracefully shuts down the inter-service ZAP node.
func TraceServedUsage ¶ added in v1.814.0
func TraceServedUsage(ctx context.Context, in ServedUsage)
TraceServedUsage emits the warehouse row (hanzo.cloud_usage) + gen_ai span for a self-billed request — recordTrace WITHOUT recordUsage, so the commerce debit the caller already made is never doubled. One warehouse writer, two billers, zero double-billing. Safe under a nil/zero input: an empty Owner still writes an (unattributed) row so traffic is never silently invisible; StartTime zero anchors at now.
Types ¶
type AnthropicContentBlock ¶
AnthropicContentBlock is a content block in the response.
type AnthropicErrorBody ¶
type AnthropicErrorBody struct {
Type string `json:"type"`
Error struct {
Type string `json:"type"`
Message string `json:"message"`
} `json:"error"`
}
AnthropicErrorBody is the Anthropic error response shape.
type AnthropicMessage ¶
type AnthropicMessage struct {
Role string `json:"role"`
Content json.RawMessage `json:"content"`
}
AnthropicMessage is a single message in the Anthropic conversation. Content accepts both string ("hello") and array-of-blocks ([{"type":"text","text":"hello"}]) formats per the Anthropic Messages API.
func (*AnthropicMessage) ContentText ¶
func (m *AnthropicMessage) ContentText() string
ContentText returns the message content as a plain string. Handles both string format and array-of-content-blocks format.
type AnthropicRequest ¶
type AnthropicRequest struct {
Model string `json:"model"`
MaxTokens int `json:"max_tokens"`
System json.RawMessage `json:"system,omitempty"`
Messages []AnthropicMessage `json:"messages"`
Tools []AnthropicTool `json:"tools,omitempty"`
ToolChoice json.RawMessage `json:"tool_choice,omitempty"`
Temperature float32 `json:"temperature,omitempty"`
Stream bool `json:"stream"`
// Thinking is Anthropic extended-thinking config: {"type":"enabled","budget_tokens":N}.
// RawMessage so it forwards VERBATIM to a native Anthropic upstream (the native path
// re-marshals this struct) AND is parseable by anthropicThinkingToReasoningEffort for
// the Anthropic→OpenAI translation. One field, two consumers — the round trip that
// used to be silently dropped on BOTH paths.
Thinking json.RawMessage `json:"thinking,omitempty"`
}
AnthropicRequest is the Anthropic Messages API request body.
func (*AnthropicRequest) SystemText ¶
func (r *AnthropicRequest) SystemText() string
SystemText returns the system prompt as a plain string. Handles both string format ("You are helpful") and array format ([{"type":"text","text":"You are helpful"}]) used by the Anthropic SDK.
type AnthropicResponse ¶
type AnthropicResponse struct {
ID string `json:"id"`
Type string `json:"type"`
Role string `json:"role"`
Content []AnthropicContentBlock `json:"content"`
Model string `json:"model"`
StopReason string `json:"stop_reason"`
Usage AnthropicUsage `json:"usage"`
}
AnthropicResponse is the non-streaming Messages API response.
type AnthropicTool ¶ added in v1.786.0
type AnthropicTool struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
InputSchema json.RawMessage `json:"input_schema"`
}
AnthropicTool is a tool definition in the Anthropic format.
type AnthropicUsage ¶
type AnthropicUsage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
}
AnthropicUsage tracks token counts.
type AnthropicWriter ¶
type AnthropicWriter struct {
web.Response
Cleaner Cleaner
Buffer []byte
MessageBuf []byte
RequestID string
Stream bool
StreamSent bool
Model string
// contains filtered or unexported fields
}
AnthropicWriter implements io.Writer, collecting output for non-streaming and emitting SSE events in Anthropic format for streaming.
func (*AnthropicWriter) Close ¶
func (w *AnthropicWriter) Close(promptTokens, completionTokens, totalTokens int) error
Close finalizes the streaming response with stop events.
func (*AnthropicWriter) MessageString ¶
func (w *AnthropicWriter) MessageString() string
MessageString returns the full accumulated message text.
type ApiController ¶
type ApiController struct {
web.Controller
}
func (*ApiController) ActivateFile ¶
func (c *ApiController) ActivateFile()
ActivateFile @Title ActivateFile @Tag File API @Description activate file @Param key query string true "The key of the file" @Param filename query string true "The name of the file" @Success 200 {object} controllers.Response The Response object @router /activate-file [post]
func (*ApiController) AddAIConnection ¶ added in v1.803.0
func (c *ApiController) AddAIConnection()
AddAIConnection connects (or reconnects) a third-party AI account for the org by sealing the supplied key into KMS and upserting the org's provider row. The raw key is sealed BEFORE the row is built and is never persisted or echoed. @Title AddAIConnection @Tag AI Connections API @Description connect a third-party AI account by API key (sealed into KMS) @Param body body object true "{provider, apiKey}" @Success 200 {object} controllers.aiConnResponse The Response object @router /ai/connections [post]
func (*ApiController) AddApplication ¶
func (c *ApiController) AddApplication()
AddApplication @Title AddApplication @Tag Application API @Description add application @Param body body object.Application true "The details of the application" @Success 200 {object} controllers.Response The Response object @router /add-application [post]
func (*ApiController) AddArticle ¶
func (c *ApiController) AddArticle()
AddArticle @Title AddArticle @Tag Article API @Description add article @Param body body object.Article true "The details of the article" @Success 200 {object} controllers.Response The Response object @router /add-article [post]
func (*ApiController) AddAsset ¶
func (c *ApiController) AddAsset()
AddAsset @Title AddAsset @Tag Asset API @Description add an asset @Param body body object.Asset true "The details of the asset" @Success 200 {object} controllers.Response The Response object @router /add-asset [post]
func (*ApiController) AddCaase ¶
func (c *ApiController) AddCaase()
AddCaase @Title AddCaase @Tag Caase API @Description add a caase @Param body body object.Caase true "The details of the caase" @Success 200 {object} controllers.Response The Response object @router /add-caase [post]
func (*ApiController) AddChat ¶
func (c *ApiController) AddChat()
AddChat @Title AddChat @Tag Chat API @Description add chat @Param body body object.Chat true "The details of the chat" @Success 200 {object} controllers.Response The Response object @router /add-chat [post]
func (*ApiController) AddConnection ¶
func (c *ApiController) AddConnection()
AddConnection @Title AddConnection @Tag Connection API @Description add connection @Param body body object.Connection true "The connection object" @Success 200 {object} Response @router /add-connection [post]
func (*ApiController) AddConsultation ¶
func (c *ApiController) AddConsultation()
AddConsultation @Title AddConsultation @Tag Consultation API @Description add a consultation @Param body body object.Consultation true "The details of the consultation" @Success 200 {object} controllers.Response The Response object @router /add-consultation [post]
func (*ApiController) AddDoctor ¶
func (c *ApiController) AddDoctor()
AddDoctor @Title AddDoctor @Tag Doctor API @Description add a doctor @Param body body object.Doctor true "The details of the doctor" @Success 200 {object} controllers.Response The Response object @router /add-doctor [post]
func (*ApiController) AddFile ¶
func (c *ApiController) AddFile()
AddFile @Title AddFile @Tag File API @Description add file object @Param body body object.File true "The details of the file object" @Success 200 {object} controllers.Response The Response object @router /add-file [post]
func (*ApiController) AddForm ¶
func (c *ApiController) AddForm()
AddForm @Title AddForm @Tag Form API @Description add form @Param body body object.Form true "The details of the form" @Success 200 {object} controllers.Response The Response object @router /add-form [post]
func (*ApiController) AddGraph ¶
func (c *ApiController) AddGraph()
AddGraph @Title AddGraph @Tag Graph API @Description add Graph @Param body body object.Graph true "The details of the Graph" @Success 200 {object} controllers.Response The Response object @router /add-Graph [post]
func (*ApiController) AddHospital ¶
func (c *ApiController) AddHospital()
AddHospital @Title AddHospital @Tag Hospital API @Description add a hospital @Param body body object.Hospital true "The details of the hospital" @Success 200 {object} controllers.Response The Response object @router /add-hospital [post]
func (*ApiController) AddMessage ¶
func (c *ApiController) AddMessage()
AddMessage @Title AddMessage @Tag Message API @Description add message @Param body body object.Message true "The details of the message" @Success 200 {object} object.Chat The Response object @router /add-message [post]
func (*ApiController) AddModelRoute ¶
func (c *ApiController) AddModelRoute()
AddModelRoute @Title AddModelRoute @Tag ModelRoute API @Description add a model route @Param body body object.ModelRoute true "The details of the model route" @Success 200 {object} controllers.Response The Response object @router /add-model-route [post]
func (*ApiController) AddNode ¶
func (c *ApiController) AddNode()
AddNode @Title AddNode @Tag Node API @Description add a node @Param body body object.Node true "The details of the node" @Success 200 {object} controllers.Response The Response object @router /add-node [post]
func (*ApiController) AddNodeTunnel ¶
func (c *ApiController) AddNodeTunnel()
AddNodeTunnel @Title AddNodeTunnel @Tag Connection API @Description add node tunnel session @Param nodeId query string true "The id of node" @Success 200 {object} Response @router /add-node-tunnel [get]
func (*ApiController) AddPatient ¶
func (c *ApiController) AddPatient()
AddPatient @Title AddPatient @Tag Patient API @Description add a patient @Param body body object.Patient true "The details of the patient" @Success 200 {object} controllers.Response The Response object @router /add-patient [post]
func (*ApiController) AddPermission ¶
func (c *ApiController) AddPermission()
AddPermission @Title AddPermission @Tag Permission API @Description add permission @Param body body iam.Permission true "The details of the permission" @Success 200 {object} controllers.Response The Response object @router /add-permission [post]
func (*ApiController) AddProvider ¶
func (c *ApiController) AddProvider()
AddProvider @Title AddProvider @Tag Provider API @Description add provider @Param body body object.Provider true "The details of the provider" @Success 200 {object} controllers.Response The Response object @router /add-provider [post]
func (*ApiController) AddRecord ¶
func (c *ApiController) AddRecord()
AddRecord @Title AddRecord @Tag Record API @Description add a record @Param body body object.Record true "The details of the record" @Success 200 {object} controllers.Response The Response object @router /add-record [post]
func (*ApiController) AddRecords ¶
func (c *ApiController) AddRecords()
AddRecords @Title AddRecords @Tag Record API @Description add multiple records @Param body body []object.Record true "The details of the records" @Param sync query string false "Set to 'true' or '1' to enable synchronous processing" @Success 200 {object} controllers.Response The Response object @router /add-records [post]
func (*ApiController) AddRoutingReward ¶ added in v1.810.0
func (c *ApiController) AddRoutingReward()
AddRoutingReward attaches a per-request outcome reward to the routing decision that served request_id — the enso training loop's quality signal. Org-scoped via the same session-OR-Bearer principal the usage read uses (RequirePrincipal): the reward lands only on the caller's OWN org's event, so a request_id from another org (or unknown) is a 404 — cross-org writes are impossible and unknown ids are indistinguishable from foreign ones. Idempotent: a repeat overwrites. The body carries NO prompt text — only {request_id, reward|rating}.
@Title AddRoutingReward @Tag Router API @Description attach an outcome reward (0..1) or 1..5 rating to a routed request, for enso training @Param body body controllers.routingRewardRequest true "request_id + reward (0..1) or rating (1..5)" @Success 200 {object} controllers.routingRewardResult The Response object @router /add-routing-reward [post]
func (*ApiController) AddScale ¶
func (c *ApiController) AddScale()
AddScale @router /add-scale [post]
func (*ApiController) AddScan ¶
func (c *ApiController) AddScan()
AddScan @Title AddScan @Tag Scan API @Description add a scan @Param body body object.Scan true "The details of the scan" @Success 200 {object} controllers.Response The Response object @router /add-scan [post]
func (*ApiController) AddSession ¶
func (c *ApiController) AddSession()
AddSession @Title AddSession @Tag Session API @Description Add session for one user in one application. If there are other existing sessions, join the session into the list. @Param id query string true "The id(organization/application/user) of session" @Param sessionId query string true "sessionId to be added" @Success 200 {array} string The Response object @router /add-session [post]
func (*ApiController) AddStore ¶
func (c *ApiController) AddStore()
AddStore @Title AddStore @Tag Store API @Description add store @Param body body object.Store true "The details of the store" @Success 200 {object} controllers.Response The Response object @router /add-store [post]
func (*ApiController) AddTask ¶
func (c *ApiController) AddTask()
AddTask @Title AddTask @Tag Task API @Description add task @Param body body object.Task true "The details of the task" @Success 200 {object} controllers.Response The Response object @router /add-task [post]
func (*ApiController) AddTemplate ¶
func (c *ApiController) AddTemplate()
AddTemplate @Title AddTemplate @Tag Template API @Description add template @Param body body object.Template true "The details of the template" @Success 200 {object} controllers.Response The Response object @router /add-template [post]
func (*ApiController) AddTreeFile ¶
func (c *ApiController) AddTreeFile()
AddTreeFile @Title AddTreeFile @Tag Tree File API @Description add tree file @Param store query string true "The store of the file" @Param key query string true "The key of the file" @Param isLeaf query string true "if is leaf" @Param filename query string true "The name of the file" @Success 200 {object} controllers.Response The Response object @router /add-tree-file [post]
func (*ApiController) AddVector ¶
func (c *ApiController) AddVector()
AddVector @Title AddVector @Tag Vector API @Description add vector @Param body body object.Vector true "The details of the vector" @Success 200 {object} controllers.Response The Response object @router /add-vector [post]
func (*ApiController) AddVideo ¶
func (c *ApiController) AddVideo()
AddVideo @Title AddVideo @Tag Video API @Description add video @Param body body object.Video true "The details of the video" @Success 200 {object} controllers.Response The Response object @router /add-video [post]
func (*ApiController) AddWorkflow ¶
func (c *ApiController) AddWorkflow()
AddWorkflow @Title AddWorkflow @Tag Workflow API @Description add workflow @Param body body object.Workflow true "The details of the workflow" @Success 200 {object} controllers.Response The Response object @router /add-workflow [post]
func (*ApiController) AdminGrantModelAccess ¶ added in v1.809.2
func (c *ApiController) AdminGrantModelAccess()
AdminGrantModelAccess (POST /v1/admin/model-access) grants (or requests) access for any org/user/model. SuperAdmin only — mirrors the router_policy admin pattern but at platform scope. Body: {owner, user, email?, model, status?}. user "" grants the whole org; status defaults to "granted".
func (*ApiController) AdminListModelAccess ¶ added in v1.809.2
func (c *ApiController) AdminListModelAccess()
AdminListModelAccess (GET /v1/admin/model-access[?owner=]) lists access rows. SuperAdmin only; without ?owner it returns every org's rows.
func (*ApiController) AnalyzeTask ¶
func (c *ApiController) AnalyzeTask()
AnalyzeTask @Title AnalyzeTask @Tag Task API @Description analyze task document and generate structured report @Param id query string true "The id (owner/name) of the task" @Success 200 {object} object.TaskResult The Response object @router /analyze-task [post]
func (*ApiController) AnthropicCountTokens ¶ added in v1.805.12
func (c *ApiController) AnthropicCountTokens()
AnthropicCountTokens implements POST /v1/messages/count_tokens. Claude Code calls it before a request; it returns {"input_tokens": N} for the given model + messages + tools. @Title AnthropicCountTokens @Tag Anthropic Compatible API @Description Anthropic-compatible token counting. @router /messages/count_tokens [post]
func (*ApiController) AnthropicMessages ¶
func (c *ApiController) AnthropicMessages()
AnthropicMessages implements the Anthropic Messages API. @Title AnthropicMessages @Tag Anthropic Compatible API @Description Anthropic compatible messages API. Accepts:
- IAM API key (hk-...) via x-api-key or Authorization header
- hanzo.id JWT token via Authorization header
- Provider API key via Authorization header
@Param body body AnthropicRequest true "The Anthropic messages request" @Success 200 {object} AnthropicResponse @router /messages [post]
func (*ApiController) AudioMedia ¶ added in v1.807.0
func (c *ApiController) AudioMedia()
AudioMedia serves the generative audio verbs — /v1/audio/voice (TTS), /music, /foley — that the Zen family serves natively. It resolves the SKU and, for a Zen model, forwards to zen's matching verb billed per call at the discovered price. These verbs are Zen-native; a non-Zen model is rejected.
func (*ApiController) AudioSpeech ¶ added in v1.796.6
func (c *ApiController) AudioSpeech()
AudioSpeech is the OpenAI-compatible TTS endpoint (POST /v1/audio/speech). It authenticates the caller, resolves `model` to its TTS provider (the SAME model-route resolution the chat/images/video endpoints use — so a BYO node registered as a TTS provider works transparently), synthesizes the audio, and streams the bytes back. One code path, OpenAI-shaped, no store/message coupling (unlike the legacy /v1/generate-text-to-speech-audio which is bound to a chat store).
@Title AudioSpeech @Tag Audio API @Description OpenAI-compatible text-to-speech @Param body body controllers.audioSpeechRequest true "speech request" @Success 200 {file} audio "audio bytes" @router /audio/speech [post]
func (*ApiController) CallbackAIProvider ¶ added in v1.805.0
func (c *ApiController) CallbackAIProvider()
CallbackAIProvider completes OAuth: the org is recovered from the SIGNED state (not a header), the code is exchanged for a token, the token is SEALED into KMS (never the row/logs) through the same path as a BYOK key, and the org's provider row is upserted to "connected". The browser is then redirected back to the console with ?ai_connected=<provider> (or ?ai_connect_error=<provider> on failure). Because the org comes from the state THIS server signed, an attacker cannot land their token in a victim org — which is why this endpoint is state-authenticated rather than credential-gated. @Title CallbackAIProvider @Tag AI Connections API @Description OAuth callback that seals the provider token and connects the account @Param provider path string true "provider slug (openai|anthropic|google)" @Success 302 {string} string redirect back to the console @router /ai/connections/:provider/callback [get]
func (*ApiController) CancelFinetuneJob ¶ added in v1.806.13
func (c *ApiController) CancelFinetuneJob()
CancelFinetuneJob deletes the TrainJob CR, meters the GPU-hours used so far, and marks the job cancelled. ?id= or ?name=
func (*ApiController) ChatCompletions ¶
func (c *ApiController) ChatCompletions()
ChatCompletions implements the OpenAI-compatible chat completions API @Title ChatCompletions @Tag OpenAI Compatible API @Description OpenAI compatible chat completions API. Accepts:
- Widget key (hz_...) — restricted models, no balance check, token-capped
- IAM API key (hk-...) — full model routing + billing
- hanzo.id JWT token — full model routing + billing
- Provider API key — direct provider access
@Param body body openai.ChatCompletionRequest true "The OpenAI chat request" @Success 200 {object} openai.ChatCompletionResponse @router /chat [post]
func (*ApiController) CheckSignedIn ¶
func (c *ApiController) CheckSignedIn() (string, bool)
func (*ApiController) CommitRecord ¶
func (c *ApiController) CommitRecord()
CommitRecord @Title CommitRecord @Tag Record API @Description commit a record @Param body body object.Record true "The details of the record" @Success 200 {object} controllers.Response The Response object @router /commit-record [post]
func (*ApiController) CommitRecordSecond ¶
func (c *ApiController) CommitRecordSecond()
CommitRecordSecond @Title CommitRecordSecond @Tag Record API @Description commit a record @Param body body object.Record true "The details of the record" @Success 200 {object} controllers.Response The Response object @router /commit-record-second [post]
func (*ApiController) ConnectAIProvider ¶ added in v1.805.0
func (c *ApiController) ConnectAIProvider()
ConnectAIProvider begins an OAuth connection for the caller's org: it binds the org into a signed state and sends the caller to the provider's authorize URL. By default it 302-redirects (a top-level browser "connect your login" click); a SPA/BFF that needs to drive the redirect itself passes ?format=json and gets {authorizeUrl} in the standard envelope. The org is the VERIFIED principal, so only the caller's own connection can result. @Title ConnectAIProvider @Tag AI Connections API @Description begin an OAuth connection to a third-party AI account (login manager) @Param provider path string true "provider slug (openai|anthropic|google)" @Success 302 {string} string redirect to the provider authorize URL @router /ai/connections/:provider/authorize [get]
func (*ApiController) Crawl ¶ added in v1.790.4
func (c *ApiController) Crawl()
Crawl @Title Crawl @Tag Crawl API @Description crawl one or more URLs via the self-hosted Hanzo Crawl (Crawl4AI) @Description service and return clean, LLM-ready markdown. The single canonical @Description "crawl a URL, get content back" endpoint. @Param body body controllers.crawlRequest true "Crawl request ({url} or {urls})" @Success 200 {object} controllers.Response "{results: []object.CrawlResult}" @router /crawl [post]
func (*ApiController) CreateFinetuneJob ¶ added in v1.806.13
func (c *ApiController) CreateFinetuneJob()
CreateFinetuneJob validates the request, resolves efficient defaults, persists the job, and submits a real TrainJob CR. A submit failure (e.g. no cluster wired) is surfaced honestly: the job is saved with status "failed" + the reason, never faked.
func (*ApiController) DeleteAIConnection ¶ added in v1.803.0
func (c *ApiController) DeleteAIConnection()
DeleteAIConnection disconnects a third-party AI account: it deactivates the org's row so completion resolution falls back to the global Hanzo account (no BYO), and best-effort tombstones the sealed secret. Idempotent. @Title DeleteAIConnection @Tag AI Connections API @Description disconnect a third-party AI account @Param provider path string true "provider slug" @Success 200 {object} controllers.aiConnResponse The Response object @router /ai/connections/:provider [delete]
func (*ApiController) DeleteAllVectors ¶
func (c *ApiController) DeleteAllVectors()
DeleteAllVectors @Title DeleteAllVectors @Tag Vector API @Description delete all vectors @Success 200 {object} controllers.Response The Response object @router /delete-all-vectors [post]
func (*ApiController) DeleteApplication ¶
func (c *ApiController) DeleteApplication()
DeleteApplication @Title DeleteApplication @Tag Application API @Description delete application @Param body body object.Application true "The details of the application" @Success 200 {object} controllers.Response The Response object @router /delete-application [post]
func (*ApiController) DeleteArticle ¶
func (c *ApiController) DeleteArticle()
DeleteArticle @Title DeleteArticle @Tag Article API @Description delete article @Param body body object.Article true "The details of the article" @Success 200 {object} controllers.Response The Response object @router /delete-article [post]
func (*ApiController) DeleteAsset ¶
func (c *ApiController) DeleteAsset()
DeleteAsset @Title DeleteAsset @Tag Asset API @Description delete an asset @Param body body object.Asset true "The details of the asset" @Success 200 {object} controllers.Response The Response object @router /delete-asset [post]
func (*ApiController) DeleteCaase ¶
func (c *ApiController) DeleteCaase()
DeleteCaase @Title DeleteCaase @Tag Caase API @Description delete a caase @Param body body object.Caase true "The details of the caase" @Success 200 {object} controllers.Response The Response object @router /delete-caase [post]
func (*ApiController) DeleteChat ¶
func (c *ApiController) DeleteChat()
DeleteChat @Title DeleteChat @Tag Chat API @Description delete chat @Param body body object.Chat true "The details of the chat" @Success 200 {object} controllers.Response The Response object @router /delete-chat [post]
func (*ApiController) DeleteConnection ¶
func (c *ApiController) DeleteConnection()
DeleteConnection @Title DeleteConnection @Tag Connection API @Description delete connection @Param id query string true "The id of connection" @Success 200 {object} Response @router /delete-connection [post]
func (*ApiController) DeleteConsultation ¶
func (c *ApiController) DeleteConsultation()
DeleteConsultation @Title DeleteConsultation @Tag Consultation API @Description delete a consultation @Param body body object.Consultation true "The details of the consultation" @Success 200 {object} controllers.Response The Response object @router /delete-consultation [post]
func (*ApiController) DeleteDoctor ¶
func (c *ApiController) DeleteDoctor()
DeleteDoctor @Title DeleteDoctor @Tag Doctor API @Description delete a doctor @Param body body object.Doctor true "The details of the doctor" @Success 200 {object} controllers.Response The Response object @router /delete-doctor [post]
func (*ApiController) DeleteFile ¶
func (c *ApiController) DeleteFile()
DeleteFile @Title DeleteFile @Tag File API @Description delete file object @Param body body object.File true "The details of the file object" @Success 200 {object} controllers.Response The Response object @router /delete-file [post]
func (*ApiController) DeleteForm ¶
func (c *ApiController) DeleteForm()
DeleteForm @Title DeleteForm @Tag Form API @Description delete form @Param body body object.Form true "The details of the form" @Success 200 {object} controllers.Response The Response object @router /delete-form [post]
func (*ApiController) DeleteGraph ¶
func (c *ApiController) DeleteGraph()
DeleteGraph @Title DeleteGraph @Tag Graph API @Description delete Graph @Param body body object.Graph true "The details of the Graph" @Success 200 {object} controllers.Response The Response object @router /delete-Graph [post]
func (*ApiController) DeleteHospital ¶
func (c *ApiController) DeleteHospital()
DeleteHospital @Title DeleteHospital @Tag Hospital API @Description delete a hospital @Param body body object.Hospital true "The details of the hospital" @Success 200 {object} controllers.Response The Response object @router /delete-hospital [post]
func (*ApiController) DeleteMessage ¶
func (c *ApiController) DeleteMessage()
DeleteMessage @Title DeleteMessage @Tag Message API @Description delete message @Param body body object.Message true "The details of the message" @Success 200 {object} controllers.Response The Response object @router /delete-message [post]
func (*ApiController) DeleteModelRoute ¶
func (c *ApiController) DeleteModelRoute()
DeleteModelRoute @Title DeleteModelRoute @Tag ModelRoute API @Description delete a model route @Param body body object.ModelRoute true "The details of the model route" @Success 200 {object} controllers.Response The Response object @router /delete-model-route [post]
func (*ApiController) DeleteMyRoutingData ¶ added in v1.820.0
func (c *ApiController) DeleteMyRoutingData()
DeleteMyRoutingData deletes ALL of the caller's OWN org routing events — the self-scoped right-to-be-forgotten. Org-admin gated and self-scoped (c.GetOrg()), so a caller can only ever delete its own data, never another tenant's. Completes the data-ownership story: content-free ledger + opt-in + self-export + self-delete.
@Title DeleteMyRoutingData @Tag Router API @Description delete all of the caller's own org routing events (right to be forgotten) @router /delete-my-routing-data [post]
func (*ApiController) DeleteNode ¶
func (c *ApiController) DeleteNode()
DeleteNode @Title DeleteNode @Tag Node API @Description delete a node @Param body body object.Node true "The details of the node" @Success 200 {object} controllers.Response The Response object @router /delete-node [post]
func (*ApiController) DeletePatient ¶
func (c *ApiController) DeletePatient()
DeletePatient @Title DeletePatient @Tag Patient API @Description delete a patient @Param body body object.Patient true "The details of the patient" @Success 200 {object} controllers.Response The Response object @router /delete-patient [post]
func (*ApiController) DeletePermission ¶
func (c *ApiController) DeletePermission()
DeletePermission @Title DeletePermission @Tag Permission API @Description delete permission @Param body body iam.Permission true "The details of the permission" @Success 200 {object} controllers.Response The Response object @router /delete-permission [post]
func (*ApiController) DeleteProvider ¶
func (c *ApiController) DeleteProvider()
DeleteProvider @Title DeleteProvider @Tag Provider API @Description delete provider @Param body body object.Provider true "The details of the provider" @Success 200 {object} controllers.Response The Response object @router /delete-provider [post]
func (*ApiController) DeleteRecord ¶
func (c *ApiController) DeleteRecord()
DeleteRecord @Title DeleteRecord @Tag Record API @Description delete a record @Param body body object.Record true "The details of the record" @Success 200 {object} controllers.Response The Response object @router /delete-record [post]
func (*ApiController) DeleteScale ¶
func (c *ApiController) DeleteScale()
DeleteScale @router /delete-scale [post]
func (*ApiController) DeleteScan ¶
func (c *ApiController) DeleteScan()
DeleteScan @Title DeleteScan @Tag Scan API @Description delete a scan @Param body body object.Scan true "The details of the scan" @Success 200 {object} controllers.Response The Response object @router /delete-scan [post]
func (*ApiController) DeleteSession ¶
func (c *ApiController) DeleteSession()
DeleteSession @Title DeleteSession @Tag Session API @Description Delete session for one user in one application. @Param id query string true "The id(organization/application/user) of session" @Success 200 {array} string The Response object @router /delete-session [post]
func (*ApiController) DeleteStore ¶
func (c *ApiController) DeleteStore()
DeleteStore @Title DeleteStore @Tag Store API @Description delete store @Param body body object.Store true "The details of the store" @Success 200 {object} controllers.Response The Response object @router /delete-store [post]
func (*ApiController) DeleteTask ¶
func (c *ApiController) DeleteTask()
DeleteTask @Title DeleteTask @Tag Task API @Description delete task @Param body body object.Task true "The details of the task" @Success 200 {object} controllers.Response The Response object @router /delete-task [post]
func (*ApiController) DeleteTemplate ¶
func (c *ApiController) DeleteTemplate()
DeleteTemplate @Title DeleteTemplate @Tag Template API @Description delete template @Param body body object.Template true "The details of the template" @Success 200 {object} controllers.Response The Response object @router /delete-template [post]
func (*ApiController) DeleteTreeFile ¶
func (c *ApiController) DeleteTreeFile()
DeleteTreeFile @Title DeleteTreeFile @Tag Tree File API @Description delete tree file @Param store query string true "The store of the file" @Param key query string true "The key of the file" @Param isLeaf query string true "if is leaf" @Success 200 {object} controllers.Response The Response object @router /delete-tree-file [post]
func (*ApiController) DeleteVector ¶
func (c *ApiController) DeleteVector()
DeleteVector @Title DeleteVector @Tag Vector API @Description delete vector @Param body body object.Vector true "The details of the vector" @Success 200 {object} controllers.Response The Response object @router /delete-vector [post]
func (*ApiController) DeleteVideo ¶
func (c *ApiController) DeleteVideo()
DeleteVideo @Title DeleteVideo @Tag Video API @Description delete video @Param body body object.Video true "The details of the video" @Success 200 {object} controllers.Response The Response object @router /delete-video [post]
func (*ApiController) DeleteWelcomeMessage ¶
func (c *ApiController) DeleteWelcomeMessage()
func (*ApiController) DeleteWorkflow ¶
func (c *ApiController) DeleteWorkflow()
DeleteWorkflow @Title DeleteWorkflow @Tag Workflow API @Description delete workflow @Param body body object.Workflow true "The details of the workflow" @Success 200 {object} controllers.Response The Response object @router /delete-workflow [post]
func (*ApiController) DeployApplication ¶
func (c *ApiController) DeployApplication()
DeployApplication @Title DeployApplication @Tag Application API @Description deploy application synchronously @Param body body object.Application true "The details of the application" @Success 200 {object} controllers.Response The Response object @router /deploy-application [post]
func (*ApiController) DeployFinetuneJob ¶ added in v1.806.13
func (c *ApiController) DeployFinetuneJob()
DeployFinetuneJob serves a completed job's checkpoints and registers the result as a routable model on api.hanzo.ai. ?id= or ?name=
func (*ApiController) DevBridge ¶
func (c *ApiController) DevBridge()
DevBridge upgrades to WebSocket and bridges JSON-RPC messages between the browser and a hanzo-app-server instance.
In local mode (default): spawns hanzo-app-server as a child process. In remote mode (?remote=host:port): proxies to a remote app-server via TCP.
GET /api/dev-bridge?cwd=/path/to/project GET /api/dev-bridge?remote=host:port&cwd=/path/to/project
func (*ApiController) Embeddings ¶ added in v1.785.10
func (c *ApiController) Embeddings()
Embeddings implements POST /v1/embeddings (OpenAI-compatible).
Body: {"model": "...", "input": "..."|["...", ...], "encoding_format"?, "dimensions"?} It authenticates the caller, resolves the model to its upstream provider via the shared routing table, rewrites the user-facing model name to the upstream id, and proxies the request to the provider's /embeddings endpoint verbatim.
func (*ApiController) EnforceStoreIsolation ¶
func (c *ApiController) EnforceStoreIsolation(requestedStoreName string) (string, bool)
EnforceStoreIsolation enforces store isolation based on user's Homepage field. Returns the enforced store name and true if isolation check passes, or empty string and false if access denied.
func (*ApiController) ExportMyRoutingData ¶ added in v1.820.0
func (c *ApiController) ExportMyRoutingData()
ExportMyRoutingData streams the CALLER'S OWN org routing events as JSONL. Org- admin gated and SELF-SCOPED — the org is forced to c.GetOrg(), never a query or body value — so a customer exports only its own content-free ledger. This is the customer-facing data-ownership read that pairs with the training opt-in; the super-admin, any-org ExportRoutingLedger above is the platform operator's export.
@Title ExportMyRoutingData @Tag Router API @Description export the caller's own org routing events (content-free) as JSONL @router /export-my-routing-data [get]
func (*ApiController) Finish ¶
func (c *ApiController) Finish()
func (*ApiController) GenerateTextToSpeechAudio ¶
func (c *ApiController) GenerateTextToSpeechAudio()
GenerateTextToSpeechAudio @Title GenerateTextToSpeechAudio @Tag TTS API @Description convert text to speech @Param body controllers.TextToSpeechRequest true "The text to convert to speech" @Success 200 {object} []byte The audio data @router /generate-text-to-speech-audio [post]
func (*ApiController) GenerateTextToSpeechAudioStream ¶
func (c *ApiController) GenerateTextToSpeechAudioStream()
GenerateTextToSpeechAudioStream @Title GenerateTextToSpeechAudioStream @Tag TTS API @Description convert text to speech with streaming @Param storeId query string true "The store ID" @Param messageId query string true "The message ID" @Success 200 {stream} string "An event stream of audio chunks in base64 format" @router /generate-text-to-speech-audio-stream [get]
func (*ApiController) GetAIConnectionUsage ¶ added in v1.809.0
func (c *ApiController) GetAIConnectionUsage()
GetAIConnectionUsage imports the caller org's usage for a connected third-party account. The org is resolved from the VERIFIED principal (requireConnectionOrg), so a tenant reads only its own connection. The key is unsealed SERVER-SIDE and never returned. An unconnected account, a missing importer, or a scope-denied provider all return a 200 ProviderUsage with connected/available flags + a human note — the UI's honest-empty states — never a fabricated figure. @Title GetAIConnectionUsage @Tag AI Connections API @Description import a connected third-party AI account's usage (spend/tokens/requests/per-model/series) @Param provider path string true "provider slug (see GET /v1/ai/connections)" @Param from query string false "window start (RFC3339, YYYY-MM-DD, or unix seconds; default 30d ago)" @Param to query string false "window end (RFC3339, YYYY-MM-DD, or unix seconds; default now)" @Success 200 {object} controllers.ProviderUsage The Response object @router /ai/connections/:provider/usage [get]
func (*ApiController) GetAIConnections ¶ added in v1.803.0
func (c *ApiController) GetAIConnections()
GetAIConnections lists the org's connectable AI accounts and whether each is currently connected. Never returns a key or a kms:// reference. @Title GetAIConnections @Tag AI Connections API @Description list the org's connected third-party AI accounts (login manager) @Success 200 {array} controllers.aiConnResponse The Response object @router /ai/connections [get]
func (*ApiController) GetAcceptLanguage ¶
func (c *ApiController) GetAcceptLanguage() string
func (*ApiController) GetAccount ¶
func (c *ApiController) GetAccount()
GetAccount @Title GetAccount @Tag Account API @Description get account @Success 200 {object} iam.Claims The Response object @router /get-account [get]
func (*ApiController) GetActiveFile ¶
func (c *ApiController) GetActiveFile()
GetActiveFile @Title GetActiveFile @Tag File API @Description get active file @Param prefix query string true "The prefix of the file" @Success 200 {string} string "get active file" @router /get-active-file [get]
func (*ApiController) GetActivities ¶
func (c *ApiController) GetActivities()
GetActivities @Title GetActivities @Tag Activity API @Description get activities @Param days query string true "days count" @Success 200 {array} object.Activity The Response object @router /get-activities [get]
func (*ApiController) GetAdminProviders ¶ added in v1.790.5
func (c *ApiController) GetAdminProviders()
GetAdminProviders @Title GetAdminProviders @Tag Provider Admin API @Description List admin-owned Model providers as a clean management view
(enabled/primary/keyPresent/modelCount). Never returns secret material. Super-admin gated (see routers/authz_filter.go superAdminEndpoints).
@Success 200 {array} controllers.adminProviderView The Response object @router /admin/providers [get]
func (*ApiController) GetAgentsDashboardUrl ¶
func (c *ApiController) GetAgentsDashboardUrl()
GetAgentsDashboardUrl returns the URL of the Hanzo Agents control plane dashboard.
@Title GetAgentsDashboardUrl @Tag Agents API @Description get agents dashboard URL @Success 200 {object} Response The Response object @router /get-agents-dashboard-url [get]
func (*ApiController) GetAnswer ¶
func (c *ApiController) GetAnswer()
GetAnswer @Title GetAnswer @Tag Message API @Description get answer @Param provider query string true "The provider" @Param question query string true "The question of message" @Param framework query string true "The framework" @Param video query string true "The video" @Success 200 {string} string "answer message" @router /get-answer [get]
func (*ApiController) GetApplication ¶
func (c *ApiController) GetApplication()
GetApplication @Title GetApplication @Tag Application API @Description get application @Param id query string true "The id of application" @Success 200 {object} object.Application The Response object @router /get-application [get]
func (*ApiController) GetApplications ¶
func (c *ApiController) GetApplications()
GetApplications @Title GetApplications @Tag Application API @Description get applications @Param owner query string true "The owner of applications" @Success 200 {array} object.Application The Response object @router /get-applications [get]
func (*ApiController) GetArticle ¶
func (c *ApiController) GetArticle()
GetArticle @Title GetArticle @Tag Article API @Description get article @Param id query string true "The id (owner/name) of article" @Success 200 {object} object.Article The Response object @router /get-article [get]
func (*ApiController) GetArticles ¶
func (c *ApiController) GetArticles()
GetArticles @Title GetArticles @Tag Article API @Description get articles @Param owner query string true "The owner of article" @Success 200 {array} object.Article The Response object @router /get-articles [get]
func (*ApiController) GetAsset ¶
func (c *ApiController) GetAsset()
GetAsset @Title GetAsset @Tag Asset API @Description get asset @Param id query string true "The id ( owner/name ) of the asset" @Success 200 {object} object.Asset The Response object @router /get-asset [get]
func (*ApiController) GetAssets ¶
func (c *ApiController) GetAssets()
GetAssets @Title GetAssets @Tag Asset API @Description get all assets @Param pageSize query string false "The size of each page" @Param p query string false "The number of the page" @Success 200 {object} object.Asset The Response object @router /get-assets [get]
func (*ApiController) GetCaase ¶
func (c *ApiController) GetCaase()
GetCaase @Title GetCaase @Tag Caase API @Description get caase @Param id query string true "The id ( owner/name ) of the caase" @Success 200 {object} object.Caase The Response object @router /get-caase [get]
func (*ApiController) GetCaases ¶
func (c *ApiController) GetCaases()
GetCaases @Title GetCaases @Tag Caase API @Description get all caases @Param pageSize query string true "The size of each page" @Param p query string true "The number of the page" @Success 200 {object} object.Caase The Response object @router /get-caases [get]
func (*ApiController) GetChat ¶
func (c *ApiController) GetChat()
GetChat @Title GetChat @Tag Chat API @Description get chat @Param id query string true "The id of chat" @Success 200 {object} object.Chat The Response object @router /get-chat [get]
func (*ApiController) GetChats ¶
func (c *ApiController) GetChats()
GetChats @Title GetChats @Tag Chat API @Description get chats @Param user query string true "The user of chat" @Param field query string true "The field of chat" @Param value query string true "The value of chat" @Param startTime query string false "Filter by start time" @Param endTime query string false "Filter by end time" @Success 200 {array} object.Chat The Response object @router /get-chats [get]
func (*ApiController) GetCloudUsages ¶ added in v1.786.0
func (c *ApiController) GetCloudUsages()
GetCloudUsages @Title GetCloudUsages @Tag Usage API @Description Overview aggregation of the hanzo.cloud_usage ledger: totals + prior-period deltas, an evenly-spaced time series, spend-by-model (top-N + other), and the recent-activity feed, for a time range. @Param range query string false "24h | 7d | 30d | custom (default 24h)" @Param start query string false "custom range start (RFC3339 or unix seconds)" @Param end query string false "custom range end (RFC3339 or unix seconds)" @Param org query string false "super admin only: target org slug, 'all' for every org" @Param topModels query string false "spend-by-model top-N (default 6)" @Param activityType query string false "all | inference (default all)" @Param activityLimit query string false "recent-activity page size (default 20)" @Param activityOffset query string false "recent-activity page offset (default 0)" @Success 200 {object} object.CloudUsageOverview The Response object @router /get-cloud-usages [get]
Auth is session-OR-Bearer (c.RequirePrincipal): the console sends a session cookie, while the token-bearing surfaces (app / chat / billing, which drive the unified UsagePanel) send an IAM Bearer. Both resolve to the SAME principal, and the scope below is decided from THAT principal alone.
Scoping is the dual-use o11y read shared by tenant surfaces (own-org) and admin.hanzo.ai (god-view): a non-super-admin is pinned to their own org — request scope hints (X-Org-Id header, ?org=) are ignored, so a tenant can never read another org, no matter which auth it presents. A super admin targets one org via ?org=<slug> (or the X-Org-Id header console2 stamps), or omits it / passes ?org=all for the ALL-orgs view. The super-admin decision comes from the verified principal (util.IsSuperAdmin), never from a header or param.
func (*ApiController) GetConnection ¶
func (c *ApiController) GetConnection()
GetConnection @Title GetConnection @Tag Connection API @Description get connection @Param id query string true "The id of connection" @Success 200 {object} object.Connection @router /get-connection [get]
func (*ApiController) GetConnections ¶
func (c *ApiController) GetConnections()
GetConnections @Title GetConnections @Tag Connection API @Description get all connections @Param pageSize query string true "The size of each page" @Param p query string true "The number of the page" @Success 200 {object} object.Connection The Response object @router /get-connections [get]
func (*ApiController) GetConsultation ¶
func (c *ApiController) GetConsultation()
GetConsultation @Title GetConsultation @Tag Consultation API @Description get consultation @Param id query string true "The id ( owner/name ) of the consultation" @Success 200 {object} object.Consultation The Response object @router /get-consultation [get]
func (*ApiController) GetConsultations ¶
func (c *ApiController) GetConsultations()
GetConsultations @Title GetConsultations @Tag Consultation API @Description get all consultations @Param pageSize query string true "The size of each page" @Param p query string true "The number of the page" @Success 200 {object} object.Consultation The Response object @router /get-consultations [get]
func (*ApiController) GetDoctor ¶
func (c *ApiController) GetDoctor()
GetDoctor @Title GetDoctor @Tag Doctor API @Description get doctor @Param id query string true "The id ( owner/name ) of the doctor" @Success 200 {object} object.Doctor The Response object @router /get-doctor [get]
func (*ApiController) GetDoctors ¶
func (c *ApiController) GetDoctors()
GetDoctors @Title GetDoctors @Tag Doctor API @Description get all doctors @Param pageSize query string true "The size of each page" @Param p query string true "The number of the page" @Success 200 {object} object.Doctor The Response object @router /get-doctors [get]
func (*ApiController) GetFileMy ¶
func (c *ApiController) GetFileMy()
GetFileMy @Title GetFileMy @Tag File API @Description get file object @Param id query string true "The id (owner/name) of the file object" @Success 200 {object} object.File The Response object @router /get-file [get]
func (*ApiController) GetFiles ¶
func (c *ApiController) GetFiles()
GetFiles @Title GetFiles @Tag File API @Description get file objects @Param owner query string true "The owner of the file object" @Success 200 {array} object.File The Response object @router /get-files [get]
func (*ApiController) GetFinetuneJob ¶ added in v1.806.13
func (c *ApiController) GetFinetuneJob()
GetFinetuneJob returns one job with refreshed live status. ?id=owner/name or ?name=
func (*ApiController) GetFinetunePresets ¶ added in v1.806.13
func (c *ApiController) GetFinetunePresets()
GetFinetunePresets returns the new-job catalog plus, when a selection is passed (?baseModel&method&task&preset[&datasetExamples]), the recommended config so the console can render "Recommended" as a one-click, ready-to-run default.
func (*ApiController) GetForm ¶
func (c *ApiController) GetForm()
GetForm @Title GetForm @Tag Form API @Description get form @Param id query string true "The id (owner/name) of form" @Success 200 {object} object.Form The Response object @router /get-form [get]
func (*ApiController) GetFormData ¶
func (c *ApiController) GetFormData()
GetFormData @Title GetFormData @Tag Form API @Description get forms @Param owner query string true "The owner of form" @Success 200 {array} object.Form The Response object @router /get-form-data [get]
func (*ApiController) GetForms ¶
func (c *ApiController) GetForms()
GetForms @Title GetForms @Tag Form API @Description get forms @Param owner query string true "The owner of form" @Success 200 {array} object.Form The Response object @router /get-forms [get]
func (*ApiController) GetGlobalArticles ¶
func (c *ApiController) GetGlobalArticles()
GetGlobalArticles @Title GetGlobalArticles @Tag Article API @Description get global articles @Success 200 {array} object.Article The Response object @router /get-global-articles [get]
func (*ApiController) GetGlobalChats ¶
func (c *ApiController) GetGlobalChats()
GetGlobalChats @Title GetGlobalChats @Tag Chat API @Description get global chats @Success 200 {array} object.Chat The Response object @router /get-global-chats [get]
func (*ApiController) GetGlobalFiles ¶
func (c *ApiController) GetGlobalFiles()
GetGlobalFiles @Title GetGlobalFiles @Tag File API @Description get global file objects @Success 200 {array} object.File The Response object @router /get-global-files [get]
func (*ApiController) GetGlobalForms ¶
func (c *ApiController) GetGlobalForms()
GetGlobalForms @Title GetGlobalForms @Tag Form API @Description get global forms @Success 200 {array} object.Form The Response object @router /get-global-forms [get]
func (*ApiController) GetGlobalGraphs ¶
func (c *ApiController) GetGlobalGraphs()
GetGlobalGraphs @Title GetGlobalGraphs @Tag Graph API @Description get global graphs @Success 200 {array} object.Graph The Response object @router /get-global-graphs [get]
func (*ApiController) GetGlobalMessages ¶
func (c *ApiController) GetGlobalMessages()
GetGlobalMessages @Title GetGlobalMessages @Tag Message API @Description get global messages @Success 200 {array} object.Message The Response object @router /get-global-messages [get]
func (*ApiController) GetGlobalProviders ¶
func (c *ApiController) GetGlobalProviders()
GetGlobalProviders @Title GetGlobalProviders @Tag Provider API @Description get global providers @Success 200 {array} object.Provider The Response object @router /get-global-providers [get]
func (*ApiController) GetGlobalScales ¶
func (c *ApiController) GetGlobalScales()
GetGlobalScales @Title GetGlobalScales @Tag Scale API @Success 200 {array} object.Scale The Response object @router /get-global-scales [get]
func (*ApiController) GetGlobalStores ¶
func (c *ApiController) GetGlobalStores()
GetGlobalStores @Title GetGlobalStores @Tag Store API @Description get global stores @Success 200 {array} object.Store The Response object @router /get-global-stores [get]
func (*ApiController) GetGlobalTasks ¶
func (c *ApiController) GetGlobalTasks()
GetGlobalTasks @Title GetGlobalTasks @Tag Task API @Description get global tasks @Success 200 {array} object.Task The Response object @router /get-global-tasks [get]
func (*ApiController) GetGlobalVectors ¶
func (c *ApiController) GetGlobalVectors()
GetGlobalVectors @Title GetGlobalVectors @Tag Vector API @Description get global vectors @Success 200 {array} object.Vector The Response object @router /get-global-vectors [get]
func (*ApiController) GetGlobalVideos ¶
func (c *ApiController) GetGlobalVideos()
GetGlobalVideos @Title GetGlobalVideos @Tag Video API @Description get global videos @Success 200 {array} object.Video The Response object @router /get-global-videos [get]
func (*ApiController) GetGlobalWorkflows ¶
func (c *ApiController) GetGlobalWorkflows()
GetGlobalWorkflows @Title GetGlobalWorkflows @Tag Workflow API @Description get global workflows @Success 200 {array} object.Workflow The Response object @router /get-global-workflows [get]
func (*ApiController) GetGraph ¶
func (c *ApiController) GetGraph()
GetGraph @Title GetGraph @Tag Graph API @Description get Graph @Param id query string true "The id (owner/name) of Graph" @Success 200 {object} object.Graph The Response object @router /get-Graph [get]
func (*ApiController) GetGraphs ¶
func (c *ApiController) GetGraphs()
GetGraphs @Title GetGraphs @Tag Graph API @Description get graphs @Param owner query string true "The owner of Graph" @Success 200 {array} object.Graph The Response object @router /get-graphs [get]
func (*ApiController) GetHfRepo ¶ added in v1.806.13
func (c *ApiController) GetHfRepo()
GetHfRepo returns a repo's detail (files, gated/private state). ?id=&kind=model|dataset
func (*ApiController) GetHospital ¶
func (c *ApiController) GetHospital()
GetHospital @Title GetHospital @Tag Hospital API @Description get hospital @Param id query string true "The id ( owner/name ) of the hospital" @Success 200 {object} object.Hospital The Response object @router /get-hospital [get]
func (*ApiController) GetHospitals ¶
func (c *ApiController) GetHospitals()
GetHospitals @Title GetHospitals @Tag Hospital API @Description get all hospitals @Param pageSize query string true "The size of each page" @Param p query string true "The number of the page" @Success 200 {object} object.Hospital The Response object @router /get-hospitals [get]
func (*ApiController) GetK8sStatus ¶
func (c *ApiController) GetK8sStatus()
GetK8sStatus @Title GetK8sStatus @Tag Deployment API @Description get kubernetes cluster status @Success 200 {object} object.K8sStatus The Response object @router /get-k8s-status [get]
func (*ApiController) GetMessage ¶
func (c *ApiController) GetMessage()
GetMessage @Title GetMessage @Tag Message API @Description get message @Param id query string true "The id of message" @Success 200 {object} object.Message The Response object @router /get-message [get]
func (*ApiController) GetMessageAnswer ¶
func (c *ApiController) GetMessageAnswer()
GetMessageAnswer @Title GetMessageAnswer @Tag Message API @Description get message answer @Param id query string true "The id of message" @Success 200 {stream} string "An event stream of message answers in JSON format" @router /get-message-answer [get]
func (*ApiController) GetMessages ¶
func (c *ApiController) GetMessages()
GetMessages @Title GetMessages @Tag Message API @Description get Messages @Param user query string true "The user of message" @Param chat query string true "The chat of message" @Success 200 {array} object.Message The Response object @router /get-Messages [get]
func (*ApiController) GetMetrics ¶
func (c *ApiController) GetMetrics()
GetMetrics @Title GetMetrics @Tag System API @Description get Prometheus metrics @Success 200 {string} string The Response metrics in Prometheus format @router /metrics [get]
func (*ApiController) GetModelAccessStatus ¶ added in v1.809.2
func (c *ApiController) GetModelAccessStatus()
GetModelAccessStatus (GET /v1/models/:model/access) returns the caller's standing for a gated model ("granted" | "requested" | "" none).
func (*ApiController) GetModelRoute ¶
func (c *ApiController) GetModelRoute()
GetModelRoute @Title GetModelRoute @Tag ModelRoute API @Description get a specific model route @Param owner query string true "The owner (org)" @Param modelName query string true "The model name" @Success 200 {object} object.ModelRoute The Response object @router /get-model-route [get]
func (*ApiController) GetModelRoutes ¶
func (c *ApiController) GetModelRoutes()
GetModelRoutes @Title GetModelRoutes @Tag ModelRoute API @Description get model routes for an owner @Param owner query string true "The owner (org) of the model routes" @Success 200 {array} object.ModelRoute The Response object @router /get-model-routes [get]
func (*ApiController) GetNode ¶
func (c *ApiController) GetNode()
GetNode @Title GetNode @Tag Node API @Description get node @Param id query string true "The id ( owner/name ) of the node" @Success 200 {object} object.Node The Response object @router /get-node [get]
func (*ApiController) GetNodeTunnel ¶
func (c *ApiController) GetNodeTunnel()
GetNodeTunnel @Title GetNodeTunnel @Tag Connection API @Description get node tunnel session @Param width query string true "The width of the tunnel" @Param height query string true "The height of the tunnel" @Param dpi query string true "The dpi of the tunnel" @Param connectionId query string true "The id of the connectionId" @Param username query string true "The username for the tunnel" @Param password query string true "The password for the tunnel" @Success 200 {object} Response @router /get-node-tunnel [get]
func (*ApiController) GetNodes ¶
func (c *ApiController) GetNodes()
GetNodes @Title GetNodes @Tag Node API @Description get all nodes @Param pageSize query string true "The size of each page" @Param p query string true "The number of the page" @Success 200 {object} object.Node The Response object @router /get-nodes [get]
func (*ApiController) GetOrg ¶ added in v1.804.1
func (c *ApiController) GetOrg() string
GetOrg resolves the organization a request ACTS IN — data scoping, routing, pricing, usage reads, record attribution — from the VERIFIED request principal, never a raw client header.
X-Org-Id is honored when it names the principal's own org, an org the SIGNED `orgs` claim says the principal belongs to (the org switcher), or any org at all for a super admin (cross-tenant platform access). A non-member's request is silently answered with its home org: a spoofed header can never widen scope, and the refusal discloses nothing.
This is the SCOPE answer, not the MONEY answer. What a request SPENDS FROM is billingOrg, which differs for exactly one principal — a super admin acting inside a customer tenant scopes to the customer and spends its own ledger.
func (*ApiController) GetPatient ¶
func (c *ApiController) GetPatient()
GetPatient @Title GetPatient @Tag Patient API @Description get patient @Param id query string true "The id ( owner/name ) of the patient" @Success 200 {object} object.Patient The Response object @router /get-patient [get]
func (*ApiController) GetPatients ¶
func (c *ApiController) GetPatients()
GetPatients @Title GetPatients @Tag Patient API @Description get all patients @Param pageSize query string true "The size of each page" @Param p query string true "The number of the page" @Success 200 {object} object.Patient The Response object @router /get-patients [get]
func (*ApiController) GetPermission ¶
func (c *ApiController) GetPermission()
GetPermission @Title GetPermission @Tag Permission API @Description get permission @Param id query string true "The id(owner/name) of permission" @Success 200 {object} iam.Permission The Response object @router /get-permission [get]
func (*ApiController) GetPermissions ¶
func (c *ApiController) GetPermissions()
GetPermissions @Title GetPermissions @Tag Permission API @Description get permissions @Success 200 {array} iam.Permission The Response object @router /get-permissions [get]
func (*ApiController) GetPrometheusInfo ¶
func (c *ApiController) GetPrometheusInfo()
GetPrometheusInfo @Title GetPrometheusInfo @Tag System API @Description get Prometheus Info @Success 200 {object} object.PrometheusInfo The Response object @router /get-prometheus-info [get]
func (*ApiController) GetProvider ¶
func (c *ApiController) GetProvider()
GetProvider @Title GetProvider @Tag Provider API @Description get provider @Param id query string true "The id of provider" @Success 200 {object} object.Provider The Response object @router /get-provider [get]
func (*ApiController) GetProviderFlags ¶ added in v1.790.5
func (c *ApiController) GetProviderFlags()
GetProviderFlags @Title GetProviderFlags @Tag Provider API @Description Public, secret-free list of enabled Model provider NAMES. Used by
the pricing catalog sync to gate which providers' models are published (replaces the standalone ENABLE_OPENROUTER env — one control). Safe to be unauthenticated: no keys, URLs, or config are returned.
@Success 200 {object} controllers.providerFlags The Response object @router /provider-flags [get]
func (*ApiController) GetProviders ¶
func (c *ApiController) GetProviders()
GetProviders @Title GetProviders @Tag Provider API @Description get providers @Success 200 {array} object.Provider The Response object @router /get-providers [get]
func (*ApiController) GetPublicScales ¶
func (c *ApiController) GetPublicScales()
GetPublicScales @Title GetPublicScales @Tag Scale API @Success 200 {array} object.Scale The Response object @router /get-public-scales [get]
func (*ApiController) GetRangeUsages ¶
func (c *ApiController) GetRangeUsages()
GetRangeUsages @Title GetRangeUsages @Tag Usage API @Description get range usages @Param count query string true "count of range usages" @Success 200 {array} object.Usage The Response object @router /get-range-usages [get]
func (*ApiController) GetRecord ¶
func (c *ApiController) GetRecord()
GetRecord @Title GetRecord @Tag Record API @Description get record @Param id query string true "The id ( owner/name ) of the record" @Success 200 {object} object.Record The Response object @router /get-record [get]
func (*ApiController) GetRecords ¶
func (c *ApiController) GetRecords()
GetRecords @Title GetRecords @Tag Record API @Description get all records @Param pageSize query string true "The size of each page" @Param p query string true "The number of the page" @Success 200 {object} object.Record The Response object @router /get-records [get]
func (*ApiController) GetRequestTenantOrgID ¶
func (c *ApiController) GetRequestTenantOrgID() string
func (*ApiController) GetRequestTenantProjectID ¶
func (c *ApiController) GetRequestTenantProjectID() string
func (*ApiController) GetRouterHistory ¶ added in v1.818.0
func (c *ApiController) GetRouterHistory()
GetRouterHistory returns the router-improvement time-series. Two scopes, one route, mirroring /v1/router/stats:
- ?scope=platform — PUBLIC-safe aggregate over ALL orgs, no authentication. Emits the daily reward/cost-saved/adoption series (task mix included, model ids NOT) and the retrain timeline. This is what world.hanzo.ai polls.
- default (org scope) — requires a signed-in principal, scoped to the caller's OWN org (a super admin may pass ?org= to target another or "" for all).
Window: ?days=N (default 30, capped at 90). Aggregates only.
@Title GetRouterHistory @Tag Router API @Description router improvement time-series (reward + cost-saved + adoption over time, retrain markers); scope=platform is public-safe @Param scope query string false "'platform' for the public aggregate; omit for the caller's org" @Param days query int false "window size in days (default 30, max 90)" @Param org query string false "super-admin only: target org (” = all orgs)" @Success 200 {object} controllers.routerHistory The Response object @router /router/history [get]
func (*ApiController) GetRouterJudgePanel ¶ added in v1.826.5
func (c *ApiController) GetRouterJudgePanel()
GetRouterJudgePanel returns the LIVE Mean-Field Judge Panel state: the configured panel + dynamic judge posture (enabled/sample) resolved from the "*" GlobalDefaultOwner row, the live in-process per-judge calibration (weight/mean/n), and the static published benchmark. PUBLIC-safe and platform-global (model ids + scalars only), so it rides the same unauthenticated, balance-exempt class as /v1/router/stats?scope=platform — the world widget polls it with no auth. The judge state is a single in-process population (not per-org), so there is nothing to scope; ?scope=platform is accepted for symmetry with router-stats.
@Title GetRouterJudgePanel @Tag Router API @Description live Mean-Field Judge Panel state (public, platform-global; model ids + scalars only) @Param scope query string false "'platform' (default) — the public panel snapshot" @Success 200 {object} controllers.judgePanelState The Response object @router /router/judge-panel [get]
func (*ApiController) GetRouterStats ¶ added in v1.811.0
func (c *ApiController) GetRouterStats()
GetRouterStats returns the router observability aggregate. Two scopes, one route:
- ?scope=platform — PUBLIC-safe aggregate over ALL orgs, no authentication. Emits rates, shares, per-task/per-model counts, throughput, and the cost RATIO (saved_pct) + counterfactual model id, but NEVER absolute $ levels, org identity, raw events, or feature vectors. This is what world.hanzo.ai polls.
- default (org scope) — requires a signed-in principal; scoped to the caller's OWN org (a super admin may pass ?org= to target another org or "" for all). Carries the absolute $/MTok indices for the admin savings panel.
Window: ?since= (RFC3339) or ?hours= (default 24, capped). Aggregates only.
@Title GetRouterStats @Tag Router API @Description router savings-vs-performance aggregate (scope=platform is public-safe; default is org-scoped) @Param scope query string false "'platform' for the public aggregate; omit for the caller's org" @Param org query string false "super-admin only: target org (” = all orgs)" @Param hours query int false "window size in hours (default 24)" @Param since query string false "window start (RFC3339); overrides hours" @Success 200 {object} controllers.routerStats The Response object @router /router/stats [get]
func (*ApiController) GetScale ¶
func (c *ApiController) GetScale()
GetScale @router /get-scale [get]
func (*ApiController) GetScales ¶
func (c *ApiController) GetScales()
GetScales @Title GetScales @Tag Scale API @router /get-scales [get]
func (*ApiController) GetScan ¶
func (c *ApiController) GetScan()
GetScan @Title GetScan @Tag Scan API @Description get scan @Param id query string true "The id ( owner/name ) of the scan" @Success 200 {object} object.Scan The Response object @router /get-scan [get]
func (*ApiController) GetScans ¶
func (c *ApiController) GetScans()
GetScans @Title GetScans @Tag Scan API @Description get all scans @Param pageSize query string false "The size of each page" @Param p query string false "The number of the page" @Param asset query string false "Filter by asset name" @Success 200 {object} object.Scan The Response object @router /get-scans [get]
func (*ApiController) GetScopedOwner ¶
func (c *ApiController) GetScopedOwner() (string, bool)
GetScopedOwner resolves owner from the authenticated session. Non-admin users are always scoped to their own org, ignoring request owner params. Super admins can optionally target a specific owner via query parameter.
func (*ApiController) GetSessionClaims ¶
func (c *ApiController) GetSessionClaims() *iam.Claims
func (*ApiController) GetSessionOwner ¶
func (c *ApiController) GetSessionOwner() string
GetSessionOwner returns the organization (owner) of the authenticated user. This ensures multi-tenant resource scoping — users only see their own org's resources.
func (*ApiController) GetSessionUser ¶
func (c *ApiController) GetSessionUser() *iam.User
func (*ApiController) GetSessionUsername ¶
func (c *ApiController) GetSessionUsername() string
func (*ApiController) GetSessions ¶
func (c *ApiController) GetSessions()
GetSessions @Title GetSessions @Tag Session API @Description Get organization user sessions. @Param owner query string true "The organization name" @Success 200 {array} string The Response object @router /get-sessions [get]
func (*ApiController) GetSingleSession ¶
func (c *ApiController) GetSingleSession()
GetSingleSession @Title GetSingleSession @Tag Session API @Description Get session for one user in one application. @Param id query string true "The id(organization/user) of session" @Success 200 {array} string The Response object @router /get-session [get]
func (*ApiController) GetStorageProviders ¶
func (c *ApiController) GetStorageProviders()
GetStorageProviders @Title GetStorageProviders @Tag Storage Provider API @Description get storage providers @Success 200 {array} object.Provider The Response object @router /get-storage-providers [get]
func (*ApiController) GetStore ¶
func (c *ApiController) GetStore()
GetStore @Title GetStore @Tag Store API @Description get store @Param id query string true "The id (owner/name) of the store" @Success 200 {object} object.Store The Response object @router /get-store [get]
func (*ApiController) GetStoreNames ¶
func (c *ApiController) GetStoreNames()
GetStoreNames ... @Title GetStoreNames @Tag Store API @Param owner query string true "owner" @Description get all store name and displayName @Success 200 {array} object.Store The Response object @router /get-store-names [get]
func (*ApiController) GetStores ¶
func (c *ApiController) GetStores()
GetStores @Title GetStores @Tag Store API @Description get stores @Param owner query string true "The owner of the store" @Success 200 {array} object.Store The Response object @router /get-stores [get]
func (*ApiController) GetSystemInfo ¶
func (c *ApiController) GetSystemInfo()
GetSystemInfo @Title GetSystemInfo @Tag System API @Description get system info like CPU and memory usage @Success 200 {object} util.SystemInfo The Response object @router /get-system-info [get]
func (*ApiController) GetTask ¶
func (c *ApiController) GetTask()
GetTask @Title GetTask @Tag Task API @Description get task @Param id query string true "The id (owner/name) of task" @Success 200 {object} object.Task The Response object @router /get-task [get]
func (*ApiController) GetTasks ¶
func (c *ApiController) GetTasks()
GetTasks @Title GetTasks @Tag Task API @Description get tasks @Param owner query string true "The owner of task" @Success 200 {array} object.Task The Response object @router /get-tasks [get]
func (*ApiController) GetTemplate ¶
func (c *ApiController) GetTemplate()
GetTemplate @Title GetTemplate @Tag Template API @Description get template @Param id query string true "The id of template" @Success 200 {object} object.Template The Response object @router /get-template [get]
func (*ApiController) GetTemplates ¶
func (c *ApiController) GetTemplates()
GetTemplates @Title GetTemplates @Tag Template API @Description get templates @Param owner query string true "The owner of templates" @Success 200 {array} object.Template The Response object @router /get-templates [get]
func (*ApiController) GetTrafficGlobe ¶ added in v1.817.0
func (c *ApiController) GetTrafficGlobe()
GetTrafficGlobe returns the PUBLIC live request-geo aggregate for the world.hanzo.ai "Hanzo mode" globe: WHERE requests to api.hanzo.ai are coming from, as country/region points with per-service-class counts, plus headline throughput rates.
It is AUTH-exempt and BALANCE-exempt exactly like /v1/router/stats?scope=platform:
- auth: the controller name "traffic/globe" is neither a get-/update- CRUD name nor a super-admin/present-credential endpoint, so the authz filter passes it through, and this handler requires no principal.
- balance: isBalanceExempt("/v1/traffic/...") returns true.
It exposes ONLY aggregates — counts, rates, and country/region centroids — and NEVER any IP, per-request row, org, or user dimension (see object/traffic.go). Marketing telemetry; nothing sensitive.
@Title GetTrafficGlobe @Tag Traffic API @Description public live request-geo aggregate (country/region points + throughput totals); aggregates only, no IPs, no auth @Param window query int false "window size in minutes (default 60, capped at 1440)" @Success 200 {object} object.TrafficGlobe The Response object @router /traffic/globe [get]
func (*ApiController) GetTrainingContribution ¶ added in v1.811.0
func (c *ApiController) GetTrainingContribution()
GetTrainingContribution returns the caller's OWN org training-contribution opt-in (org > unset). Self-scoped via GetOrg — a customer reads only their OWN org's setting. Uses RequirePrincipal (session cookie OR verified Bearer JWT), NOT the session-only RequireAdmin, so this consent read serves BOTH the console (cookie) and the token-bearing account surfaces (Hanzo World carries an IAM Bearer, not the console cookie) with the SAME resolved identity. Unset reads as false — the privacy-safe default OFF.
@Title GetTrainingContribution @Tag Router API @Description get the caller's org training-data contribution opt-in @Success 200 {object} controllers.trainingContributionBody The Response object @router /get-training-contribution [get]
func (*ApiController) GetUsages ¶
func (c *ApiController) GetUsages()
GetUsages @Title GetUsages @Tag Usage API @Description get usages @Param days query string true "days count" @Success 200 {array} object.Usage The Response object @router /get-usages [get]
func (*ApiController) GetUserTableInfos ¶
func (c *ApiController) GetUserTableInfos()
GetUserTableInfos @Title GetUserTableInfos @Tag Usage API @Description get userTableInfos @Success 200 {array} object.Usage The Response object @router /get-usages [get]
func (*ApiController) GetUsers ¶
func (c *ApiController) GetUsers()
GetUsers @Title GetUsers @Tag Usage API @Description get users @Success 200 {array} string The Response object @router /get-users [get]
func (*ApiController) GetVector ¶
func (c *ApiController) GetVector()
func (*ApiController) GetVectors ¶
func (c *ApiController) GetVectors()
GetVectors @Title GetVectors @Tag Vector API @Description get vectors @Success 200 {array} object.Vector The Response object @router /get-vectors [get]
func (*ApiController) GetVersionInfo ¶
func (c *ApiController) GetVersionInfo()
GetVersionInfo @Title GetVersionInfo @Tag System API @Description get version info like IAM release version and commit ID @Success 200 {object} util.VersionInfo The Response object @router /get-version-info [get]
func (*ApiController) GetVideo ¶
func (c *ApiController) GetVideo()
GetVideo @Title GetVideo @Tag Video API @Description get video @Param id query string true "The id of video" @Success 200 {object} object.Video The Response object @router /get-video [get]
func (*ApiController) GetVideos ¶
func (c *ApiController) GetVideos()
GetVideos @Title GetVideos @Tag Video API @Description get videos @Param owner query string true "The owner of videos" @Success 200 {array} object.Video The Response object @router /get-videos [get]
func (*ApiController) GetVmDashboardUrl ¶
func (c *ApiController) GetVmDashboardUrl()
GetVmDashboardUrl returns the URL of the Hanzo VM control plane dashboard.
@Title GetVmDashboardUrl @Tag VM API @Description get VM dashboard URL @Success 200 {object} Response The Response object @router /get-vm-dashboard-url [get]
func (*ApiController) GetWorkflow ¶
func (c *ApiController) GetWorkflow()
GetWorkflow @Title GetWorkflow @Tag Workflow API @Description get workflow @Param id query string true "The id (owner/name) of workflow" @Success 200 {object} object.Workflow The Response object @router /get-workflow [get]
func (*ApiController) GetWorkflows ¶
func (c *ApiController) GetWorkflows()
GetWorkflows @Title GetWorkflows @Tag Workflow API @Description get workflows @Param owner query string true "The owner of workflow" @Success 200 {array} object.Workflow The Response object @router /get-workflows [get]
func (*ApiController) Health ¶
func (c *ApiController) Health()
Health @Title Health @Tag System API @Description check if the system is live @Success 200 {object} controllers.Response The Response object @router /health [get]
func (*ApiController) ImagesGenerations ¶ added in v1.790.1
func (c *ApiController) ImagesGenerations()
ImagesGenerations implements POST /v1/images/generations (OpenAI-compatible).
Body: {"model": "...", "prompt": "...", "n"?: int, "size"?: "1024x1024",
"response_format"?: "url"|"b64_json"}
It authenticates the caller, resolves the model to its upstream provider via the shared routing table (zen3-image* → do-ai fal diffusion), reserves the per-image budget, generates the image(s) through the do-ai async image client, records usage for billing, and returns the OpenAI images response. @Title ImagesGenerations @Tag OpenAI Compatible API @Description OpenAI compatible image generations API. @router /images/generations [post]
func (*ApiController) IndexDocs ¶
func (c *ApiController) IndexDocs()
IndexDocs @Title IndexDocs @Tag Search Docs API @Description index documentation into Meilisearch and Qdrant @Param body body object.DocIndexRequest true "Index request" @Success 200 {object} controllers.Response The Response object @router /index [post]
func (*ApiController) IngestDocs ¶ added in v1.786.0
func (c *ApiController) IngestDocs()
IngestDocs @Title IngestDocs @Tag Docs Ingest API @Description Unified RAG ingest: parse + chunk + embed documents and pipe them
to BOTH Hanzo Vector (semantic) AND Hanzo Search (keyword) under the tenant
index {owner}-{store}-docs — the same index /v1/chat retrieval reads. The
source is pluggable: "upload" (inline files/documents), "github" (index a
repo), "crawl" (web), or "s3" (the store's object-storage space). The owner
is bound to the authenticated principal; the client-supplied owner is never
trusted.
@Param body body object.IngestRequest true "Ingest request" @Success 200 {object} object.IngestStats "Ingest statistics" @router /docs/ingest [post]
func (*ApiController) InstallPatch ¶
func (c *ApiController) InstallPatch()
InstallPatch @Title InstallPatch @Tag Patch API @Description install an OS patch by patch ID (KB number or title) asynchronously @Param provider query string true "The provider ID (owner/name)" @Param patchId query string true "The patch ID (KB number or title)" @Param scan query string true "The scan ID (owner/name) for async execution" @Success 200 {object} controllers.Response The Response object @router /install-patch [post]
func (*ApiController) IsAdmin ¶
func (c *ApiController) IsAdmin() bool
func (*ApiController) IsCurrentUser ¶
func (c *ApiController) IsCurrentUser(usernameInput string) bool
func (*ApiController) IsPreviewMode ¶
func (c *ApiController) IsPreviewMode() bool
func (*ApiController) IsSessionDuplicated ¶
func (c *ApiController) IsSessionDuplicated()
IsSessionDuplicated @Title IsSessionDuplicated @Tag Session API @Description Check if there are other different sessions for one user in one application. @Param id query string true "The id(organization/application/user) of session" @Param sessionId query string true "sessionId to be checked" @Success 200 {array} string The Response object @router /is-session-duplicated [get]
func (*ApiController) ListFinetuneJobs ¶ added in v1.806.13
func (c *ApiController) ListFinetuneJobs()
ListFinetuneJobs returns the org's jobs, refreshing live status for active ones.
func (*ApiController) ListModels ¶
func (c *ApiController) ListModels()
ListModels returns the list of available models from the routing table. Requires a valid Bearer token (JWT, hk-, pk-, sk-, or hz_ key). @Title ListModels @Tag OpenAI Compatible API @Description Returns a list of all available models. Requires authentication. @Param Authorization header string true "Bearer token" @Success 200 {object} object @Failure 401 {object} object "Unauthorized" @router /models [get]
func (*ApiController) MemoryDelete ¶ added in v1.785.11
func (c *ApiController) MemoryDelete()
MemoryDelete @Title MemoryDelete @Tag Memory API @Description delete one of the authenticated user's memories @Param body body controllers.memoryRequest true "id/name to delete" @Success 200 {object} controllers.Response The Response object @router /memory/delete [post]
func (*ApiController) MemoryFacts ¶ added in v1.785.11
func (c *ApiController) MemoryFacts()
MemoryFacts @Title MemoryFacts @Tag Memory API @Description list the authenticated user's stored facts @Param limit query string false "max results" @Success 200 {array} object.Memory The Response object @router /memory/facts [get]
func (*ApiController) MemoryList ¶ added in v1.785.11
func (c *ApiController) MemoryList()
MemoryList @Title MemoryList @Tag Memory API @Description list the authenticated user's memories, newest first @Param kind query string false "filter by kind" @Param limit query string false "max results" @Success 200 {array} object.Memory The Response object @router /memory/list [get]
func (*ApiController) MemoryRecall ¶ added in v1.785.11
func (c *ApiController) MemoryRecall()
MemoryRecall @Title MemoryRecall @Tag Memory API @Description recall recent/relevant memories for context injection; with q it @Description ranks semantically, without q it returns the most recent @Param q query string false "optional relevance query" @Param kind query string false "filter by kind" @Param limit query string false "max results" @Success 200 {array} object.Memory The Response object @router /memory/recall [get]
func (*ApiController) MemoryRemember ¶ added in v1.785.11
func (c *ApiController) MemoryRemember()
MemoryRemember @Title MemoryRemember @Tag Memory API @Description store a memory for the authenticated user @Param body body controllers.memoryRequest true "content, kind, metadata" @Success 200 {object} object.Memory The Response object @router /memory/remember [post]
func (*ApiController) MemorySearch ¶ added in v1.785.11
func (c *ApiController) MemorySearch()
MemorySearch @Title MemorySearch @Tag Memory API @Description search the authenticated user's memories (semantic, text fallback) @Param q query string true "search query" @Param kind query string false "filter by kind" @Param limit query string false "max results" @Success 200 {array} object.Memory The Response object @router /memory/search [get]
func (*ApiController) MemoryUpdate ¶ added in v1.785.11
func (c *ApiController) MemoryUpdate()
MemoryUpdate @Title MemoryUpdate @Tag Memory API @Description update one of the authenticated user's memories @Param body body controllers.memoryRequest true "id/name + fields to change" @Success 200 {object} controllers.Response The Response object @router /memory/update [post]
func (*ApiController) PostBackfillDOUsage ¶ added in v1.813.0
func (c *ApiController) PostBackfillDOUsage()
PostBackfillDOUsage @Title PostBackfillDOUsage @Tag Usage API @Description Super-admin: backfill the hanzo.cloud_usage ledger from DigitalOcean's billing API for (day) windows our native metering missed — GAPS ONLY (never double-counts a natively-metered day), PROVENANCE-tagged (source="do-backfill"), and IDEMPOTENT (re-running is a no-op). DRY-RUN by default: returns the rows/days/ totals it WOULD write and persists nothing unless dryRun=false is passed explicitly. @Param from query string false "window start (RFC3339, YYYY-MM-DD, or unix seconds; default 365d ago)" @Param to query string false "window end (RFC3339, YYYY-MM-DD, or unix seconds; default now)" @Param dryRun query string false "false to persist; anything else (default) plans only" @Param force query string false "true to import even days native metering already covers" @Success 200 {object} controllers.DOBackfillPlan The Response object @router /admin/usage/backfill-do [post]
func (*ApiController) ProcessSpeechToText ¶
func (c *ApiController) ProcessSpeechToText()
ProcessSpeechToText @Title ProcessSpeechToText @Tag STT API @Description convert speech to text @Param audio formData file true "The audio file to convert to text" @Param storeId formData string true "The store ID" @Success 200 {object} controllers.SpeechToTextResponse The transcribed text @router /process-speech-to-text [post]
func (*ApiController) QueryRecord ¶
func (c *ApiController) QueryRecord()
QueryRecord @Title QueryRecord @Tag Record API @Description query record @Param id query string true "The id ( owner/name ) of the record" @Success 200 {object} object.Record The Response object @router /query-record [get]
func (*ApiController) QueryRecordSecond ¶
func (c *ApiController) QueryRecordSecond()
QueryRecordSecond @Title QueryRecordSecond @Tag Record API @Description query record @Param id query string true "The id ( owner/name ) of the record" @Success 200 {object} object.Record The Response object @router /query-record-second [get]
func (*ApiController) RagContext ¶ added in v1.790.2
func (c *ApiController) RagContext()
RagContext @Title RagContext @Tag RAG API @Description Return every stored chunk of one file_id (full document context).
Consolidates the retired chat-rag-api GET /documents/{id}/context.
@Param file_id query string true "The file_id" @Param store query string false "Store slug (default rag-files)" @Success 200 {array} object.DocSearchResult "All chunks of the file" @router /rag/context [get]
func (*ApiController) RagDelete ¶ added in v1.790.2
func (c *ApiController) RagDelete()
RagDelete @Title RagDelete @Tag RAG API @Description Delete all chunks of one or more uploaded files (by file_id) from
the owner's Search+Vector index. Consolidates the retired chat-rag-api DELETE /documents.
@Param body body controllers.ragDeleteBody true "Delete request" @Success 200 {object} controllers.Response The Response object @router /rag/delete [post]
func (*ApiController) RagDeleteDocuments ¶ added in v1.790.2
func (c *ApiController) RagDeleteDocuments()
RagDeleteDocuments handles DELETE /v1/documents — a JSON array of file_ids.
@Title RagDeleteDocuments @Tag RAG API (LibreChat-compat) @Description Delete files by id (drop-in for the retired rag-api DELETE /documents). @router /documents [delete]
func (*ApiController) RagDocumentContext ¶ added in v1.790.2
func (c *ApiController) RagDocumentContext()
RagDocumentContext handles GET /v1/documents/:file_id/context — every chunk of a file, as LangChain Documents (used when RAG_USE_FULL_CONTEXT is on).
@Title RagDocumentContext @Tag RAG API (LibreChat-compat) @Description Full file context (drop-in for rag-api GET /documents/{id}/context). @router /documents/:file_id/context [get]
func (*ApiController) RagEmbed ¶ added in v1.790.2
func (c *ApiController) RagEmbed()
RagEmbed @Title RagEmbed @Tag RAG API @Description Parse, chunk, and embed one uploaded file under its file_id into
the unified Search+Vector index, scoped to the authenticated owner. Provide inline `content` or a `url` to fetch+parse (PDF/CSV/XLSX/PPTX/…). Re-embedding the same file_id replaces its chunks. Consolidates the retired chat-rag-api POST /embed and /local/embed.
@Param body body object.RagEmbedRequest true "Embed request" @Success 200 {object} object.RagEmbedResult "Embed result" @router /rag/embed [post]
func (*ApiController) RagEmbedMultipart ¶ added in v1.790.2
func (c *ApiController) RagEmbedMultipart()
RagEmbedMultipart handles POST /v1/embed — the multipart upload hanzo.chat's uploadVectors() sends. It saves the upload to a temp file, then reuses object.RagEmbedFile (same parse+chunk+index as the native surface).
@Title RagEmbedMultipart @Tag RAG API (LibreChat-compat) @Description Multipart file embed (drop-in for the retired rag-api POST /embed). @router /embed [post]
func (*ApiController) RagQuery ¶ added in v1.790.2
func (c *ApiController) RagQuery()
RagQuery @Title RagQuery @Tag RAG API @Description Retrieve the top-K chunks relevant to a query, scoped to a single
uploaded file (`file_id`). Hybrid keyword+vector retrieval over the same index. Consolidates the retired chat-rag-api POST /query.
@Param body body object.RagQueryRequest true "Query request" @Success 200 {array} object.DocSearchResult "Matching chunks" @router /rag/query [post]
func (*ApiController) RagQueryCompat ¶ added in v1.790.2
func (c *ApiController) RagQueryCompat()
RagQueryCompat handles POST /v1/query — {file_id,query,k}. Returns LangChain (document,score) tuples.
@Title RagQueryCompat @Tag RAG API (LibreChat-compat) @Description File-scoped query (drop-in for the retired rag-api POST /query). @router /query [post]
func (*ApiController) RagQueryMultiple ¶ added in v1.790.2
func (c *ApiController) RagQueryMultiple()
RagQueryMultiple @Title RagQueryMultiple @Tag RAG API @Description Retrieve the top-K chunks relevant to a query, scoped to a SET of
uploaded files (`file_ids`). Consolidates the retired chat-rag-api POST /query_multiple. Shares one retrieval path with /rag/query.
@Param body body object.RagQueryRequest true "Query request" @Success 200 {array} object.DocSearchResult "Matching chunks" @router /rag/query-multiple [post]
func (*ApiController) RagQueryMultipleCompat ¶ added in v1.790.2
func (c *ApiController) RagQueryMultipleCompat()
RagQueryMultipleCompat handles POST /v1/query_multiple — {file_ids,query,k}.
@Title RagQueryMultipleCompat @Tag RAG API (LibreChat-compat) @Description Multi-file query (drop-in for the retired rag-api POST /query_multiple). @router /query_multiple [post]
func (*ApiController) RefreshFileVectors ¶
func (c *ApiController) RefreshFileVectors()
RefreshFileVectors @Title RefreshFileVectors @Tag File API @Description refresh file vectors @Param body body object.File true "The details of the file object" @Success 200 {object} controllers.Response The Response object @router /refresh-file-vectors [post]
func (*ApiController) RefreshMcpTools ¶
func (c *ApiController) RefreshMcpTools()
RefreshMcpTools @Title RefreshMcpTools @Tag Provider API @Description refresh Mcp tools @Param body body object.Provider true "The details of the provider" @Success 200 {object} controllers.Response The Response object @router /refresh-mcp-tools [post]
func (*ApiController) RefreshModelPricing ¶ added in v1.801.0
func (c *ApiController) RefreshModelPricing()
RefreshModelPricing handles POST /v1/admin/refresh-model-pricing. @Title RefreshModelPricing @Tag Admin @Description Force a live pricing refresh from the configured pricing service. @Success 200 {object} controllers.Response @router /admin/refresh-model-pricing [post]
func (*ApiController) RefreshStoreVectors ¶
func (c *ApiController) RefreshStoreVectors()
RefreshStoreVectors @Title RefreshStoreVectors @Tag Store API @Description refresh store vectors @Param body body object.Store true "The details of the store" @Success 200 {object} controllers.Response The Response object @router /refresh-store-vectors [post]
func (*ApiController) ReloadModelConfig ¶
func (c *ApiController) ReloadModelConfig()
ReloadModelConfig handles POST /api/reload-model-config. @Title ReloadModelConfig @Tag Admin @Description Reload model configuration from YAML and refresh live pricing. @Success 200 {object} controllers.Response @router /admin/reload-model-config [post]
func (*ApiController) RequestModelAccess ¶ added in v1.809.2
func (c *ApiController) RequestModelAccess()
RequestModelAccess (POST /v1/models/:model/access) records the caller's waitlist request for a gated model. Authed, idempotent, and self-scoped (the row is keyed to the caller's own org/identity — never a body-supplied owner). Returns the status.
func (*ApiController) RequireAdmin ¶
func (c *ApiController) RequireAdmin() bool
func (*ApiController) RequirePrincipal ¶ added in v1.807.1
func (c *ApiController) RequirePrincipal() (*iam.User, bool)
RequirePrincipal resolves the request principal from EITHER the browser session cookie OR a verified Bearer JWT (c.principalUser), returning a real 401 when neither is present. It is the Bearer-aware sibling of RequireSignedInUser: an endpoint that must serve BOTH the console (session cookie) and the token-bearing surfaces (app / chat / billing, which carry an IAM Bearer, not the console cookie) with the SAME resolved identity uses this. The Bearer branch is signature- AND issuer/audience-validated via object.ParseAndValidateJWT (never raw iam.ParseJwtToken), so a forged token cannot pose as anyone.
The returned user is the SOLE authority for any downstream org/role scope decision — the caller MUST derive scope from THIS user (its Owner, its role via util.IsSuperAdmin), NEVER from a request header or query param. That is what keeps a Bearer-reachable, org-scoped read tenant-safe.
func (*ApiController) RequireSessionOwner ¶
func (c *ApiController) RequireSessionOwner() (string, bool)
RequireSessionOwner ensures the caller is authenticated and returns their org owner. IAM headers are trusted when injected by the gateway, but session auth is primary here.
func (*ApiController) RequireSignedIn ¶
func (c *ApiController) RequireSignedIn() (string, bool)
func (*ApiController) RequireSignedInUser ¶
func (c *ApiController) RequireSignedInUser() (*iam.User, bool)
func (*ApiController) RequireSuperAdmin ¶ added in v1.804.0
func (c *ApiController) RequireSuperAdmin() bool
RequireSuperAdmin is the controller-level self-guard for platform-sensitive endpoints (provider-admin, upstream-key/topology config). It mirrors the authz filter's superAdminEndpoints gate EXACTLY — same principal (session or VERIFIED Bearer JWT via c.principalUser) and same policy (util.IsSuperAdmin) — so it is belt-AND-suspenders: even if the filter is ever bypassed (e.g. a path-normalization disagreement), the controller still refuses. Fail-closed: no principal → 401, authenticated non-super-admin → 403. Unlike RequireAdmin it is NOT relaxed by preview mode and checks GLOBAL (platform) admin, not org admin — these routes govern the primary provider that backs the whole model catalog.
func (*ApiController) Rerank ¶ added in v1.785.10
func (c *ApiController) Rerank()
Rerank implements POST /v1/rerank (Cohere/Jina-compatible).
Body: {"model": "...", "query": "...", "documents": ["...", ...]|[{"text":"..."}],
"top_n"?: int, "return_documents"?: bool}
Response: {"object":"list","model":...,"results":[{"index","relevance_score","document"?}],"usage":{...}}
Backend selection is provider-driven (one endpoint, one contract):
- If the model routes to a native rerank provider (Jina/Cohere/Voyage) the request is proxied to that provider's /rerank endpoint.
- Otherwise scores are computed as a real bi-encoder ranking: embed the query and documents through the resolved embedding model and rank by cosine similarity. No rerank-specific key required.
func (*ApiController) ResponseAudio ¶
func (c *ApiController) ResponseAudio(audioData []byte, contentType string, filename string)
func (*ApiController) ResponseAuthError ¶ added in v1.785.10
func (c *ApiController) ResponseAuthError(err error)
ResponseAuthError renders an error from the auth / routing path with its carried HTTP status (401 / 402 / 400 / 500). It never emits 200, so an invalid key, an empty balance, or a bad model is unambiguous to OpenAI-compatible clients. This is the ONE renderer for that surface (chat, embeddings, rerank).
func (*ApiController) ResponseError ¶
func (c *ApiController) ResponseError(error string, data ...interface{})
func (*ApiController) ResponseErrorStream ¶
func (c *ApiController) ResponseErrorStream(message *object.Message, errorText string)
func (*ApiController) ResponseErrorWithStatus ¶ added in v1.785.10
func (c *ApiController) ResponseErrorWithStatus(status int, error string, data ...interface{})
ResponseErrorWithStatus writes the standard error envelope with an explicit HTTP status code. Plain ResponseError emits HTTP 200, which is wrong for auth failures; the OpenAI-compatible /v1 handlers use this so a missing or invalid Bearer token returns 401, matching /v1/models. Beego's Output.Body honors a status set via SetStatus, so the body shape is unchanged.
func (*ApiController) ResponseForbidden ¶ added in v1.785.11
func (c *ApiController) ResponseForbidden(error string, data ...interface{})
ResponseForbidden renders an authorization denial (authenticated but not permitted) as a real HTTP 403 — never Beego's default 200. Same body shape.
func (*ApiController) ResponseOk ¶
func (c *ApiController) ResponseOk(data ...interface{})
func (*ApiController) ResponseUnauthorized ¶ added in v1.785.11
func (c *ApiController) ResponseUnauthorized(error string, data ...interface{})
ResponseUnauthorized renders an authentication denial (no/invalid session or credential) as a real HTTP 401 — never Beego's default 200. Same body shape.
func (*ApiController) Responses ¶ added in v1.806.15
func (c *ApiController) Responses()
Responses implements POST /v1/responses. The converted request is passed to ChatCompletions and an installed ResponseWriter converts its OpenAI chat JSON or SSE back into Responses JSON/SSE on the fly.
func (*ApiController) RetrieveVideo ¶ added in v1.800.0
func (c *ApiController) RetrieveVideo()
RetrieveVideo implements GET /v1/videos/{id} — poll a job's status.
It authenticates the caller, verifies they OWN the job (the caller's billing subject must equal the job's), performs ONE upstream status poll, and — the first time the job is observed completed — settles the reservation with the actual cost and records the billable usage event (exactly once). Returns the OpenAI-shaped video object.
@Title RetrieveVideo @Tag OpenAI Compatible API @Description Retrieve the status of an async video generation job. @router /videos/:id [get]
func (*ApiController) RouterConfigBridge ¶ added in v1.829.6
func (c *ApiController) RouterConfigBridge()
RouterConfigBridge is the HTTP transport binding for the RESTful router-config nouns (/v1/router/{policy,defaults,ledger,rewards,artifact-meta} and /v1/org/settings[/list]). It dispatches IN-PROCESS through dispatchGateway — the SAME canonical ZAP gateway registry (zap_registry.go) that handleGatewayHTTPRequest serves over the gateway transport. The native ZAP handler is the ONE and ONLY implementation of these routes; this is purely the api.hanzo.ai HTTP binding, so there is NO beego twin to drift from and the split-brain the router refactor removed stays removed.
Why a bridge and not a twin controller method: every other migrated route (get-records, get-connections, …) carries BOTH a beego controller method and a ZAP handler — the exact dual-impl drift that silently NULLed customer router settings (the update-router-policy data-wipe). Routing these nouns through the ZAP handler over one adapter keeps a single source of truth.
Identity is the request's own Bearer credential (Authorization header), which the native handlers resolve exactly as the gateway does — every caller (console, chat, app) already sends it. The dispatched handler returns a ZAP message whose status is field 0 and body is field 4 (BuildCloudResponse / BuildGatewayResponse layout); both are relayed verbatim. The route is mapped "*" (any verb) because the native handler is method-aware: /v1/router/policy splits GET (read) vs PUT (write), /v1/org/settings GET/PUT/DELETE, and returns 405 for a verb it does not own.
func (*ApiController) ScanAsset ¶
func (c *ApiController) ScanAsset()
ScanAsset @Title ScanAsset @Tag Asset API @Description unified API for scanning assets (combines test-scan and start-scan functionality) @Param provider query string true "The provider ID (owner/name)" @Param scan query string false "The scan ID (owner/name) for saving results" @Param targetMode query string true "Target mode: 'Manual Input' or 'Asset'" @Param target query string false "Manual input target (IP address or network range)" @Param asset query string false "Asset ID (owner/name) for Asset mode" @Param command query string false "Scan command with optional %s placeholder for target" @Param saveToScan query string false "Whether to save results to scan object (true/false)" @Success 200 {object} controllers.Response The Response object @router /scan-asset [post]
func (*ApiController) ScanAssets ¶
func (c *ApiController) ScanAssets()
ScanAssets @Title ScanAssets @Tag Asset API @Description scan assets from a cloud provider @Param owner query string true "The owner" @Param provider query string true "The provider name" @Success 200 {object} controllers.Response The Response object @router /scan-assets [post]
func (*ApiController) ScrapeDocs ¶
func (c *ApiController) ScrapeDocs()
ScrapeDocs is the ingest-specific route: it crawls a site and WRITES the structured content into the owner's search index, returning ScrapeStats. This is orthogonal to POST /v1/crawl (which fetches a URL and returns its content without indexing) — /v1/scrape is "crawl-and-index", /v1/crawl is "crawl".
@Title ScrapeDocs @Tag Scraper API @Description crawl a website and index structured content into search (ingest) @Param body body object.ScrapeRequest true "Scrape request" @Success 200 {object} object.ScrapeStats "Scrape and index statistics" @router /scrape [post]
func (*ApiController) ScrapePreview ¶
func (c *ApiController) ScrapePreview()
ScrapePreview is a DEPRECATED alias of POST /v1/crawl — the single canonical "crawl a URL, get content back" endpoint (Crawl4AI). It forwards to that one handler so there is exactly ONE crawl implementation; there is no parallel scrape-preview path. New callers MUST use /v1/crawl.
@Title ScrapePreview @Tag Scraper API @Description DEPRECATED — use POST /v1/crawl. Crawl a URL and return its content. @Param body body controllers.crawlRequest true "Crawl request ({url} or {urls})" @Success 200 {object} controllers.Response "{results: []object.CrawlResult}" @router /scrape/preview [post]
func (*ApiController) SearchDocs ¶
func (c *ApiController) SearchDocs()
SearchDocs @Title SearchDocs @Tag Search Docs API @Description search documentation using hybrid fulltext + vector search @Param body body object.DocSearchRequest true "Search request" @Success 200 {array} object.DocSearchResult The search results (raw array, not wrapped) @router /search [post]
func (*ApiController) SearchDocsStats ¶
func (c *ApiController) SearchDocsStats()
SearchDocsStats @Title SearchDocsStats @Tag Search Docs API @Description get search index statistics @Success 200 {object} object.DocStatsResponse The stats response @router /search/stats [get]
func (*ApiController) SearchHfDatasets ¶ added in v1.806.13
func (c *ApiController) SearchHfDatasets()
SearchHfDatasets proxies a HuggingFace dataset search (dataset picker).
func (*ApiController) SearchHfModels ¶ added in v1.806.13
func (c *ApiController) SearchHfModels()
SearchHfModels proxies a HuggingFace model search (base-model picker).
func (*ApiController) SetPrimaryAdminProvider ¶ added in v1.790.5
func (c *ApiController) SetPrimaryAdminProvider()
SetPrimaryAdminProvider @Title SetPrimaryAdminProvider @Tag Provider Admin API @Description Make one admin-owned Model provider the primary (IsDefault=true)
and clear IsDefault on all other Model providers, so EXACTLY ONE primary exists. Returns the full updated management list.
@Param body body controllers.setPrimaryRequest true "provider name" @Success 200 {array} controllers.adminProviderView The Response object @router /admin/providers/primary [post]
func (*ApiController) SetSessionClaims ¶
func (c *ApiController) SetSessionClaims(claims *iam.Claims)
func (*ApiController) SetSessionUser ¶
func (c *ApiController) SetSessionUser(user *iam.User)
func (*ApiController) Signin ¶
func (c *ApiController) Signin()
Signin @Title Signin @Tag Account API @Description sign in @Param code query string true "code of account" @Param state query string true "state of account" @Success 200 {object} iam.Claims The Response object @router /signin [post]
func (*ApiController) Signout ¶
func (c *ApiController) Signout()
Signout @Title Signout @Tag Account API @Description sign out @Success 200 {object} controllers.Response The Response object @router /signout [post]
func (*ApiController) StartConnection ¶
func (c *ApiController) StartConnection()
StartConnection @Title StartConnection @Tag Connection API @Description start connection @Param id query string true "The id of connection" @Success 200 {object} Response @router /start-connection [post]
func (*ApiController) StopConnection ¶
func (c *ApiController) StopConnection()
StopConnection @Title StopConnection @Tag Connection API @Description stop connection @Param id query string true "The id of connection" @Success 200 {object} Response @router /stop-connection [post]
func (*ApiController) T ¶
func (c *ApiController) T(error string) string
func (*ApiController) ToggleAdminProvider ¶ added in v1.790.5
func (c *ApiController) ToggleAdminProvider()
ToggleAdminProvider @Title ToggleAdminProvider @Tag Provider Admin API @Description Enable/disable an admin-owned Model provider (sets State to
"Active"/"Disabled") via the SAME store the generic CRUD uses. Persists across restarts (init.go never clobbers State on an existing record). Returns the updated management view for that provider.
@Param body body controllers.toggleProviderRequest true "provider name + enabled flag" @Success 200 {object} controllers.adminProviderView The Response object @router /admin/providers/toggle [post]
func (*ApiController) TunnelMonitor ¶
func (c *ApiController) TunnelMonitor()
func (*ApiController) UndeployApplication ¶
func (c *ApiController) UndeployApplication()
UndeployApplication @Title UndeployApplication @Tag Application API @Description undeploy application synchronously @Param body body object.Application true "The details of the application" @Success 200 {object} controllers.Response The Response object @router /undeploy-application [post]
func (*ApiController) UpdateApplication ¶
func (c *ApiController) UpdateApplication()
UpdateApplication @Title UpdateApplication @Tag Application API @Description update application @Param id query string true "The id (owner/name) of the application" @Param body body object.Application true "The details of the application" @Success 200 {object} controllers.Response The Response object @router /update-application [post]
func (*ApiController) UpdateArticle ¶
func (c *ApiController) UpdateArticle()
UpdateArticle @Title UpdateArticle @Tag Article API @Description update article @Param id query string true "The id (owner/name) of the article" @Param body body object.Article true "The details of the article" @Success 200 {object} controllers.Response The Response object @router /update-article [post]
func (*ApiController) UpdateAsset ¶
func (c *ApiController) UpdateAsset()
UpdateAsset @Title UpdateAsset @Tag Asset API @Description update asset @Param id query string true "The id ( owner/name ) of the asset" @Param body body object.Asset true "The details of the asset" @Success 200 {object} controllers.Response The Response object @router /update-asset [post]
func (*ApiController) UpdateCaase ¶
func (c *ApiController) UpdateCaase()
UpdateCaase @Title UpdateCaase @Tag Caase API @Description update caase @Param id query string true "The id ( owner/name ) of the caase" @Param body body object.Caase true "The details of the caase" @Success 200 {object} controllers.Response The Response object @router /update-caase [post]
func (*ApiController) UpdateChat ¶
func (c *ApiController) UpdateChat()
UpdateChat @Title UpdateChat @Tag Chat API @Description update Chat @Param id query string true "The id (owner/name) of the chat" @Param body body object.Chat true "The details of the chat" @Success 200 {object} controllers.Response The Response object @router /update-chat [post]
func (*ApiController) UpdateConnection ¶
func (c *ApiController) UpdateConnection()
UpdateConnection @Title UpdateConnection @Tag Connection API @Description update connection @Param id query string true "The id of connection" @Param body body object.Connection true "The connection object" @Success 200 {object} Response @router /update-connection [post]
func (*ApiController) UpdateConsultation ¶
func (c *ApiController) UpdateConsultation()
UpdateConsultation @Title UpdateConsultation @Tag Consultation API @Description update consultation @Param id query string true "The id ( owner/name ) of the consultation" @Param body body object.Consultation true "The details of the consultation" @Success 200 {object} controllers.Response The Response object @router /update-consultation [post]
func (*ApiController) UpdateDoctor ¶
func (c *ApiController) UpdateDoctor()
UpdateDoctor @Title UpdateDoctor @Tag Doctor API @Description update doctor @Param id query string true "The id ( owner/name ) of the doctor" @Param body body object.Doctor true "The details of the doctor" @Success 200 {object} controllers.Response The Response object @router /update-doctor [post]
func (*ApiController) UpdateFile ¶
func (c *ApiController) UpdateFile()
UpdateFile @Title UpdateFile @Tag File API @Description update file object @Param id query string true "The id (owner/name) of the file object" @Param body body object.File true "The details of the file object" @Success 200 {object} controllers.Response The Response object @router /update-file [post]
func (*ApiController) UpdateForm ¶
func (c *ApiController) UpdateForm()
UpdateForm @Title UpdateForm @Tag Form API @Description update form @Param id query string true "The id (owner/name) of the form" @Param body body object.Form true "The details of the form" @Success 200 {object} controllers.Response The Response object @router /update-form [post]
func (*ApiController) UpdateGraph ¶
func (c *ApiController) UpdateGraph()
UpdateGraph @Title UpdateGraph @Tag Graph API @Description update Graph @Param id query string true "The id (owner/name) of the Graph" @Param body body object.Graph true "The details of the Graph" @Success 200 {object} controllers.Response The Response object @router /update-Graph [post]
func (*ApiController) UpdateHospital ¶
func (c *ApiController) UpdateHospital()
UpdateHospital @Title UpdateHospital @Tag Hospital API @Description update hospital @Param id query string true "The id ( owner/name ) of the hospital" @Param body body object.Hospital true "The details of the hospital" @Success 200 {object} controllers.Response The Response object @router /update-hospital [post]
func (*ApiController) UpdateMessage ¶
func (c *ApiController) UpdateMessage()
UpdateMessage @Title UpdateMessage @Tag Message API @Description update message @Param id query string true "The id (owner/name) of the message" @Param body body object.Message true "The details of the message" @Success 200 {object} controllers.Response The Response object @router /update-message [post]
func (*ApiController) UpdateModelRoute ¶
func (c *ApiController) UpdateModelRoute()
UpdateModelRoute @Title UpdateModelRoute @Tag ModelRoute API @Description update a model route @Param owner query string true "The owner (org)" @Param modelName query string true "The model name" @Param body body object.ModelRoute true "The details of the model route" @Success 200 {object} controllers.Response The Response object @router /update-model-route [post]
func (*ApiController) UpdateNode ¶
func (c *ApiController) UpdateNode()
UpdateNode @Title UpdateNode @Tag Node API @Description update node @Param id query string true "The id ( owner/name ) of the node" @Param body body object.Node true "The details of the node" @Success 200 {object} controllers.Response The Response object @router /update-node [post]
func (*ApiController) UpdatePatient ¶
func (c *ApiController) UpdatePatient()
UpdatePatient @Title UpdatePatient @Tag Patient API @Description update patient @Param id query string true "The id ( owner/name ) of the patient" @Param body body object.Patient true "The details of the patient" @Success 200 {object} controllers.Response The Response object @router /update-patient [post]
func (*ApiController) UpdatePermission ¶
func (c *ApiController) UpdatePermission()
UpdatePermission @Title UpdatePermission @Tag Permission API @Description update permission @Param body body iam.Permission true "The details of the permission" @Success 200 {object} controllers.Response The Response object @router /update-permission [post]
func (*ApiController) UpdatePreferences ¶ added in v1.785.10
func (c *ApiController) UpdatePreferences()
UpdatePreferences persists user customizations (favorites, layout, etc.) onto the signed-in user's IAM account so they follow the user across every product and every device/login.
SELF-SCOPED BY DESIGN: the target user is taken from the session, never from the request body — a caller can only ever change their own preferences. The posted JSON object is SHALLOW-MERGED into the existing preferences by top-level key, so one product (or device) writing its keys never clobbers another's. Persisted column-scoped (`properties` only) so no other user field is touched. Returns the merged preferences object.
@Title UpdatePreferences @Tag Account API @Description persist the signed-in user's cross-product preferences @Success 200 {object} object the merged preferences @router /update-preferences [post]
func (*ApiController) UpdateProvider ¶
func (c *ApiController) UpdateProvider()
UpdateProvider @Title UpdateProvider @Tag Provider API @Description update provider @Param id query string true "The id (owner/name) of the provider" @Param body body object.Provider true "The details of the provider" @Success 200 {object} controllers.Response The Response object @router /update-provider [post]
func (*ApiController) UpdateRecord ¶
func (c *ApiController) UpdateRecord()
UpdateRecord @Title UpdateRecord @Tag Record API @Description update record @Param id query string true "The id ( owner/name ) of the record" @Param body body object.Record true "The details of the record" @Success 200 {object} controllers.Response The Response object @router /update-record [post]
func (*ApiController) UpdateScale ¶
func (c *ApiController) UpdateScale()
UpdateScale @router /update-scale [post]
func (*ApiController) UpdateScan ¶
func (c *ApiController) UpdateScan()
UpdateScan @Title UpdateScan @Tag Scan API @Description update scan @Param id query string true "The id ( owner/name ) of the scan" @Param body body object.Scan true "The details of the scan" @Success 200 {object} controllers.Response The Response object @router /update-scan [post]
func (*ApiController) UpdateSession ¶
func (c *ApiController) UpdateSession()
UpdateSession @Title UpdateSession @Tag Session API @Description Update session for one user in one application. @Param id query string true "The id(organization/application/user) of session" @Success 200 {array} string The Response object @router /update-session [post]
func (*ApiController) UpdateStore ¶
func (c *ApiController) UpdateStore()
UpdateStore @Title UpdateStore @Tag Store API @Description update store @Param id query string true "The id (owner/name) of the store" @Param body body object.Store true "The details of the store" @Success 200 {object} controllers.Response The Response object @router /update-store [post]
func (*ApiController) UpdateTask ¶
func (c *ApiController) UpdateTask()
UpdateTask @Title UpdateTask @Tag Task API @Description update task @Param id query string true "The id (owner/name) of the task" @Param body body object.Task true "The details of the task" @Success 200 {object} controllers.Response The Response object @router /update-task [post]
func (*ApiController) UpdateTemplate ¶
func (c *ApiController) UpdateTemplate()
UpdateTemplate @Title UpdateTemplate @Tag Template API @Description update template @Param id query string true "The id (owner/name) of the template" @Param body body object.Template true "The details of the template" @Success 200 {object} controllers.Response The Response object @router /update-template [post]
func (*ApiController) UpdateTrainingContribution ¶ added in v1.811.0
func (c *ApiController) UpdateTrainingContribution()
UpdateTrainingContribution upserts the caller's OWN org training-contribution opt-in. The owner is forced to GetOrg() (any owner in the body is ignored, and a spoofed X-Org-Id is ignored for a non-super-admin), and the other OrgSettings fields (AutoRouting / DefaultSessionRouting / RouterPrefer) are preserved — the opt-in is an orthogonal concern. Self-scoped via RequirePrincipal (session cookie OR verified Bearer JWT), so the account-settings consent toggle works identically from the console and from Hanzo World; the write only ever touches the principal's OWN org.
@Title UpdateTrainingContribution @Tag Router API @Description opt the caller's org in/out of contributing routing events to the shared retrain @Param body body controllers.trainingContributionBody true "the opt-in state" @Success 200 {object} controllers.trainingContributionBody The resolved state @router /update-training-contribution [post]
func (*ApiController) UpdateTreeFile ¶
func (c *ApiController) UpdateTreeFile()
UpdateTreeFile @Title UpdateTreeFile @Tag Tree File API @Description update tree file @Param storeId query string true "The store id of the file" @Param key query string true "The key of the file" @Param body body object.TreeFile true "The details of the Tree File" @Success 200 {object} controllers.Response The Response object @router /update-tree-file [post]
func (*ApiController) UpdateVector ¶
func (c *ApiController) UpdateVector()
UpdateVector @Title UpdateVector @Tag Vector API @Description update vector @Param id query string true "The id (owner/name) of the vector" @Param body body object.Vector true "The details of the vector" @Success 200 {object} controllers.Response The Response object @router /update-vector [post]
func (*ApiController) UpdateVideo ¶
func (c *ApiController) UpdateVideo()
UpdateVideo @Title UpdateVideo @Tag Video API @Description update video @Param id query string true "The id (owner/name) of the video" @Param body body object.Video true "The details of the video" @Success 200 {object} controllers.Response The Response object @router /update-video [post]
func (*ApiController) UpdateWorkflow ¶
func (c *ApiController) UpdateWorkflow()
UpdateWorkflow @Title UpdateWorkflow @Tag Workflow API @Description update workflow @Param id query string true "The id (owner/name) of the workflow" @Param body body object.Workflow true "The details of the workflow" @Success 200 {object} controllers.Response The Response object @router /update-workflow [post]
func (*ApiController) UploadFile ¶
func (c *ApiController) UploadFile()
UploadFile @Title UploadFile @Tag File API @Description upload file to IAM storage @Param file formData string true "The base64 encoded file data" @Param type formData string true "The file type/extension" @Param name formData string true "The file name" @Success 200 {object} controllers.Response The Response object @router /upload-file [post]
func (*ApiController) UploadTaskDocument ¶
func (c *ApiController) UploadTaskDocument()
UploadTaskDocument @Title UploadTaskDocument @Tag Task API @Description upload document for a task and parse its text @Param id query string true "The id (owner/name) of the task" @Param file formData string true "The base64 encoded file data" @Param type formData string true "The file type/extension" @Param name formData string true "The file name" @Success 200 {object} controllers.Response The Response object @router /upload-task-document [post]
func (*ApiController) UploadVideo ¶
func (c *ApiController) UploadVideo()
UploadVideo @Title UploadVideo @Tag Video API @Description upload video @Param file formData file true "The video file to upload" @Success 200 {object} string "The fileId of the uploaded video" @router /upload-video [post]
func (*ApiController) VideoContent ¶ added in v1.800.0
func (c *ApiController) VideoContent()
VideoContent implements GET /v1/videos/{id}/content — download the finished MP4.
It authenticates + ownership-checks the caller, then proxies the upstream /content endpoint (bounded by the download concurrency ceiling) and streams the raw video bytes back inline. A successful download also bills the job once (for the client that downloads without first polling to completion) — idempotent with the poll path via job.markCompleted.
@Title VideoContent @Tag OpenAI Compatible API @Description Download the finished MP4 of a completed video generation job. @router /videos/:id/content [get]
func (*ApiController) VideosGenerations ¶ added in v1.790.4
func (c *ApiController) VideosGenerations()
VideosGenerations implements POST /v1/videos/generations — the ASYNC create.
Body: {"model": "...", "prompt": "...", "size"?: "1280x720", "seconds"?: int}
It authenticates the caller, resolves the model to its upstream provider via the shared routing table (zen3-video* / wan2-2-t2v-a14b → the spark-video backend), reserves the per-video budget (the balance gate), creates ONE upstream job, registers it in the in-pod store, and returns the OpenAI-shaped video object with status "queued" IMMEDIATELY. The client then polls GET /v1/videos/{id} and downloads GET /v1/videos/{id}/content. Nothing is billed here — the debit lands on completion.
@Title VideosGenerations @Tag OpenAI Compatible API @Description OpenAI Sora-style async text-to-video: create a generation job. @router /videos/generations [post]
func (*ApiController) WecomBotHandleMessage ¶
func (c *ApiController) WecomBotHandleMessage()
WecomBotHandleMessage process WeChat work bot messages @Title WecomBotHandleMessage @Tag WechatWork Bot API @Description handle WeChat work bot messages @router /wecom-bot/callback/:botId [post]
func (*ApiController) WecomBotVerifyUrl ¶
func (c *ApiController) WecomBotVerifyUrl()
WecomBotVerifyUrl verify WeChat work bot callback URL @Title WecomBotVerifyUrl @Tag WechatWork Bot API @Description verify WeChat work bot callback URL @router /wecom-bot/callback/:botId [get]
type BrandIAM ¶ added in v1.795.0
type BrandIAM struct {
// Brand is the canonical brand key (hanzo|lux|zoo|pars).
Brand string
// Endpoint is the IAM OIDC base the code exchange + userinfo target. In
// cluster the exchange rides the internal IAM service (IAM_URL); the public
// issuer host is the value tokens carry (Issuer).
Endpoint string
// Issuer is the JWT `iss` a brand's tokens carry (e.g. https://lux.id).
Issuer string
// ClientID is the brand's OAuth client_id / IAM application name AND the `aud`
// its tokens carry (client_id == app == aud, HIP-0111).
ClientID string
// ClientSecret is the brand's confidential-client secret (from env/KMS). Empty
// for a brand whose secret is not provisioned -- the exchange then fails closed
// with a clear error, never a fabricated token.
ClientSecret string
// Org is the brand's IAM organization slug (the tenant owner).
Org string
}
BrandIAM is a brand's resolved IAM identity for the OAuth code exchange and token validation. ClientID doubles as the OAuth `aud`/client_id; Issuer is the canonical OIDC `iss` a brand's tokens carry.
type CacheTTLs ¶
type CacheTTLs struct {
PricingTTL string `yaml:"pricing_ttl"`
}
CacheTTLs defines TTL durations for cached data.
type CarrierWriter ¶
type CarrierWriter struct {
// contains filtered or unexported fields
}
func (*CarrierWriter) Flush ¶
func (w *CarrierWriter) Flush()
func (*CarrierWriter) MessageString ¶
func (w *CarrierWriter) MessageString() string
type Cleaner ¶
type Cleaner struct {
// contains filtered or unexported fields
}
func NewCleaner ¶
func (*Cleaner) CleanString ¶
func (*Cleaner) GetCleanedData ¶
type DOBackfillOptions ¶ added in v1.813.0
type DOBackfillOptions struct {
From time.Time // window start (inclusive day)
To time.Time // window end (inclusive day)
DryRun bool // when true, plan only — write nothing (the default)
Force bool // when true, import even days native metering already covers
}
DOBackfillOptions is the resolved, already-authorized backfill request.
type DOBackfillPlan ¶ added in v1.813.0
type DOBackfillPlan struct {
DryRun bool `json:"dryRun"`
Force bool `json:"force"`
Provider string `json:"provider"`
Source string `json:"source"`
From string `json:"from"` // RFC3339 (UTC)
To string `json:"to"` // RFC3339 (UTC)
Rows []DOBackfillRow `json:"rows"`
Days int `json:"days"`
Models int `json:"models"`
TotalCents int64 `json:"totalCents"`
Written int `json:"written"`
SkippedNativelyCovered int `json:"skippedNativelyCovered"`
SkippedAlreadyBackfilled int `json:"skippedAlreadyBackfilled"`
InvoicesScanned int `json:"invoicesScanned"`
InvoiceFetchErrors int `json:"invoiceFetchErrors"`
Note string `json:"note"`
}
DOBackfillPlan is the importer's full answer: what it would write / wrote, plus the honest accounting of everything it skipped and why. Returned by both the dry-run and the write path so the console shows an identical shape either way.
func RunDOBackfill ¶ added in v1.813.0
func RunDOBackfill(ctx context.Context, opts DOBackfillOptions) (DOBackfillPlan, error)
RunDOBackfill is the orchestration: fetch DO spend, read the ledger's native + already-backfilled coverage, plan the gap-fill (pure), and — only when dryRun is false — persist. It is a thin seam over the pure/testable pieces; the DO fetch and the planning are exercised directly by the tests, this glue is not.
type DOBackfillRow ¶ added in v1.813.0
type DOBackfillRow struct {
Day string `json:"day"` // YYYY-MM-DD (UTC)
Model string `json:"model"`
Provider string `json:"provider"`
CostCents int64 `json:"costCents"`
Source string `json:"source"`
ID string `json:"id"` // deterministic — re-deriving it for the same (day,model) is stable
}
DOBackfillRow is one (day, model) row the importer would write (dry-run) or wrote.
type FallbackDef ¶
type FallbackDef struct {
Provider string `yaml:"provider"`
Upstream string `yaml:"upstream"`
// ContextWindow is the window THIS provider serves the model at. The same
// model is served at different sizes by different providers — DO serves
// glm-5.2 at 262144 while the model itself is a 1M-context model — so the
// window belongs to the (provider, upstream) pair, not to the model. A
// fallback that reaches a bigger window declares it here; 0 inherits the
// primary route's window.
ContextWindow int `yaml:"context_window,omitempty"`
}
FallbackDef describes an alternate provider+upstream for failover.
type FeatureFlags ¶
type FeatureFlags struct {
LiveMode bool `yaml:"live_mode"`
PremiumGate bool `yaml:"premium_gate"`
}
FeatureFlags controls runtime behavior.
type GuacamoleHandler ¶
type GuacamoleHandler struct {
// contains filtered or unexported fields
}
func NewGuacamoleHandler ¶
func NewGuacamoleHandler(ws *websocket.Conn, tunnel *guacamole.Tunnel) *GuacamoleHandler
func (GuacamoleHandler) Start ¶
func (r GuacamoleHandler) Start()
func (GuacamoleHandler) Stop ¶
func (r GuacamoleHandler) Stop()
type ModelConfig ¶
type ModelConfig struct {
// contains filtered or unexported fields
}
ModelConfig is the runtime singleton that serves model routing and pricing from a parsed YAML config file.
func GetModelConfig ¶
func GetModelConfig() *ModelConfig
GetModelConfig returns the singleton. Returns nil if not initialized.
func (*ModelConfig) AutoRoutingActive ¶ added in v1.802.0
func (mc *ModelConfig) AutoRoutingActive(orgPref string) bool
AutoRoutingActive decides whether the virtual `auto`/`zen-router` model routes for a request, given the EFFECTIVE preference already resolved by effectiveAutoRouting (org row > "*" GlobalDefaultOwner row > deprecated ROUTER_ENABLED env). Precedence on that resolved three-state preference:
- "disabled": never routes — `auto` falls through as a pre-routing unknown id
- "enabled": routes whenever router config is present (per-org or global opt-in)
- "" (unset): every row and the env are unset — the conf router.enabled flag is the last-resort default
func (*ModelConfig) ConfRouterPolicy ¶ added in v1.811.0
func (mc *ModelConfig) ConfRouterPolicy() (map[string][]string, float64)
ConfRouterPolicy returns the live conf router Prefer + CostCeiling under the read lock — the baseline that effectiveRouterPrefer / effectiveRouterCostCeiling fold the per-org OrgSettings over. The Prefer map is copied so callers never hold (or mutate) the live config map.
func (*ModelConfig) ContextWindow ¶ added in v1.806.7
func (mc *ModelConfig) ContextWindow(model string) int
ContextWindow returns the max context (tokens) a model is served at, or 0 when nothing declares it (the caller applies the floor).
A window is a property of WHERE a model is served, not of the model alone: GLM-5.2 is a 1M-context model, but DigitalOcean serves it at 262144. So the value resolves in three steps, most specific first:
provider override (this route's own context_window) model default (the upstream leaf's context_window, via the alias chain) floor (0 here; model.DefaultContextLength at the call site)
The alias chain means `zen5` inherits its upstream's window without redeclaring it. Lookup is by normalized lowercase key.
func (*ModelConfig) GetPrice ¶
func (mc *ModelConfig) GetPrice(model string) modelPrice
GetPrice returns pricing for a model name, with alias and default fallback.
func (*ModelConfig) GetPriceOK ¶ added in v1.812.0
func (mc *ModelConfig) GetPriceOK(model string) (modelPrice, bool)
GetPriceOK is GetPrice plus whether a REAL per-model price was found (true) or the configured default was synthesized (false). The price value is identical to GetPrice; only unpriced-model detection reads the bool.
func (*ModelConfig) LastPricingRefresh ¶
func (mc *ModelConfig) LastPricingRefresh() time.Time
LastPricingRefresh returns when pricing was last refreshed from live source.
func (*ModelConfig) ListModels ¶
func (mc *ModelConfig) ListModels() []modelInfo
ListModels returns visible models sorted by name (excludes hidden).
func (*ModelConfig) ListModelsWithUpstream ¶
func (mc *ModelConfig) ListModelsWithUpstream() []zapModelEntry
ListModelsWithUpstream returns all models including upstream IDs (for ZAP).
func (*ModelConfig) PremiumGateEnabled ¶
func (mc *ModelConfig) PremiumGateEnabled() bool
PremiumGateEnabled returns whether the premium gate feature is active.
func (*ModelConfig) Reload ¶
func (mc *ModelConfig) Reload() error
Reload re-reads the config file and triggers a live pricing fetch if enabled.
func (*ModelConfig) ResolveRoute ¶
func (mc *ModelConfig) ResolveRoute(model string) *modelRoute
ResolveRoute looks up a user-facing model name and returns its route. Returns nil if the model is not in the routing table.
func (*ModelConfig) RetryConfig ¶ added in v1.806.7
func (mc *ModelConfig) RetryConfig() RetryDef
RetryConfig returns the configured retry policy (zero fields mean "use the default"). Read under the lock so a live config reload is safe.
func (*ModelConfig) RouteForContext ¶ added in v1.806.7
func (mc *ModelConfig) RouteForContext(model string, tokens int) (provider, upstream string, window int, ok bool)
RouteForContext picks a route for `model` that can actually serve a prompt of `tokens`, returning the provider and upstream to call.
The primary route is used whenever it fits. When it does not — the prompt is 400K and DO serves glm-5.2 at 262144 — the request is not refused: the fallback chain is searched for a provider that serves the SAME model with a window big enough, and that one is called instead. Fallbacks are declared in preference order, so the first that fits wins.
This is why the window lives on the (provider, upstream) pair: it turns the fallback chain from failover-only into capability selection. If nothing in the chain fits, the primary is returned and the upstream rejects it — an honest error from the model rather than a guess from us.
tokens <= 0 means "unknown size": take the primary.
func (*ModelConfig) RouterClient ¶ added in v1.802.0
func (mc *ModelConfig) RouterClient(known func(string) bool) router.Client
RouterClient assembles a router.Client from the config, regardless of the enabled flag — the enable decision is made separately by AutoRoutingActive. `known` restricts the choice to models the caller can serve for the current org (typically resolveModelRouteForOrg != nil). Cheap to build per request.
func (*ModelConfig) RouterEnabled ¶ added in v1.802.0
func (mc *ModelConfig) RouterEnabled() bool
RouterEnabled reports whether the virtual `auto`/`zen-router` model is active.
func (*ModelConfig) Status ¶
func (mc *ModelConfig) Status() string
Status returns a human-readable status string for diagnostics.
func (*ModelConfig) Stop ¶
func (mc *ModelConfig) Stop()
Stop signals the background refresh goroutine to exit.
type ModelConfigFile ¶
type ModelConfigFile struct {
Version int `yaml:"version"`
Services ServiceEndpoints `yaml:"services"`
Cache CacheTTLs `yaml:"cache"`
Features FeatureFlags `yaml:"features"`
Retry RetryDef `yaml:"retry"`
Router RouterConfigDef `yaml:"router"`
DefaultPricing ModelPriceDef `yaml:"default_pricing"`
Models map[string]ModelDef `yaml:"models"`
}
ModelConfigFile is the top-level structure of conf/models.yaml.
type ModelDef ¶
type ModelDef struct {
Provider string `yaml:"provider"`
Upstream string `yaml:"upstream"`
Fallbacks []FallbackDef `yaml:"fallbacks,omitempty"`
Premium bool `yaml:"premium"`
Hidden bool `yaml:"hidden"`
OwnedBy string `yaml:"owned_by"`
AliasOf string `yaml:"alias_of"`
AliasPricing string `yaml:"alias_pricing"`
PricingOnly bool `yaml:"pricing_only"`
Pricing *ModelPriceDef `yaml:"pricing,omitempty"`
// ContextWindow is the model's max input+output context in tokens. When
// set (>0) it overrides the heuristic getContextLength table — models.yaml
// is the per-model source of truth, configurable without a rebuild. This
// is the single field that stops long prompts (and /compact) dead-ending
// on a stale 16K/256K fallback for models the table predates.
ContextWindow int `yaml:"context_window,omitempty"`
// MaxOutputTokens is the model's max completion length (tokens), taken from
// the upstream catalog. Surfaced in /v1/models so a client caps its output
// request honestly instead of guessing.
MaxOutputTokens int `yaml:"max_output_tokens,omitempty"`
// Vision reports the model accepts image input (OpenAI image_url content
// parts); Tools reports it supports function/tool calling. Both are additive
// capability flags surfaced in /v1/models (omitempty ⇒ present only when
// true). Set ONLY from a live capability probe of the serving provider —
// never guessed — so absence means "not advertised", never a fabricated yes.
Vision bool `yaml:"vision,omitempty"`
Tools bool `yaml:"tools,omitempty"`
}
ModelDef describes a single model entry in the config.
type ModelPriceDef ¶
type ModelPriceDef struct {
InputPerMillion float64 `yaml:"input_per_million,omitempty"`
OutputPerMillion float64 `yaml:"output_per_million,omitempty"`
Input float64 `yaml:"input,omitempty"`
Output float64 `yaml:"output,omitempty"`
CostInPerMillion float64 `yaml:"cost_in_per_million,omitempty"`
CostOutPerMillion float64 `yaml:"cost_out_per_million,omitempty"`
}
ModelPriceDef holds per-million token economics: the customer price (Input/Output, with the *_per_million long form) plus the optional provider COGS (cost_in_per_million / cost_out_per_million). COGS unset ⇒ cost defaults to price (zero margin), so an entry that lists only a price is byte-identical to before.
type OpenAIResponsesRequest ¶ added in v1.806.15
type OpenAIResponsesRequest struct {
Model string `json:"model"`
Instructions string `json:"instructions,omitempty"`
Input json.RawMessage `json:"input"`
Tools []responsesTool `json:"tools,omitempty"`
ToolChoice json.RawMessage `json:"tool_choice,omitempty"`
ParallelToolCalls *bool `json:"parallel_tool_calls,omitempty"`
Stream bool `json:"stream,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
Temperature *float32 `json:"temperature,omitempty"`
TopP *float32 `json:"top_p,omitempty"`
Store bool `json:"store,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Reasoning json.RawMessage `json:"reasoning,omitempty"`
Text json.RawMessage `json:"text,omitempty"`
}
OpenAIResponsesRequest is the subset of POST /v1/responses used by Codex and OpenAI SDKs. Unknown fields are deliberately accepted for forward compatibility; fields that Chat Completions cannot represent are ignored.
type OpenAIWriter ¶
type OpenAIWriter struct {
web.Response
Cleaner Cleaner
Buffer []byte
MessageBuf []byte
RequestID string
Stream bool
StreamSent bool
Model string
// IncludeUsage mirrors the request's stream_options.include_usage. Per the
// OpenAI spec the trailing empty-choices usage chunk is emitted ONLY when the
// client asks for it; sending it unconditionally breaks clients that read
// choices[0] on every chunk.
IncludeUsage bool
}
OpenAIWriter implements a writer that formats responses in OpenAI format
func (*OpenAIWriter) Close ¶
func (w *OpenAIWriter) Close(promptTokens, completionTokens, totalTokens int) error
Close finalizes the stream by sending completion message and DONE marker
func (*OpenAIWriter) MessageString ¶
func (w *OpenAIWriter) MessageString() string
MessageString returns the complete buffered message
type PanelJudge ¶ added in v1.826.5
type PanelJudge struct {
Model string `json:"model"`
Weight float64 `json:"weight"`
Mean float64 `json:"mean"`
N int `json:"n"`
}
PanelJudge is one judge's public, in-process snapshot: its model id, current reliability weight, running mean of RAW scores (the judge's own calibration baseline), and how many scores it has observed. Scalars + a model id only — no content, no PII — so it rides the public /v1/router/judge-panel surface the world.hanzo.ai dashboard polls.
func PanelSnapshot ¶ added in v1.826.5
func PanelSnapshot() []PanelJudge
PanelSnapshot copies the LIVE MFJP calibration state under the lock into a stable, deterministically-ordered (by model id) slice of per-judge scalars for the read endpoint. Empty when no judge has scored yet ⇒ the endpoint reports available:false.
type ProviderUsage ¶ added in v1.809.0
type ProviderUsage struct {
Provider string `json:"provider"`
Connected bool `json:"connected"`
Available bool `json:"available"`
Note string `json:"note,omitempty"`
Currency string `json:"currency"`
Start string `json:"start"`
End string `json:"end"`
Interval string `json:"interval"`
Totals ProviderUsageTotals `json:"totals"`
Series []ProviderUsageSeriesPoint `json:"series"`
ByModel []ProviderUsageModelSpend `json:"byModel"`
}
ProviderUsage is the ONE normalized third-party-usage value. Money is USD cents end-to-end (matching CloudUsageOverview.spendCents), so the unified panel renders a connected provider with the SAME vocabulary as native Hanzo usage. `connected` is false when the org has no active connection; `available` is false (with a human `note`) when the provider API returned nothing or the key lacked the usage scope — the two distinct honest-empty states the UI shows instead of a fabricated zero.
type ProviderUsageModelSpend ¶ added in v1.809.0
type ProviderUsageModelSpend struct {
Model string `json:"model"`
SpendCents int64 `json:"spendCents"`
Tokens int64 `json:"tokens"`
Requests int64 `json:"requests"`
}
ProviderUsageModelSpend is one model's slice of the window (spend-by-model). Spend is 0 for providers whose per-model cost is not exposed by their usage API (honest, not fabricated) — tokens/requests are still the real per-model figures.
type ProviderUsageSeriesPoint ¶ added in v1.809.0
type ProviderUsageSeriesPoint struct {
T string `json:"t"` // RFC3339 bucket start (UTC)
SpendCents int64 `json:"spendCents"`
Tokens int64 `json:"tokens"`
Requests int64 `json:"requests"`
}
ProviderUsageSeriesPoint is one day-bucket of the ascending time series.
type ProviderUsageTotals ¶ added in v1.809.0
type ProviderUsageTotals struct {
SpendCents int64 `json:"spendCents"`
Tokens int64 `json:"tokens"`
InputTokens int64 `json:"inputTokens"`
OutputTokens int64 `json:"outputTokens"`
Requests int64 `json:"requests"`
}
ProviderUsageTotals are the window totals — the metric cards.
type RefinedWriter ¶
func (*RefinedWriter) MessageString ¶
func (w *RefinedWriter) MessageString() string
func (*RefinedWriter) ReasonString ¶
func (w *RefinedWriter) ReasonString() string
func (*RefinedWriter) SearchString ¶
func (w *RefinedWriter) SearchString() string
func (*RefinedWriter) String ¶
func (w *RefinedWriter) String() string
func (*RefinedWriter) ToolString ¶
func (w *RefinedWriter) ToolString() string
type RetryDef ¶ added in v1.806.7
type RetryDef struct {
Attempts int `yaml:"attempts,omitempty"`
BaseBackoff string `yaml:"base_backoff,omitempty"` // e.g. "500ms"
MaxBackoff string `yaml:"max_backoff,omitempty"` // e.g. "4s"
}
RetryDef is how long we hold a request open for a provider that is merely busy, rather than handing its 429 to the client.
It is configuration, not a constant, for the same reason the context windows are: the right number is a property of the providers we happen to be using today, and it changes without our code changing. Baking it in means a rebuild to tune a timeout — which is how the context table ended up lying for a year.
attempts: total tries of ONE provider (1 disables same-provider retry). base/max: exponential backoff bounds, jittered, capped by the caller's deadline.
type RouterConfigDef ¶ added in v1.802.0
type RouterConfigDef struct {
Enabled bool `yaml:"enabled"`
Endpoint string `yaml:"endpoint"` // zen-router base URL; "" = heuristic only
Prefer map[string][]string `yaml:"prefer"` // task tag → ordered model ids ("default" catch-all)
CostCeiling float64 `yaml:"cost_ceiling"` // advisory cost cap, USD per 1k tokens (per-1k), forwarded verbatim as the engine SLO
}
RouterConfigDef configures the virtual `auto`/`zen-router` model. When disabled (the default) `auto` is not a routable model and behaves like any other unknown id. When enabled, a chat request for `auto` is classified and mapped to a concrete servable model before provider/pricing/billing resolution — so the request bills and reports the model that served it.
type ServedUsage ¶ added in v1.814.0
type ServedUsage struct {
Owner string // billing org (who paid) — the warehouse partition key
User string // actor, "owner/name" when known
Model string // the SKU the caller requested (zen5, …)
Provider string // serving family label ("zen")
RequestID string
Status string // "success" | "error"
ErrorMsg string
PromptTokens int
CompletionTokens int
BilledNano int64 // exact retail billed, nano-USD; 0 = recompute from rates
CostNano int64 // exact upstream COGS, nano-USD; 0 = recompute from rates
StartTime time.Time
}
ServedUsage is the trace input for a request that was BILLED ELSEWHERE — a co-resident subsystem that debits commerce itself (zen's Meter in the unified cloud binary) but must still land in the ONE usage warehouse + o11y span plane this package owns. Money is exact nano-USD when the biller knows it (zen computes both retail and upstream COGS per served tier); 0 falls back to the rate-table recompute.
type ServiceEndpoints ¶
type ServiceEndpoints struct {
PricingURL string `yaml:"pricing_url"`
}
ServiceEndpoints holds URLs for external pricing/model services.
Source Files
¶
- account.go
- activity.go
- agent.go
- anthropic_api.go
- anthropic_translate.go
- application.go
- article.go
- asset.go
- audio_api.go
- auto_route.go
- base.go
- billing_nano.go
- billing_reserve.go
- brand.go
- caase.go
- carrier_writer.go
- chat.go
- chat_retrieval.go
- cloud_usage.go
- connection.go
- connections_api.go
- connections_oauth.go
- connections_usage.go
- consultation.go
- crawl.go
- dev_bridge.go
- do_backfill.go
- docs_ingest.go
- doctor.go
- embeddings_api.go
- failover.go
- family_tier.go
- file.go
- file_cache.go
- finetune.go
- form.go
- form_data.go
- gateway_bridge.go
- graph.go
- graph_chat.go
- hospital.go
- images_api.go
- memory.go
- message.go
- message_answer.go
- message_carrier.go
- message_dryrun.go
- message_util.go
- message_writer.go
- model_access.go
- model_config.go
- model_config_live.go
- model_pricing.go
- model_route.go
- model_routes.go
- node.go
- openai_api.go
- openai_responses.go
- openai_writer.go
- openrouter_catalog.go
- org_resolver.go
- patch.go
- patient.go
- permission.go
- platform_fee.go
- prometheus.go
- provider.go
- provider_admin.go
- provider_flags.go
- rag.go
- rag_librechat.go
- reasoning.go
- record.go
- record_chain.go
- resource.go
- retry.go
- router_history.go
- router_judge.go
- router_judge_panel.go
- router_judge_panel_read.go
- router_meanfield.go
- router_policy.go
- router_probe.go
- router_stats.go
- router_trainer.go
- routing_autoreward.go
- routing_defaults.go
- routing_reward.go
- scale.go
- scan.go
- scraper.go
- search_docs.go
- session.go
- speech_to_text.go
- storage_provider.go
- store.go
- system_info.go
- task.go
- task_upload.go
- telemetry.go
- template.go
- template_deploy.go
- text_to_speech.go
- trace_export.go
- traffic_globe.go
- tree_file.go
- tunnel.go
- tunnel_handler.go
- upstream_error.go
- usage.go
- util.go
- util_record.go
- vector.go
- video.go
- video_jobs.go
- videos_api.go
- vm.go
- wecom_bot.go
- workflow.go
- zap_account-auth.go
- zap_ai-connections-byo.go
- zap_anthropic-messages.go
- zap_application-deploy.go
- zap_audio.go
- zap_billing-usage.go
- zap_chat-graph-crud.go
- zap_embeddings-rerank.go
- zap_forward.go
- zap_images-generation.go
- zap_infra-k8s-crud.go
- zap_interservice.go
- zap_knowledge-stores-files-vectors.go
- zap_memory.go
- zap_model-routing-config.go
- zap_native.go
- zap_providers-admin.go
- zap_rag-search-crawl.go
- zap_records-sessions-connections.go
- zap_registry.go
- zap_responses.go
- zap_router-policy-stats.go
- zap_security-assets-scans.go
- zap_verticals-and-misc.go
- zap_videos-generation.go
- zap_workspace-crud.go
- zen_client.go
- zen_media.go