Community이미지github.com

aimlapi-images

Use when generating or editing images through AI/ML API (aimlapi): text-to-image, image editing, reference images, logos or product shots, or when an image request is refused for its parameters.

aimlapi-images란 무엇인가요?

aimlapi-images is a Codex agent skill that use when generating or editing images through AI/ML API (aimlapi): text-to-image, image editing, reference images, logos or product shots, or when an image request is refused for its parameters.

지원 대상~Claude Code✓Codex CLI~Cursor
npx skills add https://github.com/aimlapi/skills/tree/HEAD/skills/aimlapi-images

Installed? Explore more 이미지 skills: steipete/songsee, affaan-m/frontend-design, mattpocock/improve-codebase-architecture · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Generate and edit images

Image generation is synchronous: one request, the answer holds the images. The catch is that every image model has its own parameters. FLUX takes image_size and num_images; OpenAI's image models take size and n; others take aspect_ratio or image_urls. Read the schema of the model you call; do not carry parameters over from another model.

When to use

  • "Generate an image of …", "make a logo / thumbnail / product shot"
  • "Edit this image", "put this product on a beach", "combine these two photos"

Steps

1. Pick the model and read its parameters

curl -s 'https://api.aimlapi.com/v1/models?type=openai/image-generations&include=pricing'

Then read the model's info.docsJson for its parameters. With the aimlapi-models skill installed, models.py params flux/schnell prints them. Models of type openai/image-editing also serve POST /v1/images/edits.

2. Generate

curl -sS https://api.aimlapi.com/v1/images/generations \
  -H "Authorization: Bearer $AIMLAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "flux/schnell", "prompt": "A lighthouse at dawn, watercolor", "image_size": "landscape_16_9", "num_images": 1}'
import os
import requests

resp = requests.post(
    "https://api.aimlapi.com/v1/images/generations",
    headers={"Authorization": f"Bearer {os.environ['AIMLAPI_API_KEY']}"},
    json={"model": "flux/schnell", "prompt": "A lighthouse at dawn, watercolor"},
    timeout=900,
)
resp.raise_for_status()
for image in resp.json()["data"]:
    print(image["url"])

Answer:

{
  "data": [{ "url": "https://cdn.aimlapi.com/…/image.png", "b64_json": null }],
  "meta": { "usage": { "credits_used": 7800, "usd_spent": 0.0039 } }
}
  • data[].url is a link to the file; download it if the user needs to keep it, links are not permanent. Some models return b64_json instead or as well; handle both.
  • meta.usage is the cost of this call (aimlapi-costs); the OpenAI SDK keeps it in r.model_extra["meta"].
  • With the OpenAI SDK, client.images.generate(...) works for OpenAI image models. For other models, pass their own fields through extra_body={...} (Python) or call the endpoint over HTTP; n and size are not translated to num_images and image_size.

3. Edit or use reference images

Two ways, depending on the model's schema:

Model schema hasCallHow the image goes in
image_urls, image_url or similar on /v1/images/generationsPOST /v1/images/generationspublic HTTPS URLs (or data URLs where the schema allows)
type openai/image-editingPOST /v1/images/editsa multipart file upload, as with OpenAI: client.images.edit(model=…, image=open("in.png", "rb"), prompt=…)

Rules

  • Send only fields from the model's schema. Unknown fields are dropped silently: the call answers 200 with the defaults (n and size on flux/schnell give one default image). Values outside an enum, or a custom size outside its minimum/maximum (flux/schnell: 64 to 1536 per side), return 400; prefer a preset.
  • Set a client timeout well above a minute; large or high-quality images can take a while. Do not set a short timeout and retry: each retry is a new, billed generation.
  • Store the files you need. Do not hot-link cdn.aimlapi.com URLs from a product page.
  • Do not put an API key in browser code to call this endpoint; proxy through your server.
  • For apps that serve other people, send safety_identifier on every request (see aimlapi-errors § Content policy).

Errors

ResponseMeaningDo
400 "Validation failed", error.details[] names path and reasona value the model does not accept, or a missing required fieldread docsJson, fix that field
400 content_policy_violationthe provider refused the prompt or imagechange the content; do not resend it to another model
403 "You've run out of credits"balance exhaustedthe user tops up
404unknown model, or a generation model on /v1/images/editscheck the model's type
5xx / timeoutprovider failureretry once or twice with backoff; check GET /v2/logs first if you are not sure whether the first call was charged

Check before done

  • Run the request once with "model": "sandbox/<model id>" (free, aimlapi-sandbox): the answer has the live shape with placeholder PNGs.
  • Your code reads data[].url and handles b64_json.
  • Every parameter you send is in the model's schema.

Reference

관련 스킬