API Fundamentals
This page explains the fundamental concepts that apply across the FASHN API. Authentication, content delivery, error handling, credits, rate limits, and webhooks work the same for every endpoint, including the FASHN Agent API. The request and response patterns describe the single-task endpoints, which run through /v1/run. The Agent API's own request and response formats are on Agent Images.
Install the FASHN agent skill and Claude Code, Codex, Cursor, or another agent can wire these patterns into your project for you: npx skills add fashn-ai/fashn-skill.
Authentication
All API requests require authentication using a Bearer token in the Authorization header:
You can obtain your API key from the Developer API Dashboard ↗.
Single-Task Request Pattern
All FASHN single-task endpoints follow a consistent request pattern to the same /v1/run endpoint:
Agent Images takes a prompt and images as top-level fields at POST /v1/agent/images (or /v1/agent/images/run with status at /v1/agent/status), instead of a model_name and inputs at /v1/run. It uses the same authentication, credits, and concurrency limits.
Universal Request Properties
model_nameRequiredstring
Specifies which model/endpoint to use for processing. Each endpoint has its own unique model name.
inputsRequiredobject
Contains all the input parameters for the selected model. The structure of this object varies by endpoint.
Single-Task Response Pattern
Initial Response
When you submit a request to /v1/run, you'll receive an immediate response with a prediction ID:
Status Polling
Use the prediction ID to poll for status and results:
GEThttps://api.fashn.ai/v1/status/{id}
Response States
Poll for the status of a specific prediction using its ID.
status'starting' | 'in_queue' | 'processing' | 'completed' | 'failed'
The current state of your prediction:
starting- Prediction is being initializedin_queue- Prediction is waiting to be processedprocessing- Model is actively generating your resultcompleted- Generation finished successfully, output availablefailed- Generation failed, check error details
Response Headers
x-fashn-credits-used: Indicates how many credits were consumed for that prediction.
Example Status Responses
In Progress:
Completed:
- CDN URLs (default): Outputs are scheduled for expiry after three days
- Base64 outputs (when
return_base64: true): Available through the status endpoint for 60 minutes after completion instead of the standard three-day window
Learn more in the Data Retention & Privacy section.
Failed:
Content Delivery
By default, output URLs are served from FASHN's content delivery network. Single-task endpoints return them in the output array, and the FASHN Agent API returns them in each prediction's results.* Depending on routing, outputs may be delivered from either of these domains:
https://cdn.fashn.ai/...https://media.fashn.ai/...
Both are official FASHN delivery domains and are interchangeable. The outputs for a given prediction may be served from either one, and the serving domain can differ between requests. API outputs are scheduled for expiry after three days.
* This applies to the default delivery method. When you setreturn_base64: true, outputs are returned as base64-encoded strings instead of CDN URLs, so no cdn.fashn.ai or media.fashn.ai URL is produced.
Error Handling
At a high level there are two kinds of errors you may see. For detailed guidance and the full list of error codes, see the Error Handling page.
API-Level Errors
These errors return an HTTP error code and a short payload. They can result from authentication, validation, quota, or server failures. Example:
No id or prediction status is returned.
Runtime Errors
These happen during model execution after a prediction ID was returned. You’ll see them when polling /v1/status/{id} with status: "failed". Some runtime errors are common across endpoints (for example, malformed image URLs), while others are endpoint-specific validations; see Error Handling for details. Example:
Credits & Pricing
Credits are the billing unit for all FASHN API endpoints. Pricing is charged per successful output, and the exact cost depends on the endpoint and selected options.
Billing Basics
- Failed predictions do not consume credits.
- Pricing is applied per output. If you request multiple outputs, the per-output cost is multiplied accordingly.
- Depending on the endpoint, pricing may be fixed per output, vary based on parameters such as
resolution,generation_mode, orduration, or include optional surcharges such asface_reference.
Each endpoint page includes its own Credit Cost section. For a centralized overview, see the API pricing guide: Credit Costs ↗.
Rate Limits
These are the default rate limits that apply to all endpoints unless stated otherwise in the specific endpoint documentation:
| Endpoint | Limit |
|---|---|
/v1/run | 100 requests per 60 seconds |
/v1/status | 50 requests per 10 seconds |
/v1/agent/images and /v1/agent/images/run | 100 requests per 60 seconds |
/v1/agent/status | 50 requests per 10 seconds |
Concurrency Limits
The API has a default concurrency limit of 6 requests per limit. This means you can have up to 6 concurrent requests being processed at any given time.
Our API rate limits are in place to ensure fair usage and prevent misuse of our services. However, we understand that legitimate applications may require higher limits as they grow. If your app's usage nears the specified rate limits, and this usage is justified by your application's needs, we will gladly increase your rate limit. Please reach out to our support@fashn.ai to discuss your specific requirements.
Endpoint Lifecycle
Every FASHN API model has a lifecycle stage that describes its stability and integration guidance. See Model Lifecycle for stage definitions, release dates, and the current status of every model.
Webhooks
Instead of polling for status, you can configure webhooks to receive notifications when predictions complete. See the Webhooks Guide for setup instructions.