# `PhoenixKit.Modules.AI.Endpoint`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/modules/ai/endpoint.ex#L1)

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 key
- `base_url`: Optional custom base URL for the provider
- `provider_settings`: Provider-specific settings (JSON)
  - For OpenRouter: `http_referer`, `x_title` headers

### 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 parameter
- `frequency_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 active
- `sort_order`: Display order for listing
- `last_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.uuid, "Hello!")

# `changeset`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/modules/ai/endpoint.ex#L156)

Creates a changeset for endpoint creation and updates.

# `default_base_url`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/modules/ai/endpoint.ex#L221)

Returns the default base URL for a provider.

# `image_quality_options`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/modules/ai/endpoint.ex#L282)

Returns image quality options for form selects.

# `image_size_options`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/modules/ai/endpoint.ex#L271)

Returns image size options for form selects.

# `masked_api_key`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/modules/ai/endpoint.ex#L227)

Masks the API key for display, showing only the last 4 characters.

# `provider_label`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/modules/ai/endpoint.ex#L240)

Returns a display label for the provider.

# `provider_options`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/modules/ai/endpoint.ex#L212)

Returns provider options for form selects.

# `reasoning_effort_options`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/modules/ai/endpoint.ex#L292)

Returns reasoning effort options for form selects.

# `recently_validated?`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/modules/ai/endpoint.ex#L246)

Checks if the endpoint has been validated recently (within the last 24 hours).

# `short_model_name`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/modules/ai/endpoint.ex#L258)

Extracts the model name without the provider prefix.

# `valid_providers`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/modules/ai/endpoint.ex#L207)

Returns the list of valid provider types.

# `validation_changeset`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/modules/ai/endpoint.ex#L200)

Creates a changeset for updating the last_validated_at timestamp.

---

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