mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
135 lines
6.5 KiB
SQL
135 lines
6.5 KiB
SQL
-- Generated by aether-data-schema from schema/logical/*.toml.
|
|
-- Do not edit generated files directly; edit logical schema or explicit overrides instead.
|
|
|
|
CREATE TABLE IF NOT EXISTS public.usage (
|
|
request_id character varying(128) NOT NULL,
|
|
id character varying(128),
|
|
user_id character varying(64),
|
|
api_key_id character varying(64),
|
|
provider_name character varying(255) DEFAULT 'unknown' NOT NULL,
|
|
model character varying(255) DEFAULT 'unknown' NOT NULL,
|
|
target_model character varying(255),
|
|
provider_id character varying(64),
|
|
provider_endpoint_id character varying(64),
|
|
provider_api_key_id character varying(64),
|
|
request_type character varying(64),
|
|
api_format character varying(64),
|
|
api_family character varying(64),
|
|
endpoint_kind character varying(64),
|
|
endpoint_api_format character varying(64),
|
|
provider_api_family character varying(64),
|
|
provider_endpoint_kind character varying(64),
|
|
has_format_conversion boolean DEFAULT false NOT NULL,
|
|
is_stream boolean DEFAULT false NOT NULL,
|
|
upstream_is_stream boolean,
|
|
input_tokens bigint DEFAULT 0 NOT NULL,
|
|
output_tokens bigint DEFAULT 0 NOT NULL,
|
|
input_output_total_tokens bigint DEFAULT 0 NOT NULL,
|
|
total_tokens bigint DEFAULT 0 NOT NULL,
|
|
cache_creation_input_tokens bigint DEFAULT 0 NOT NULL,
|
|
cache_creation_input_tokens_5m bigint DEFAULT 0 NOT NULL,
|
|
cache_creation_input_tokens_1h bigint DEFAULT 0 NOT NULL,
|
|
cache_creation_ephemeral_5m_input_tokens bigint DEFAULT 0 NOT NULL,
|
|
cache_creation_ephemeral_1h_input_tokens bigint DEFAULT 0 NOT NULL,
|
|
cache_read_input_tokens bigint DEFAULT 0 NOT NULL,
|
|
input_context_tokens bigint DEFAULT 0 NOT NULL,
|
|
input_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
output_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
cache_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
cache_creation_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
cache_creation_cost_usd_5m double precision DEFAULT 0 NOT NULL,
|
|
cache_creation_cost_usd_1h double precision DEFAULT 0 NOT NULL,
|
|
cache_read_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
request_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
actual_input_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
actual_output_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
actual_cache_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
actual_cache_creation_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
actual_cache_creation_cost_usd_5m double precision DEFAULT 0 NOT NULL,
|
|
actual_cache_creation_cost_usd_1h double precision DEFAULT 0 NOT NULL,
|
|
actual_cache_read_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
actual_request_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
rate_multiplier double precision DEFAULT 1 NOT NULL,
|
|
input_price_per_1m double precision,
|
|
output_price_per_1m double precision,
|
|
cache_creation_price_per_1m double precision,
|
|
cache_creation_price_per_1m_5m double precision,
|
|
cache_creation_price_per_1m_1h double precision,
|
|
cache_read_price_per_1m double precision,
|
|
price_per_request double precision,
|
|
status_code integer,
|
|
error_message text,
|
|
error_category character varying(255),
|
|
response_time_ms bigint,
|
|
first_byte_time_ms bigint,
|
|
wallet_id character varying(64),
|
|
status character varying(64) DEFAULT 'completed' NOT NULL,
|
|
billing_status character varying(64) DEFAULT 'pending' NOT NULL,
|
|
total_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
actual_total_cost_usd double precision DEFAULT 0 NOT NULL,
|
|
request_headers jsonb,
|
|
request_body jsonb,
|
|
provider_request_headers jsonb,
|
|
provider_request_body jsonb,
|
|
response_headers jsonb,
|
|
response_body jsonb,
|
|
client_response_headers jsonb,
|
|
client_response_body jsonb,
|
|
request_body_compressed bytea,
|
|
provider_request_body_compressed bytea,
|
|
response_body_compressed bytea,
|
|
client_response_body_compressed bytea,
|
|
request_metadata jsonb,
|
|
created_at bigint,
|
|
candidate_id character varying(128),
|
|
candidate_index bigint,
|
|
key_name character varying(255),
|
|
username character varying(255),
|
|
api_key_name character varying(255),
|
|
planner_kind character varying(64),
|
|
route_family character varying(128),
|
|
route_kind character varying(128),
|
|
execution_path character varying(128),
|
|
local_execution_runtime_miss_reason character varying(255),
|
|
wallet_balance_before double precision,
|
|
wallet_balance_after double precision,
|
|
wallet_recharge_balance_before double precision,
|
|
wallet_recharge_balance_after double precision,
|
|
wallet_gift_balance_before double precision,
|
|
wallet_gift_balance_after double precision,
|
|
finalized_at bigint,
|
|
created_at_unix_ms bigint DEFAULT 0 NOT NULL,
|
|
updated_at_unix_secs bigint DEFAULT 0 NOT NULL
|
|
);
|
|
|
|
ALTER TABLE ONLY public.usage ADD CONSTRAINT usage_pkey PRIMARY KEY (request_id);
|
|
CREATE INDEX IF NOT EXISTS usage_api_key_id_idx ON public.usage USING btree (api_key_id);
|
|
CREATE INDEX IF NOT EXISTS usage_billing_status_idx ON public.usage USING btree (billing_status);
|
|
CREATE INDEX IF NOT EXISTS usage_created_at_idx ON public.usage USING btree (created_at_unix_ms);
|
|
CREATE INDEX IF NOT EXISTS usage_provider_api_key_id_idx ON public.usage USING btree (provider_api_key_id);
|
|
CREATE INDEX IF NOT EXISTS usage_provider_id_idx ON public.usage USING btree (provider_id);
|
|
CREATE INDEX IF NOT EXISTS usage_request_id_idx ON public.usage USING btree (request_id);
|
|
CREATE INDEX IF NOT EXISTS usage_user_id_idx ON public.usage USING btree (user_id);
|
|
CREATE INDEX IF NOT EXISTS usage_wallet_id_idx ON public.usage USING btree (wallet_id);
|
|
|
|
CREATE TABLE IF NOT EXISTS public.usage_settlement_snapshots (
|
|
request_id character varying(128) NOT NULL,
|
|
billing_status character varying(64) NOT NULL,
|
|
wallet_id character varying(64),
|
|
wallet_balance_before double precision,
|
|
wallet_balance_after double precision,
|
|
wallet_recharge_balance_before double precision,
|
|
wallet_recharge_balance_after double precision,
|
|
wallet_gift_balance_before double precision,
|
|
wallet_gift_balance_after double precision,
|
|
provider_monthly_used_usd double precision,
|
|
finalized_at bigint,
|
|
created_at bigint NOT NULL,
|
|
updated_at bigint NOT NULL
|
|
);
|
|
|
|
ALTER TABLE ONLY public.usage_settlement_snapshots ADD CONSTRAINT usage_settlement_snapshots_pkey PRIMARY KEY (request_id);
|
|
CREATE INDEX IF NOT EXISTS usage_settlement_snapshots_billing_status_idx ON public.usage_settlement_snapshots USING btree (billing_status);
|
|
CREATE INDEX IF NOT EXISTS usage_settlement_snapshots_wallet_id_idx ON public.usage_settlement_snapshots USING btree (wallet_id);
|
|
|