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

PhoenixKit V34 Migration: AI Endpoints System

This migration replaces the Accounts + Slots architecture with a unified
Endpoints system where each endpoint contains credentials, model selection,
and generation parameters in a single entity.

## Architecture Change

### Before (V32)
- **Accounts Table**: Provider credentials only
- **Slots**: Stored in Settings as JSON (4 types × 3 slots each)
- Slots referenced account_id for credentials
- Fallback chain: tries slot 0 → 1 → 2

### After (V34)
- **Endpoints Table**: Unified configuration
  - Provider credentials (name, api_key, base_url, provider_settings)
  - Model selection (single model per endpoint)
  - Generation parameters (temperature, max_tokens, etc.)
- No type categorization (user decides endpoint purpose)
- No fallback chain (explicit endpoint targeting)

## Changes

### New Table: phoenix_kit_ai_endpoints
- Unified configuration combining account + slot fields
- All generation parameters in one place
- Sort order for display

### Modified Table: phoenix_kit_ai_requests
- Added endpoint_id for new requests
- Added endpoint_name for denormalized history
- Kept account_id/slot_index for backward compatibility

### Cleanup
- Remove slot Settings entries (ai_text_processing_slots, etc.)
- Keep ai_enabled setting
- Keep accounts table for historical request references

# `down`

Rollback the V34 migration.

# `up`

Run the V34 migration to add the AI Endpoints system.

---

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