Run This Ai
EN DE

Getting Started with Fooocus-API: Docker Setup and First API Calls

A step-by-step tutorial for setting up Fooocus-API with Docker and making your first AI image generation API calls.

Fooocus-API Logo

Getting Started with Fooocus-API: Docker Setup and First API Calls

This tutorial walks through setting up Fooocus-API with Docker and making your first image generation requests.

Prerequisites

  • A machine with an NVIDIA GPU - Fooocus-API requires CUDA
  • Docker installed
  • NVIDIA Container Toolkit for GPU passthrough
  • 16GB+ RAM and 20GB free disk for model downloads

Step 1: Pull and Run the Docker Container

docker run -d --gpus=all \
  -e NVIDIA_DRIVER_CAPABILITIES=compute,utility \
  -e NVIDIA_VISIBLE_DEVICES=all \
  -p 8888:8888 \
  --name fooocus-api \
  konieshadow/fooocus-api:latest

For persistent model caching:

docker run -d --gpus=all \
  -e NVIDIA_DRIVER_CAPABILITIES=compute,utility \
  -e NVIDIA_VISIBLE_DEVICES=all \
  -v ~/repositories:/app/repositories \
  -v ~/.cache/pip:/root/.cache/pip \
  -p 8888:8888 \
  --name fooocus-api \
  konieshadow/fooocus-api:latest

Step 2: Wait for Model Downloads

On first startup, models download automatically (5-15 minutes). Watch logs:

docker logs -f fooocus-api
Fooocus-API Repository

Step 3: Generate Your First Image

curl -X POST "http://localhost:8888/v1/generate" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "a serene mountain lake at sunset, cinematic lighting",
    "width": 1024,
    "height": 1024,
    "guidance_scale": 7,
    "steps": 30
  }'

Poll for completion with your task ID:

curl "http://localhost:8888/v1/generation/result?task_id=YOUR_TASK_ID"

Using Docker Compose

services:
  fooocus-api:
    image: konieshadow/fooocus-api:latest
    restart: unless-stopped
    ports:
      - "8888:8888"
    volumes:
      - ./repositories:/app/repositories
      - ./pip-cache:/root/.cache/pip
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]

Conclusion

Fooocus-API makes it straightforward to integrate professional-quality AI image generation into any application. With Docker, you can be up and running in minutes, generating production-ready images through a clean REST API.

#fooocus #docker #tutorial #image-generation #stable-diffusion