Credit-Based API Documentation

Generate images using prepaid credits with API key authentication. Great for production, teams, and predictable billing.

Authentication

All credit-based API endpoints require authentication using a Bearer token in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Get your API key by purchasing credits.

Endpoints

GET /credits/balance

Check your current credit balance.

curl -X GET \
  'https://imference.com/credits/balance' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Response:

{"credits": 100}
POST /image/generate

Generate an image using 5 credits. Returns a request_id for status polling.

curl -X POST \
  'https://imference.com/image/generate' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "illustrious-hassuka-xl",
    "prompt": "A cat astronaut floating in space"
  }'

Request Body:

  • model (required) - Model code (e.g., "illustrious-hassuka-xl")
  • prompt (required) - Text description of the image

Response:

{"request_id": "abc123..."}
GET /image/status

Check the status of an image generation request.

curl -X GET \
  'https://imference.com/image/status?request_id=YOUR_REQUEST_ID' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Response (when ready):

{
  "data": {
    "RequestID": "abc123...",
    "URL": "https://blob.imference.com/large/uuid.webp",
    "Format": "webp",
    "Seed": 12345,
    "Timestamp": "2024-01-15T10:30:00Z"
  }
}
GET /image/all

Get all images generated with your API key.

curl -X GET \
  'https://imference.com/image/all' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Rate Limits

50 requests per minute per API key.

If you exceed this limit, you'll receive a 429 Too Many Requests response.

Error Responses

The API returns standard HTTP status codes. Error responses include a JSON body with an error field.

Status Meaning Common Cause
400 Bad Request Missing or invalid fields (e.g. no prompt, unknown model)
401 Unauthorized Missing or invalid API key
402 Payment Required Insufficient credits for the requested generation
404 Not Found Invalid endpoint or request_id not found
429 Too Many Requests Rate limit exceeded (50 req/min)
500 Internal Server Error Server-side error — retry or contact support

Example error response:

{"error": "insufficient credits"}