Quickstart

API calls

A complete call has five steps. Steps 2 and 3 are free; only execution reserves and charges credits.

  1. Create a connection key and authorize a source.
  2. Discover sources with GET /api/v1/capabilities/credits.estimate/targets; add ?capability_key=image.generate or ?capability_key=video.generate to have the server return only that capability's sources.
  3. Optionally estimate the cost with POST /api/v1/capabilities/credits.estimate/estimates.
  4. Quote the exact request, then submit it.
  5. Poll your own task and read the result.
BASH
curl -s https://api.anycap.io/v1/chat/completions \  -H "Authorization: Bearer $ANYCAP_API_KEY" \  -H "Content-Type: application/json" \  -H "Idempotency-Key: $OPERATION_ID" \  -H "X-Anycap-Source: $SOURCE_ID" \  -d '{"model":"<model>","messages":[{"role":"user","content":"Say hello in one sentence."}],"max_tokens":32,"stream":false}'
Persist the idempotency key before submitting. A timeout or a missing response does not prove failure: read the task again instead of submitting a new one.