Skip to main content

Stability AI

Stability AI is available on the Spanway gateway through the stability/ model prefix. You register a Stability AI model once in the gateway's config.yaml (or through the Admin UI), and every application then calls it through the gateway's OpenAI-compatible API with a Spanway virtual key. The provider credential stays on the gateway, and every request is authenticated, rate limited, logged and costed in the same way as any other provider.

The gateway translates requests and responses for Stability AI natively, so provider specific parameters and errors are mapped to the OpenAI format for you.

Supported endpoints​

The gateway's endpoint support matrix lists the following endpoints for Stability AI. Each link explains the request shape and the gateway features that apply to that endpoint.

Model types​

The bundled price map lists 23 Stability AI models across these modes: Image generation, Image edit. The mode decides which gateway endpoint a model is meant for, and it is also used by the gateway's health checks to send the right kind of test request.

Environment variables​

The Stability AI integration reads the following environment variables. Variables marked as required are the ones the gateway's environment validation checks for this provider. You can also pass any of these values directly in spanway_params (for example api_key or api_base), and the per-model value wins over the environment.

VariableRequiredPurpose
STABILITY_API_BASENoOverrides the provider base URL
STABILITY_API_KEYNoCredential the gateway sends to the provider

Reference a variable from config.yaml with the os.environ/ prefix so that the secret never appears in the file itself. Secrets can also come from a secret manager, see secret managers.

Register a model on the gateway​

Add an entry to model_list in config.yaml. The model_name is the public name your applications send, and spanway_params.model tells the gateway which provider and upstream model to call.

model_list:
- model_name: stable-image-ultra
spanway_params:
model: stability/stable-image-ultra
api_key: os.environ/STABILITY_API_KEY

Start the gateway with this file:

spanway --config config.yaml
Private preview

Spanway is in private preview. The container images and Helm charts will be published soon. To request access, write to sales@spanway.ai, and preview customers receive download instructions in their onboarding pack.

To add the model without a restart, call POST /model/new with the same model_name and spanway_params, or use the Models + Endpoints page in the Admin UI. See model management for details.

Call the model through the gateway​

Send requests to the gateway's /v1/images/generations endpoint with a virtual key. The gateway maps the public model name to the Stability AI deployment, translates the request, and returns the response in the OpenAI format.

curl -X POST http://localhost:4000/v1/images/generations \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "stable-image-ultra", "prompt": "A lighthouse at dawn, watercolor", "n": 1}'

The same request works from any OpenAI SDK by setting the base URL to http://localhost:4000 and the API key to a Spanway virtual key. Create keys with POST /key/generate as described in virtual keys.

Models and pricing​

The table lists every Stability AI model in the gateway's bundled price map. Prices are shown in US dollars per 1 million tokens, computed from the per-token values the gateway uses for spend tracking. Context window sizes are the provider limits recorded in the same file. Capabilities are the supports_* flags set for each model.

info

Prices come from the price map bundled with this Spanway build. They are used to calculate the spend recorded for each request, key, team and user. Your negotiated rates may differ, and you can override them per deployment with custom pricing.

Model (model value)ModeMax input tokensMax output tokensInput per 1M tokensOutput per 1M tokensOther pricingCapabilities
stability/conservativeImage edit$0.04 per image
stability/creativeImage edit$0.06 per image
stability/eraseImage edit$0.005 per image
stability/fastImage edit$0.002 per image
stability/inpaintImage edit$0.005 per image
stability/outpaintImage edit$0.004 per image
stability/remove-backgroundImage edit$0.005 per image
stability/replace-background-and-relightImage edit$0.008 per image
stability/sd3Image generation$0.065 per image
stability/sd3-largeImage generation$0.065 per image
stability/sd3-large-turboImage generation$0.04 per image
stability/sd3-mediumImage generation$0.035 per image
stability/sd3.5-largeImage generation$0.065 per image
stability/sd3.5-large-turboImage generation$0.04 per image
stability/sd3.5-mediumImage generation$0.035 per image
stability/search-and-recolorImage edit$0.005 per image
stability/search-and-replaceImage edit$0.005 per image
stability/sketchImage edit$0.005 per image
stability/stable-image-coreImage generation$0.03 per image
stability/stable-image-ultraImage generation$0.08 per image
stability/structureImage edit$0.005 per image
stability/styleImage edit$0.005 per image
stability/style-transferImage edit$0.008 per image