scnmnt-image-generation-service v0.1.0
subsystem
capsule://quake0day/[email protected]
Provides core functionality for AI image generation and prompt enhancement. It interacts with an upstream AI API, handles image uploads, task submission, and polling for results, as well as prompt enhancement via streaming.
Owns
- Logic for submitting image generation and editing tasks to an upstream API
- Prompt enhancement logic, including system prompts and streaming responses
- Image size normalization and validation
- Internal HTTP client for upstream API communication
Does not own
- User authentication or authorization
- Quota management (delegated to scnmnt-quota-service)
- API route registration (delegated to scnmnt-api-router)
AI orientation
An agent working on this capsule would focus on integrating with external AI APIs, handling image processing (uploads, proxying), and managing task states. They should be proficient in HTTP client interactions, multipart forms, and streaming responses.
Avoid
- Modifying database schema for quota management
- Implementing frontend UI components
Provides
library:image.Client— Go client for AI image generation and prompt enhancement.http_api:/api/images/generate— Endpoint to submit image generation tasks.http_api:/api/prompts/enhance— Endpoint to enhance user prompts with streaming responses.http_api:/api/images/tasks/:id— Endpoint to fetch the status of an image generation task.http_api:/api/images/tasks/:id/image— Endpoint to proxy generated images.
Requires
library:quota.Storefromscnmnt-quota-service— Used to spend and refund user credits for image generation.env:CHATGPT2API_BASE_URL— Base URL for the upstream AI API.env:CHATGPT2API_API_KEY— API key for authentication with the upstream AI API.env:CHATGPT2API_IMAGE_MODEL— Model identifier for image generation.env:CHATGPT2API_PROMPT_MODEL— Model identifier for prompt enhancement.
Dependencies
Capsules
scnmnt-quota-service>=0.1.0
Invariants (must always hold)
- All requests to the upstream AI API must be authenticated with the provided API key.
- Image generation tasks must correctly deduct quota credits, and refund on failure.
- Prompt enhancement must return a valid stream of text.
Source files (5)
Click any file to view its content; the path on the right shows where the file lands when this capsule is installed.
src/internal/image/client.go→internal/image/client.gosrc/internal/image/client_test.go→internal/image/client_test.gosrc/internal/image/prompt_enhance.go→internal/image/prompt_enhance.gosrc/internal/image/size.go→internal/image/size.gosrc/internal/image/upstream.go→internal/image/upstream.go
Plus capsule.yaml and
install.json.