# `PhoenixKit.Migrations.Postgres.V32`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.165/lib/phoenix_kit/migrations/postgres/v32.ex#L1)

PhoenixKit V32 Migration: AI System

This migration introduces the AI provider account management and usage tracking system.

## Changes

### AI Accounts Table (phoenix_kit_ai_accounts)
- Store AI provider credentials (OpenRouter, etc.)
- Support multiple accounts per provider
- Optional settings for provider-specific configuration
- API key validation tracking

### AI Requests Table (phoenix_kit_ai_requests)
- Track every AI API request for history and statistics
- Token usage tracking (input, output, total)
- Cost tracking when available
- Latency and status monitoring
- Per-user and per-account tracking

### Settings Seeds
- AI module enable/disable
- Text processing slots configuration (JSON)

## PostgreSQL Support
- Leverages PostgreSQL's native JSONB for flexible metadata
- Supports prefix for schema isolation
- Optimized indexes for common queries

# `down`

Rollback the V32 migration.

# `up`

Run the V32 migration to add the AI system.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
