Introduction
HyperGen provides an OpenAI-compatible HTTP API for image generation. This allows you to:- Generate images via REST API calls
- Integrate with OpenAI client libraries
- Deploy as a scalable service
- Use familiar OpenAI API patterns
Starting the Server
Start the HyperGen API server using the CLI:Server Options
Example
Authentication
API Key
If you start the server with--api-key, all requests must include the API key in the Authorization header.
Error Responses
Base URL
When running locally, the default base URL is:/v1 to match OpenAI’s API structure:
Endpoints
HyperGen provides the following API endpoints:POST /v1/images/generations
Generate images from text prompts (OpenAI-compatible)
GET /v1/models
List available models (OpenAI-compatible)
GET /health
Health check endpoint for monitoring
OpenAI Compatibility
HyperGen’s HTTP API is designed to be compatible with OpenAI’s image generation API. This means:- Drop-in Replacement: Use HyperGen as a replacement for OpenAI’s DALL-E API
- Same Request Format: Request and response formats match OpenAI’s spec
- Client Library Support: Works with OpenAI’s official client libraries
Using OpenAI Python Library
Using OpenAI Node.js Library
HyperGen Extensions
While maintaining OpenAI compatibility, HyperGen adds several extensions:Extended Parameters
Example with Extensions
Error Handling
The API uses standard HTTP status codes:Error Response Format
All errors return a JSON response:Rate Limiting
HyperGen uses a request queue system:- Maximum queue size: Configurable via
--max-queue-size(default: 100) - Requests beyond the queue size will wait
- Queue status available via
/healthendpoint
Monitor queue size using the
/health endpoint to track server loadBest Practices
Production Deployment
Production Deployment
- Always use
--api-keyfor authentication - Set appropriate
--max-queue-sizebased on expected traffic - Use a reverse proxy (nginx, Caddy) for HTTPS
- Monitor the
/healthendpoint - Run on a GPU-enabled instance
Performance Optimization
Performance Optimization
- Use SDXL Turbo for faster generation (4 steps vs 50)
- Adjust
--max-batch-sizefor throughput vs latency - Use
float16dtype for 2x speed improvement - Keep queue size reasonable to avoid memory issues
Development
Development
- Run without
--api-keyfor easier testing - Use
--reloadflag for auto-restart on code changes - Monitor logs for debugging
- Test with
/healthendpoint first
Next Steps
Generate Images
Learn about the image generation endpoint
List Models
Query available models
Health Checks
Monitor server health and status