Hugging Face Image Generation API

Text-to-image generation

Operations 1

POST /v1/images/generations Generate Images #

Documentation

Specifications

SDKs

Other Resources

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/hugging-face-image-generation-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

hugging-face-image-generation-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Hugging Face Inference Providers Image Generation API
  description: Unified proxy layer providing access to 15+ inference partners through a single OpenAI-compatible endpoint. Route requests to providers like AWS, Google, Azure, Together, Fireworks, and more through a consistent API with automatic model routing and provider selection.
  version: 1.0.0
  termsOfService: https://huggingface.co/terms-of-service
  contact:
    name: Hugging Face Support
    url: https://huggingface.co/support
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
servers:
- url: https://router.huggingface.co
  description: Hugging Face Inference Providers router
security:
- bearerAuth: []
tags:
- name: Image Generation
  description: Text-to-image generation
paths:
  /v1/images/generations:
    post:
      summary: Generate Images
      description: Generate images from text prompts using diffusion models available through inference providers.
      operationId: createImageGeneration
      tags:
      - Image Generation
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
            examples:
              CreateimagegenerationRequestExample:
                summary: Default createImageGeneration request
                x-microcks-default: true
                value:
                  model: example_value
                  prompt: example_value
                  n: 10
                  size: 256x256
                  response_format: url
                  negative_prompt: example_value
                  num_inference_steps: 10
                  guidance_scale: 42.5
      responses:
        '200':
          description: Generated images
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageGenerationResponse'
              examples:
                Createimagegeneration200Example:
                  summary: Default createImageGeneration 200 response
                  x-microcks-default: true
                  value:
                    created: 10
                    data:
                    - url: https://www.example.com
                      b64_json: example_value
                      revised_prompt: example_value
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Createimagegeneration400Example:
                  summary: Default createImageGeneration 400 response
                  x-microcks-default: true
                  value:
                    error:
                      message: example_value
                      type: example_value
                      code: example_value
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: Error message
            type:
              type: string
              description: Error type
            code:
              type: string
              description: Error code
          example: example_value
    ImageGenerationResponse:
      type: object
      properties:
        created:
          type: integer
          example: 10
        data:
          type: array
          items:
            type: object
            properties:
              url:
                type: string
                format: uri
                description: URL of the generated image
              b64_json:
                type: string
                description: Base64-encoded image data
              revised_prompt:
                type: string
                description: Revised prompt used for generation
          example: []
    ImageGenerationRequest:
      type: object
      required:
      - model
      - prompt
      properties:
        model:
          type: string
          description: Image generation model ID
          example: stabilityai/stable-diffusion-xl-base-1.0
        prompt:
          type: string
          description: Text prompt describing the image to generate
          example: example_value
        n:
          type: integer
          minimum: 1
          maximum: 4
          default: 1
          description: Number of images to generate
          example: 10
        size:
          type: string
          description: Image dimensions
          enum:
          - 256x256
          - 512x512
          - 1024x1024
          default: 1024x1024
          example: 256x256
        response_format:
          type: string
          enum:
          - url
          - b64_json
          default: url
          example: url
        negative_prompt:
          type: string
          description: Negative prompt to guide generation
          example: example_value
        num_inference_steps:
          type: integer
          description: Number of diffusion steps
          example: 10
        guidance_scale:
          type: number
          format: float
          description: Classifier-free guidance scale
          example: 42.5
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: HF Token
      description: Hugging Face API token with Inference Providers permission. Generate from https://huggingface.co/settings/tokens