AI endpoint schema for PhoenixKit AI system.
An endpoint is a unified configuration that combines provider credentials, model selection, and generation parameters into a single entity. Each endpoint represents one complete AI configuration ready for making API requests.
Schema Fields
Identity
name: Display name for the endpoint (e.g., "Claude Fast", "GPT-4 Creative")description: Optional description of the endpoint's purpose
Provider Configuration
provider: Provider type (currently "openrouter")api_key: Provider API keybase_url: Optional custom base URL for the providerprovider_settings: Provider-specific settings (JSON)- For OpenRouter:
http_referer,x_titleheaders
- For OpenRouter:
Model Configuration
model: AI model identifier (e.g., "anthropic/claude-3-haiku")
Generation Parameters
temperature: Sampling temperature (0-2, default: 0.7)max_tokens: Maximum tokens to generate (nil = model default)top_p: Nucleus sampling threshold (0-1)top_k: Top-k sampling parameterfrequency_penalty: Frequency penalty (-2 to 2)presence_penalty: Presence penalty (-2 to 2)repetition_penalty: Repetition penalty (0-2)stop: Stop sequences (array of strings)seed: Random seed for reproducibility
Image Generation Parameters
image_size: Image size (e.g., "1024x1024", "1792x1024")image_quality: Image quality ("standard", "hd")
Embeddings Parameters
dimensions: Embedding dimensions (model-specific)
Status
enabled: Whether the endpoint is activesort_order: Display order for listinglast_validated_at: Last successful API key validation
Usage Examples
# Create an endpoint
{:ok, endpoint} = PhoenixKit.Modules.AI.create_endpoint(%{
name: "Claude Fast",
provider: "openrouter",
api_key: "sk-or-v1-...",
model: "anthropic/claude-3-haiku",
temperature: 0.7
})
# Use the endpoint
{:ok, response} = PhoenixKit.Modules.AI.ask(endpoint.id, "Hello!")
Summary
Functions
Creates a changeset for endpoint creation and updates.
Returns the default base URL for a provider.
Returns image quality options for form selects.
Returns image size options for form selects.
Masks the API key for display, showing only the last 4 characters.
Returns a display label for the provider.
Returns provider options for form selects.
Returns reasoning effort options for form selects.
Checks if the endpoint has been validated recently (within the last 24 hours).
Extracts the model name without the provider prefix.
Returns the list of valid provider types.
Creates a changeset for updating the last_validated_at timestamp.
Functions
Creates a changeset for endpoint creation and updates.
Returns the default base URL for a provider.
Returns image quality options for form selects.
Returns image size options for form selects.
Masks the API key for display, showing only the last 4 characters.
Returns a display label for the provider.
Returns provider options for form selects.
Returns reasoning effort options for form selects.
Checks if the endpoint has been validated recently (within the last 24 hours).
Extracts the model name without the provider prefix.
Returns the list of valid provider types.
Creates a changeset for updating the last_validated_at timestamp.