Documentation
¶
Overview ¶
Package openai provides an OpenAI-compatible API server for OmniAgent.
Index ¶
- Constants
- Variables
- func CalculateCost(model string, promptTokens, completionTokens int) float64
- func GenerateCostChart(ts *UsageTimeseries) *chartir.ChartIR
- func GenerateModelPieChart(summary *UsageSummary) *chartir.ChartIR
- func GenerateTokensChart(ts *UsageTimeseries) *chartir.ChartIR
- func GetAAuthClaims(ctx context.Context) *auth.AAuthClaims
- func GetAgentAuthClaims(ctx context.Context) *auth.AgentAuthClaims
- type AgentHandler
- type AgentInfo
- type AgentManager
- type AgentUsage
- type ChatCompletionChunk
- type ChatCompletionRequest
- type ChatCompletionResponse
- type Choice
- type ChunkChoice
- type ChunkDelta
- type CloneAgentRequest
- type Config
- type CreateAgentRequest
- type CreateCronJobRequest
- type CronActionInfo
- type CronJobInfo
- type CronJobResult
- type CronScheduleInfo
- type Error
- type ErrorResponse
- type Function
- type FunctionCall
- type MemoryCollection
- type MemoryHandler
- type MemoryRecord
- type MemorySearchResult
- type Message
- type Model
- type ModelPricing
- type ModelUsage
- type Option
- func WithAAuth(cfg *auth.AAuthConfig) Option
- func WithAPIKeys(keys ...string) Option
- func WithAPIPrefix(prefix string) Option
- func WithAgentAuth(cfg *auth.AgentAuthConfig) Option
- func WithAuth(cfg *auth.Config) Option
- func WithBaseURL(url string) Option
- func WithLogger(logger *slog.Logger) Option
- func WithOpenAIPrefix(prefix string) Option
- func WithPhoneNumber(phone string) Option
- func WithWebUI(enabled bool) Option
- type SSEWriter
- type Server
- type StoreMemoryRequest
- type StreamingHandler
- type Tool
- type ToolCall
- type ToolInfo
- type UpdateAgentRequest
- type UpdateCronJobRequest
- type Usage
- type UsageBucket
- type UsageHandler
- type UsageRecord
- type UsageStore
- func (s *UsageStore) Clear()
- func (s *UsageStore) Count() int
- func (s *UsageStore) GetRecords(limit int) []UsageRecord
- func (s *UsageStore) GetSummary(since, until time.Time) *UsageSummary
- func (s *UsageStore) GetTimeseries(since, until time.Time, interval string) *UsageTimeseries
- func (s *UsageStore) Record(r UsageRecord)
- type UsageSummary
- type UsageTimeseries
Constants ¶
const ( NamingSourceOpenAI = "openai" NamingSourceEchartify = "echartify" NamingSourceOmniAgent = "omniagent" )
Naming convention sources
Variables ¶
ErrUnauthorized is returned when authentication fails.
Functions ¶
func CalculateCost ¶
CalculateCost estimates the cost based on model and tokens.
func GenerateCostChart ¶
func GenerateCostChart(ts *UsageTimeseries) *chartir.ChartIR
GenerateCostChart generates a ChartIR for cost over time.
func GenerateModelPieChart ¶
func GenerateModelPieChart(summary *UsageSummary) *chartir.ChartIR
GenerateModelPieChart generates a ChartIR for usage by model.
func GenerateTokensChart ¶
func GenerateTokensChart(ts *UsageTimeseries) *chartir.ChartIR
GenerateTokensChart generates a ChartIR for token usage over time.
func GetAAuthClaims ¶
func GetAAuthClaims(ctx context.Context) *auth.AAuthClaims
GetAAuthClaims retrieves AAuth claims from the context. Deprecated: Use GetAgentAuthClaims for unified claim access.
func GetAgentAuthClaims ¶
func GetAgentAuthClaims(ctx context.Context) *auth.AgentAuthClaims
GetAgentAuthClaims retrieves agent authentication claims from the context. Works for both ID-JAG and AAuth tokens.
Types ¶
type AgentHandler ¶
type AgentHandler interface {
// ChatCompletion handles a chat completion request.
// Returns the response text.
ChatCompletion(ctx context.Context, req *ChatCompletionRequest) (*ChatCompletionResponse, error)
// ChatCompletionStream handles streaming chat completion.
// Calls onDelta for each chunk, should return after all chunks are sent.
ChatCompletionStream(ctx context.Context, req *ChatCompletionRequest,
onDelta func(delta *ChatCompletionChunk) error) error
// ListModels returns available models/agents.
ListModels(ctx context.Context) ([]Model, error)
// GetModel returns details for a specific model/agent.
GetModel(ctx context.Context, modelID string) (*Model, error)
// ListTools returns available tools registered with the agent.
ListTools(ctx context.Context) ([]ToolInfo, error)
// ListCronJobs returns all scheduled jobs.
ListCronJobs(ctx context.Context) ([]CronJobInfo, error)
// GetCronJob returns a specific job by ID.
GetCronJob(ctx context.Context, id string) (*CronJobInfo, error)
// CreateCronJob creates a new scheduled job.
CreateCronJob(ctx context.Context, req *CreateCronJobRequest) (*CronJobInfo, error)
// UpdateCronJob updates an existing job.
UpdateCronJob(ctx context.Context, id string, req *UpdateCronJobRequest) (*CronJobInfo, error)
// DeleteCronJob removes a job.
DeleteCronJob(ctx context.Context, id string) error
// TriggerCronJob runs a job immediately.
TriggerCronJob(ctx context.Context, id string) (*CronJobResult, error)
// EnableCronJob enables a disabled job.
EnableCronJob(ctx context.Context, id string) error
// DisableCronJob disables a job without deleting it.
DisableCronJob(ctx context.Context, id string) error
}
AgentHandler defines the interface that agent implementations must satisfy. OmniAgent's agent.Agent will implement this interface via an adapter.
type AgentInfo ¶
type AgentInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Provider string `json:"provider"`
Model string `json:"model"`
Temperature float64 `json:"temperature,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
SystemPrompt string `json:"system_prompt,omitempty"`
AllowedTools []string `json:"allowed_tools,omitempty"`
DeniedTools []string `json:"denied_tools,omitempty"`
Enabled bool `json:"enabled"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
AgentInfo represents information about a configured agent.
type AgentManager ¶
type AgentManager interface {
// ListAgents returns all configured agents.
ListAgents(ctx context.Context) ([]AgentInfo, error)
// GetAgent returns details for a specific agent.
GetAgent(ctx context.Context, id string) (*AgentInfo, error)
// CreateAgent creates a new agent configuration.
CreateAgent(ctx context.Context, req *CreateAgentRequest) (*AgentInfo, error)
// UpdateAgent updates an existing agent configuration.
UpdateAgent(ctx context.Context, id string, req *UpdateAgentRequest) (*AgentInfo, error)
// DeleteAgent removes an agent.
DeleteAgent(ctx context.Context, id string) error
// CloneAgent duplicates an existing agent.
CloneAgent(ctx context.Context, id string, req *CloneAgentRequest) (*AgentInfo, error)
}
AgentManager is an optional interface for managing multiple agents. Adapters that support multi-agent can implement this interface.
type AgentUsage ¶
type AgentUsage struct {
AgentID string `json:"agent_id"`
Requests int64 `json:"requests"`
PromptTokens int64 `json:"prompt_tokens"`
CompletionTokens int64 `json:"completion_tokens"`
TotalTokens int64 `json:"total_tokens"`
Cost float64 `json:"cost"`
}
AgentUsage tracks usage per agent.
type ChatCompletionChunk ¶
type ChatCompletionChunk struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []ChunkChoice `json:"choices"`
Usage *Usage `json:"usage,omitempty"`
SystemFingerprint string `json:"system_fingerprint,omitempty"`
}
ChatCompletionChunk represents a streaming chunk.
type ChatCompletionRequest ¶
type ChatCompletionRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
N *int `json:"n,omitempty"`
Stream bool `json:"stream,omitempty"`
Stop []string `json:"stop,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
User string `json:"user,omitempty"`
Tools []Tool `json:"tools,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
Seed *int `json:"seed,omitempty"`
}
ChatCompletionRequest represents a chat completion request.
type ChatCompletionResponse ¶
type ChatCompletionResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []Choice `json:"choices"`
Usage *Usage `json:"usage,omitempty"`
SystemFingerprint string `json:"system_fingerprint,omitempty"`
}
ChatCompletionResponse represents a non-streaming chat completion response.
type Choice ¶
type Choice struct {
Index int `json:"index"`
Message Message `json:"message"`
FinishReason string `json:"finish_reason"`
Logprobs any `json:"logprobs,omitempty"`
}
Choice represents a completion choice.
type ChunkChoice ¶
type ChunkChoice struct {
Index int `json:"index"`
Delta ChunkDelta `json:"delta"`
FinishReason *string `json:"finish_reason"`
Logprobs any `json:"logprobs,omitempty"`
}
ChunkChoice represents a choice in a streaming chunk.
type ChunkDelta ¶
type ChunkDelta struct {
Role string `json:"role,omitempty"`
Content string `json:"content,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
}
ChunkDelta represents the delta content in a streaming chunk.
type CloneAgentRequest ¶
type CloneAgentRequest struct {
NewID string `json:"new_id,omitempty"`
NewName string `json:"new_name"`
}
CloneAgentRequest represents a request to clone an agent.
type Config ¶
type Config struct {
// APIKeys is a list of valid API keys. If empty, no authentication is required.
APIKeys []string
// OpenAIPrefix is the URL prefix for OpenAI-compatible routes (default: "/openai/v1").
OpenAIPrefix string
// APIPrefix is the URL prefix for OmniAgent API routes (default: "/api").
APIPrefix string
// WebUI enables the embedded chat web UI at the root path.
WebUI bool
// PhoneNumber is the phone number to display in the web UI for voice calls.
PhoneNumber string
// Auth holds OAuth authentication configuration for the web UI.
Auth *auth.Config
// AAuth holds AAuth token validation configuration.
// Deprecated: Use AgentAuth for unified ID-JAG and AAuth support.
AAuth *auth.AAuthConfig
// AgentAuth holds agent authentication configuration for both ID-JAG and AAuth.
// This enables policy-based routing: ID-JAG for automatic auth, AAuth for sensitive actions.
AgentAuth *auth.AgentAuthConfig
// BaseURL is the public URL of the server (required for OAuth callbacks).
BaseURL string
// Logger is the logger for the server.
Logger *slog.Logger
}
Config configures the server.
type CreateAgentRequest ¶
type CreateAgentRequest struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
APIKey string `json:"api_key,omitempty"` //nolint:gosec // G101: API key in request
BaseURL string `json:"base_url,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
SystemPrompt string `json:"system_prompt,omitempty"`
AllowedTools []string `json:"allowed_tools,omitempty"`
DeniedTools []string `json:"denied_tools,omitempty"`
}
CreateAgentRequest represents a request to create an agent.
type CreateCronJobRequest ¶
type CreateCronJobRequest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Schedule CronScheduleInfo `json:"schedule"`
Action CronActionInfo `json:"action"`
}
CreateCronJobRequest represents a request to create a scheduled job.
type CronActionInfo ¶
type CronActionInfo struct {
Type string `json:"type"`
SessionID string `json:"session_id,omitempty"`
Message string `json:"message,omitempty"`
WebhookURL string `json:"webhook_url,omitempty"`
WebhookMethod string `json:"webhook_method,omitempty"`
WebhookHeaders map[string]string `json:"webhook_headers,omitempty"`
WebhookBody string `json:"webhook_body,omitempty"`
ToolName string `json:"tool_name,omitempty"`
ToolParams map[string]any `json:"tool_params,omitempty"`
}
CronActionInfo represents job action information.
type CronJobInfo ¶
type CronJobInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Schedule CronScheduleInfo `json:"schedule"`
Action CronActionInfo `json:"action"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
LastRunAt *time.Time `json:"last_run_at,omitempty"`
NextRunAt *time.Time `json:"next_run_at,omitempty"`
RunCount int64 `json:"run_count"`
LastError string `json:"last_error,omitempty"`
}
CronJobInfo represents information about a scheduled job.
type CronJobResult ¶
type CronJobResult struct {
Success bool `json:"success"`
Output any `json:"output,omitempty"`
Error string `json:"error,omitempty"`
Duration string `json:"duration"`
StartedAt string `json:"started_at"`
}
CronJobResult represents the result of triggering a job.
type CronScheduleInfo ¶
type CronScheduleInfo struct {
Cron string `json:"cron,omitempty"`
Once string `json:"once,omitempty"` // RFC3339 timestamp
Interval string `json:"interval,omitempty"`
}
CronScheduleInfo represents job schedule information.
type Error ¶
type Error struct {
Message string `json:"message"`
Type string `json:"type"`
Param *string `json:"param,omitempty"`
Code *string `json:"code,omitempty"`
}
Error represents an API error.
type ErrorResponse ¶
type ErrorResponse struct {
Error Error `json:"error"`
}
ErrorResponse wraps an error in the standard format.
type Function ¶
type Function struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Parameters map[string]interface{} `json:"parameters,omitempty"`
Strict bool `json:"strict,omitempty"`
}
Function represents a function definition.
type FunctionCall ¶
FunctionCall represents a function call within a tool call.
type MemoryCollection ¶
type MemoryCollection struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Count int `json:"count"`
}
MemoryCollection represents a memory collection.
type MemoryHandler ¶
type MemoryHandler interface {
// ListMemories returns memories from a collection.
ListMemories(ctx context.Context, collection string, limit int) ([]MemoryRecord, error)
// SearchMemories performs semantic search on memories.
SearchMemories(ctx context.Context, collection, query string, limit int) ([]MemorySearchResult, error)
// StoreMemory stores a new memory.
StoreMemory(ctx context.Context, req *StoreMemoryRequest) (*MemoryRecord, error)
// DeleteMemory deletes a memory by key.
DeleteMemory(ctx context.Context, collection, key string) error
// ListCollections returns all memory collections.
ListCollections(ctx context.Context) ([]MemoryCollection, error)
}
MemoryHandler is an optional interface for semantic memory operations. Adapters that support memory can implement this interface.
type MemoryRecord ¶
type MemoryRecord struct {
Key string `json:"key"`
Content string `json:"content"`
Collection string `json:"collection"`
Metadata map[string]string `json:"metadata,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
MemoryRecord represents a stored memory.
type MemorySearchResult ¶
type MemorySearchResult struct {
MemoryRecord
Score float64 `json:"score"`
}
MemorySearchResult represents a memory search result with score.
type Message ¶
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
Name string `json:"name,omitempty"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
}
Message represents a chat message.
type Model ¶
type Model struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
OwnedBy string `json:"owned_by"`
}
Model represents an available model.
type ModelPricing ¶
ModelPricing defines token costs per model.
type ModelUsage ¶
type ModelUsage struct {
Model string `json:"model"`
Requests int64 `json:"requests"`
PromptTokens int64 `json:"prompt_tokens"`
CompletionTokens int64 `json:"completion_tokens"`
TotalTokens int64 `json:"total_tokens"`
Cost float64 `json:"cost"`
}
ModelUsage tracks usage per model.
type Option ¶
type Option func(*Config)
Option configures the server.
func WithAAuth ¶
func WithAAuth(cfg *auth.AAuthConfig) Option
WithAAuth sets the AAuth token validation configuration. Deprecated: Use WithAgentAuth for unified ID-JAG and AAuth support.
func WithAPIPrefix ¶
WithAPIPrefix sets the URL prefix for OmniAgent API endpoints.
func WithAgentAuth ¶
func WithAgentAuth(cfg *auth.AgentAuthConfig) Option
WithAgentAuth sets the agent authentication configuration. This enables both ID-JAG (automatic) and AAuth (human consent) token validation with policy-based routing based on action sensitivity.
func WithBaseURL ¶
WithBaseURL sets the public URL of the server for OAuth callbacks.
func WithLogger ¶
WithLogger sets the logger for the server.
func WithOpenAIPrefix ¶
WithOpenAIPrefix sets the URL prefix for OpenAI-compatible endpoints.
func WithPhoneNumber ¶
WithPhoneNumber sets the phone number to display in the web UI.
type SSEWriter ¶
type SSEWriter struct {
// contains filtered or unexported fields
}
SSEWriter wraps http.ResponseWriter for Server-Sent Events.
func NewSSEWriter ¶
func NewSSEWriter(w http.ResponseWriter) (*SSEWriter, error)
NewSSEWriter creates a new SSE writer.
func (*SSEWriter) WriteError ¶
WriteError writes an error as an SSE event.
func (*SSEWriter) WriteEvent ¶
WriteEvent writes an SSE event with JSON data.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps the ogen-generated server with Chi router and Huma API.
func New ¶
func New(handler AgentHandler, opts ...Option) (*Server, error)
New creates a new OpenAI-compatible API server.
func (*Server) GetMergedSpec ¶
GetMergedSpec returns the merged OpenAPI specification. This combines the ogen spec (OpenAI-compatible endpoints) with the Huma-generated spec (OmniAgent extension endpoints).
func (*Server) ListenAndServe ¶
ListenAndServe starts the HTTP server with appropriate timeouts.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.
func (*Server) UsageStore ¶
func (s *Server) UsageStore() *UsageStore
UsageStore returns the server's usage store for external recording.
type StoreMemoryRequest ¶
type StoreMemoryRequest struct {
Content string `json:"content"`
Key string `json:"key,omitempty"`
Collection string `json:"collection,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
StoreMemoryRequest represents a request to store a memory.
type StreamingHandler ¶
type StreamingHandler struct {
// contains filtered or unexported fields
}
StreamingHandler creates an HTTP handler that supports both streaming and non-streaming requests. This is used to bypass ogen's limitations with SSE.
func NewStreamingHandler ¶
func NewStreamingHandler(agent AgentHandler, ogenHandler http.Handler) *StreamingHandler
NewStreamingHandler creates a new streaming handler.
func (*StreamingHandler) ServeHTTP ¶
func (h *StreamingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.
func (*StreamingHandler) SetUsageStore ¶
func (h *StreamingHandler) SetUsageStore(store *UsageStore)
SetUsageStore sets the usage store for tracking.
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function FunctionCall `json:"function"`
}
ToolCall represents a tool/function call.
type ToolInfo ¶
type ToolInfo struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters map[string]interface{} `json:"parameters,omitempty"`
Category string `json:"category,omitempty"`
}
ToolInfo represents information about an available tool.
type UpdateAgentRequest ¶
type UpdateAgentRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Provider *string `json:"provider,omitempty"`
Model *string `json:"model,omitempty"`
APIKey *string `json:"api_key,omitempty"` //nolint:gosec // G101: API key in request
BaseURL *string `json:"base_url,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
SystemPrompt *string `json:"system_prompt,omitempty"`
AllowedTools []string `json:"allowed_tools,omitempty"`
DeniedTools []string `json:"denied_tools,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
}
UpdateAgentRequest represents a request to update an agent.
type UpdateCronJobRequest ¶
type UpdateCronJobRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Schedule *CronScheduleInfo `json:"schedule,omitempty"`
Action *CronActionInfo `json:"action,omitempty"`
}
UpdateCronJobRequest represents a request to update a scheduled job.
type Usage ¶
type Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
}
Usage represents token usage statistics.
type UsageBucket ¶
type UsageBucket struct {
Timestamp time.Time `json:"timestamp"`
Requests int64 `json:"requests"`
PromptTokens int64 `json:"prompt_tokens"`
CompletionTokens int64 `json:"completion_tokens"`
TotalTokens int64 `json:"total_tokens"`
Cost float64 `json:"cost"`
}
UsageBucket represents usage for a single time bucket.
type UsageHandler ¶
type UsageHandler interface {
// GetUsageSummary returns aggregated usage statistics.
GetUsageSummary(ctx context.Context, since, until time.Time) (*UsageSummary, error)
// GetUsageTimeseries returns time-bucketed usage data.
GetUsageTimeseries(ctx context.Context, since, until time.Time, interval string) (*UsageTimeseries, error)
// GetUsageRecords returns recent usage records.
GetUsageRecords(ctx context.Context, limit int) ([]UsageRecord, error)
// RecordUsage records a usage event.
RecordUsage(record UsageRecord)
}
UsageHandler is an optional interface for usage tracking. Adapters that support usage tracking can implement this interface.
type UsageRecord ¶
type UsageRecord struct {
ID string `json:"id"`
Timestamp time.Time `json:"timestamp"`
Model string `json:"model"`
AgentID string `json:"agent_id,omitempty"`
SessionID string `json:"session_id,omitempty"`
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
Cost float64 `json:"cost"`
Latency int64 `json:"latency_ms"`
}
UsageRecord represents a single usage event.
type UsageStore ¶
type UsageStore struct {
// contains filtered or unexported fields
}
UsageStore stores usage records in memory.
func NewUsageStore ¶
func NewUsageStore(maxSize int) *UsageStore
NewUsageStore creates a new usage store.
func (*UsageStore) GetRecords ¶
func (s *UsageStore) GetRecords(limit int) []UsageRecord
GetRecords returns recent usage records.
func (*UsageStore) GetSummary ¶
func (s *UsageStore) GetSummary(since, until time.Time) *UsageSummary
GetSummary returns aggregated usage statistics.
func (*UsageStore) GetTimeseries ¶
func (s *UsageStore) GetTimeseries(since, until time.Time, interval string) *UsageTimeseries
GetTimeseries returns time-bucketed usage data.
type UsageSummary ¶
type UsageSummary struct {
TotalRequests int64 `json:"total_requests"`
TotalPromptTokens int64 `json:"total_prompt_tokens"`
TotalCompTokens int64 `json:"total_completion_tokens"`
TotalTokens int64 `json:"total_tokens"`
TotalCost float64 `json:"total_cost"`
AvgLatency float64 `json:"avg_latency_ms"`
ByModel map[string]*ModelUsage `json:"by_model"`
ByAgent map[string]*AgentUsage `json:"by_agent"`
PeriodStart time.Time `json:"period_start"`
PeriodEnd time.Time `json:"period_end"`
}
UsageSummary provides aggregated usage statistics.
type UsageTimeseries ¶
type UsageTimeseries struct {
Interval string `json:"interval"` // "hour", "day"
Buckets []UsageBucket `json:"buckets"`
}
UsageTimeseries represents time-bucketed usage data.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package auth provides OAuth 2.0 authentication for the OmniAgent web UI.
|
Package auth provides OAuth 2.0 authentication for the OmniAgent web UI. |
|
internal
|
|
|
ogen
Code generated by ogen, DO NOT EDIT.
|
Code generated by ogen, DO NOT EDIT. |
|
Package operations provides Huma-compatible request/response types and operation registrations.
|
Package operations provides Huma-compatible request/response types and operation registrations. |
|
Package web provides embedded web assets for the OpenAI-compatible API server.
|
Package web provides embedded web assets for the OpenAI-compatible API server. |