Skip to content

AI 0.1.0: AI endpoints, prompts and usage tracking for PhoenixKit

AI 0.1.0 is the first release of the PhoenixKit AI module as its own package. It lets a Phoenix site call AI models through OpenRouter from one place: you set up endpoints and prompts in the admin, your code uses them, and every call is logged with its tokens, cost and time.

In the admin

The module adds an AI section with four pages:

  • Endpoints: each endpoint holds an OpenRouter API key, a model and its generation settings, such as temperature or reasoning effort. The form validates the key and loads the models it can use.
  • Prompts: reusable prompt templates. Words in double curly braces, such as {{Topic}}, are filled in when the prompt is used.
  • Playground: try an endpoint, with or without a prompt, and see the answer.
  • Usage: the request log, with tokens, cost, response time and status for each call.

The module can be turned on and off on the Modules page, and access is given per role.

For developers

Code calls an endpoint with ask/3 for a single question, complete/3 for a conversation, embed/3 for embeddings, and ask_with_prompt/4 to use a saved prompt. Each call is logged automatically.

Installing

Add phoenix_kit_ai to your dependencies and run mix deps.get. The module used to be part of PhoenixKit core; its three tables, for endpoints, prompts and requests, are created with IF NOT EXISTS, so a site that already had them keeps its data. Then turn the module on under Modules.

Full release notes: AI 0.1.0

0.1.0 · 24 March 2026

Added

  • Extract AI module from PhoenixKit into standalone phoenix_kit_ai package
  • Implement PhoenixKit.Module behaviour with all required callbacks
  • Add PhoenixKitAI.Endpoint schema for AI endpoint configurations (provider credentials, model, generation parameters)
  • Add PhoenixKitAI.Prompt schema for reusable prompt templates with {{Variable}} substitution
  • Add PhoenixKitAI.Request schema for request logging (tokens, cost, latency, status)
  • Add PhoenixKitAI.Completion HTTP client for OpenRouter chat completions and embeddings
  • Add PhoenixKitAI.OpenRouterClient for API key validation and model discovery
  • Add admin LiveViews: Endpoints, EndpointForm, Prompts, PromptForm, Playground
  • Add route module with admin_routes/0 and admin_locale_routes/0
  • Add css_sources/0 for Tailwind CSS scanning support
  • Add migration module (v1) with IF NOT EXISTS for all 3 tables (run by parent app)
  • Add behaviour compliance test suite
  • Add prompt unit tests (variable extraction, substitution, validation)

AI 0.1.0. Install or update: {:phoenix_kit_ai, "~> 0.1"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.