A GraphQL API service for generating AI images with custom styles, sizes, and formats. Built with FastAPI, Strawberry GraphQL, and Poetry.
# Install dependencies
poetry install
# Start the server
poetry run python app/main.py
# Server runs at http://localhost:8000
# Documentation at http://localhost:8000/docs
# Interactive GraphQL Query Builder (GraphiQL) at http://localhost:8000/graphql
Include your API key in requests:
curl -H "X-API-Key: sk_your_key" http://localhost:8000/
mutation GenerateImages($input: ImageGenerationInput!) {
generateImages(input: {
prompt: "a beautiful sunset"
width: 1024
height: 1024
style: PHOTOREALISTIC
image_format: PNG
numImages: 1
}) {
success
results {
id
url
}
}
}
# Run with auto-reload
poetry run uvicorn app.main:app --reload
# Generate SDKs
graphql-codegen
# Run tests (once implemented)
poetry run pytest
app/
βββ __init__.py
βββ main.py # FastAPI app setup
βββ schema.py # GraphQL Schema - Dynamically loaded from resolvers
βββ types/ # Type files used across resolvers
β βββ enums.py # Enum definitions
β βββ inputs.py # Input types
β βββ responses.py # Response types
β βββ scalars.py # Custom scalars
βββ resolvers/
β βββ queries/ # Query resolvers
β β βββ example-query/
β β βββ example-query.py
β βββ mutations/ # Mutation resolvers
β βββ example-mutation/
β βββ example-mutation.py
βββ services/
βββ auth.py
βββ image_generator.py
SDKs are automatically generated for:
# Required
API_KEY_SECRET=your_secret_key
# Optional
PORT=8000
HOST=0.0.0.0
MIT
We welcome contributions! To add a new model, follow these steps:
git checkout -b feature/add-new-model
@strawberry.enum
class ModelType(Enum):
...
FLUX_1_SCHNELL = "black-forest-labs/FLUX.1-schnell"
# Add your model
YOUR_NEW_MODEL = "your-company/URMoDL.1"
cls.register(
ModelType.STABLE_V1_4,
PipelineConfig(
pipeline_class=StableDiffusionPipeline,
default_params={"safety_checker": None},
inference_params={"num_inference_steps": 50},
),
)
app/schema.py to include your model in the GraphQL schema.app/resolvers/ to handle queries and mutations for your model.tests/ directory.git add .
git commit -m "Add new model"
git push origin add-new-model
master.Thank you for contributing!
126 commits
5 commits
Python
92.8%
HTML
5.4%
Shell
1.7%
A GraphQL API service for generating AI images with custom styles, sizes, and formats. Built with FastAPI, Strawberry GraphQL, and Poetry.
# Install dependencies
poetry install
# Start the server
poetry run python app/main.py
# Server runs at http://localhost:8000
# Documentation at http://localhost:8000/docs
# Interactive GraphQL Query Builder (GraphiQL) at http://localhost:8000/graphql
Include your API key in requests:
curl -H "X-API-Key: sk_your_key" http://localhost:8000/
mutation GenerateImages($input: ImageGenerationInput!) {
generateImages(input: {
prompt: "a beautiful sunset"
width: 1024
height: 1024
style: PHOTOREALISTIC
image_format: PNG
numImages: 1
}) {
success
results {
id
url
}
}
}
# Run with auto-reload
poetry run uvicorn app.main:app --reload
# Generate SDKs
graphql-codegen
# Run tests (once implemented)
poetry run pytest
app/
βββ __init__.py
βββ main.py # FastAPI app setup
βββ schema.py # GraphQL Schema - Dynamically loaded from resolvers
βββ types/ # Type files used across resolvers
β βββ enums.py # Enum definitions
β βββ inputs.py # Input types
β βββ responses.py # Response types
β βββ scalars.py # Custom scalars
βββ resolvers/
β βββ queries/ # Query resolvers
β β βββ example-query/
β β βββ example-query.py
β βββ mutations/ # Mutation resolvers
β βββ example-mutation/
β βββ example-mutation.py
βββ services/
βββ auth.py
βββ image_generator.py
SDKs are automatically generated for:
# Required
API_KEY_SECRET=your_secret_key
# Optional
PORT=8000
HOST=0.0.0.0
MIT
We welcome contributions! To add a new model, follow these steps:
git checkout -b feature/add-new-model
@strawberry.enum
class ModelType(Enum):
...
FLUX_1_SCHNELL = "black-forest-labs/FLUX.1-schnell"
# Add your model
YOUR_NEW_MODEL = "your-company/URMoDL.1"
cls.register(
ModelType.STABLE_V1_4,
PipelineConfig(
pipeline_class=StableDiffusionPipeline,
default_params={"safety_checker": None},
inference_params={"num_inference_steps": 50},
),
)
app/schema.py to include your model in the GraphQL schema.app/resolvers/ to handle queries and mutations for your model.tests/ directory.git add .
git commit -m "Add new model"
git push origin add-new-model
master.Thank you for contributing!
126 commits
5 commits
Python
92.8%
HTML
5.4%
Shell
1.7%