---
name: use-eltex-elixir
description: Generate or edit images and create, monitor, or cancel videos through the ELTEX Elixir API. Use when an agent is asked to create visual media with Elixir, inspect the live media-model catalog or Elixir balance, turn an image into a video, poll a video job, retrieve a generated asset, or cancel an active video generation.
---

# Use ELTEX Elixir

Create media through ELTEX while preventing duplicate paid generations. Use the live catalog instead of guessing model IDs or capabilities. This file is standalone and can be installed directly in a compatible agent.

## Required configuration

Use:

- `ELIXIR_BASE_URL`, defaulting to `https://eltexlabs.com/v1/elixir`
- `ELIXIR_API_KEY`, supplied as `Authorization: Bearer ...`

Never print, log, summarize, persist, or send the API key anywhere except the configured ELTEX origin. Never buy or top up Elixir. If the balance is insufficient, report the required and available amounts to the user.

## Start every generation safely

1. Call `GET /models` immediately before choosing a model because availability, price, duration, and accepted parameters can change.
2. Filter by `media_type`, `operation_type`, and any required video mode or duration. Use the returned `id` or `eltex_model_id`; never invent or rely on an old model ID.
3. Call `GET /balance` and compare `balance_elixir` with the selected model's `elixir_cost`.
4. If the user's request did not clearly authorize a paid generation, show the proposed model and Elixir cost and ask before submitting. A direct request to generate one image or video authorizes one matching generation.
5. Create one stable `Idempotency-Key` for that intended output. Reuse the exact key after a timeout or uncertain response. Use a new key only for a genuinely new output.

Use a key such as `project-42-scene-7-attempt-1`. Keep it at most 128 characters and use only letters, numbers, `.`, `_`, `:`, or `-`.

Use `GET /generations` to inspect up to 50 recent image and video jobs when the user asks for history or when a create response was lost.

## Generate an image

```bash
curl -sS -X POST "$ELIXIR_BASE_URL/images/generations" \
  -H "Authorization: Bearer $ELIXIR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: image-job-001" \
  -d '{"model":"MODEL_ID_FROM_GET_MODELS","prompt":"A cinematic product photo","count":1,"aspect_ratio":"16:9","resolution":"1K","quality":"standard","response_format":"url"}'
```

Image generation is synchronous. Return the generated `data[].url`, or handle `data[].b64_json` when explicitly requested. Do not submit more than one image unless the user requested multiple outputs and the model's `max_count` permits it.

Only send fields listed in the selected model's `accepted_parameters`. Image generation can support `count` or `n`, `size`, `aspect_ratio`, `resolution`, `quality`, `response_format`, and `style` in addition to `model` and `prompt`.

## Edit an image

Use a model whose `operation_type` is `edit`. Supply one of `image`, `image_url`, or `input_images`:

```bash
curl -sS -X POST "$ELIXIR_BASE_URL/images/edits" \
  -H "Authorization: Bearer $ELIXIR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: edit-job-001" \
  -d '{"model":"EDIT_MODEL_ID_FROM_GET_MODELS","prompt":"Make the sky a dramatic sunset","image_url":"https://example.com/source.png","response_format":"url"}'
```

Use only HTTPS URLs or `data:image/...;base64,...` values. `input_images` accepts up to eight entries. Image editing returns one result; do not send `count` or `n`.

## Generate and monitor a video

Use `mode: "t2v"` for text-to-video. Use `mode: "i2v"` plus an image input for image-to-video.

```bash
curl -sS -X POST "$ELIXIR_BASE_URL/video/generations" \
  -H "Authorization: Bearer $ELIXIR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: video-job-001" \
  -d '{"model":"VIDEO_MODEL_ID_FROM_GET_MODELS","mode":"t2v","prompt":"A glowing dashboard in motion","duration_seconds":8,"aspect_ratio":"16:9"}'
```

Video creation is asynchronous. Save `generation_id`, then poll without a tight loop:

```bash
curl -sS "$ELIXIR_BASE_URL/video/generations/GENERATION_ID" \
  -H "Authorization: Bearer $ELIXIR_API_KEY"
```

Poll about every 5-10 seconds until `completed`, `failed_provider`, or `cancelled`. On completion, return `asset_url` and `thumbnail_url` when present. Do not launch a replacement just because polling takes time.

Only send fields listed in `accepted_parameters`. Video models can support `duration` or `duration_seconds`, `image` or `image_url`, `end_image_url`, `input_images`, `resolution`, `aspect_ratio`, `audio`, `webhook_url`, and `metadata` in addition to `model`, `prompt`, and `mode`.

Cancel only when the user asks to stop the active video job:

```bash
curl -sS -X DELETE "$ELIXIR_BASE_URL/video/generations/GENERATION_ID" \
  -H "Authorization: Bearer $ELIXIR_API_KEY"
```

## Failure handling

- `400 INVALID_PARAMETER`: inspect `accepted_parameters` in `GET /models`, correct the payload, and ask again if the correction materially changes cost or output.
- `401` or `403`: stop and request a valid, active Elixir API key.
- `402 INSUFFICIENT_ELIXIR`: stop and report the available balance; never purchase credits.
- `404 GENERATION_NOT_FOUND`: verify the generation belongs to the current key.
- `409` on cancellation: the job is already terminal; fetch its status.
- `429 RATE_LIMITED`: honor `Retry-After` when present and retry the same request with the same idempotency key.
- `502/503 PROVIDER_ERROR`: submission failures are refunded automatically. Do not repeatedly regenerate. Explain the failure and wait for the user to approve a corrected model or new attempt.

When the full skill directory is installed, [references/api.md](references/api.md) provides a compact endpoint and response reference; the workflow above remains sufficient when only this standalone `SKILL.md` is installed.
