> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apistable.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a task

> Submit asynchronous image, video, or music work.

> API preview: generation providers are not connected. An authenticated request can return 503 without creating a task or charging credits.

## Request body

| Parameter | Type | Behavior |
| - | - | - |
| model | string · required | Exact model and operation ID. |
| input | object · required | Validated against that model’s schema. |
| output\_count | integer · default 1 | Images/videos only; 1–4 target items. |
| fallback | boolean · default false | Authorizes eligible official fallback. |
| max\_credits | non-negative integer · optional | Maximum total reservation you accept. |

## Planned live acceptance

When live execution is enabled, successful acceptance atomically records the operation, result items, credit reservation, and durable scheduling record. HTTP 202 means work is accepted, not that a model has finished.

With output\_count=4, you receive one task ID containing four stable items. The worker schedules each item within account and provider limits. There is no guarantee that all four start simultaneously.

> During this build, real provider execution is not connected. A request must not manufacture a successful model output or a completed paid generation.

## Planned idempotent acceptance

Once live task acceptance is enabled, send Idempotency-Key and retain it with the input. In this build, POST /v1/tasks rejects live execution before creating an operation, so the header does not yet produce a stored operation. Reusing it with the same input refers to the original operation; changing quantity, fallback, or the credit cap should return a conflict. Deliberately generating again requires a new key and a new paid operation.

[Errors and recovery](https://docs.apistable.com/en/errors.md)


## OpenAPI

````yaml openapi.json POST /v1/tasks
openapi: 3.1.0
info:
  title: APIstable API preview
  version: 0.1.0-preview
  description: >-
    Current implemented HTTP surface. / 当前已实现的 HTTP 接口。 Models and quote prices
    are illustrative. Real providers and paid generation are not connected. POST
    /v1/tasks and /v1/chat/completions return 503 provider_not_configured after
    authentication and applicable validation; no credits are reserved or
    charged. Live 202 acceptance, provider callbacks, SSE, idempotent task
    creation, and full model capability adapters remain future integration work.
    Website login sessions are separate from application API keys.
servers:
  - url: https://apistable.com
    description: APIstable API
security: []
tags:
  - name: Models
  - name: Quotes
  - name: Tasks
  - name: Credits
  - name: LLM
paths:
  /v1/tasks:
    post:
      tags:
        - Tasks
      summary: Generation submission placeholder / 生成提交预览
      description: >-
        Requires generations:write. Validates the request, then returns 503
        provider_not_configured. No operation, reservation, or provider attempt
        is created. Idempotency-Key is shown for the future live contract but is
        not consumed by this disabled submission path. Do not treat HTTP 503 as
        a successful generation.
      operationId: createTaskPreview
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
          description: >-
            Reserved for live acceptance. No task is currently created or
            deduplicated by this header.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaskRequest'
      responses:
        '400':
          description: Invalid or unsupported input
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: invalid_api_key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: insufficient_scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: model_not_found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: payload_too_large
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: credit_limit_exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: >-
            provider_not_configured, model_unavailable, or service_unavailable.
            No live work is accepted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: provider_not_configured
                  message: >-
                    Live model providers are not connected in this build. No
                    credits were reserved or charged.
      security:
        - bearerAuth: []
components:
  schemas:
    TaskRequest:
      type: object
      additionalProperties: false
      required:
        - model
        - input
      properties:
        model:
          type: string
          minLength: 1
          example: prism-image-2
        input:
          $ref: '#/components/schemas/GenerationInput'
        output_count:
          type: integer
          minimum: 1
          maximum: 4
          default: 1
          description: >-
            Target result count. Images/videos accept 1–4; music and LLM must
            remain 1. Not a concurrency guarantee. / 目标结果数，非同时并发保证。
        fallback:
          type: boolean
          default: false
          description: >-
            Authorizes a higher-priced compatible official fallback after an
            eligible confirmed failure. Live execution is disabled in this
            build.
        max_credits:
          type: integer
          minimum: 0
          description: >-
            Whole-request reservation cap. Reject the entire request when
            max_reserved_credits exceeds it.
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
    GenerationInput:
      type: object
      additionalProperties: false
      required:
        - prompt
      description: >-
        Current preview input. Supported fields vary by modality and exact
        catalog model. No live provider mapping is implied.
      properties:
        prompt:
          type: string
          minLength: 1
          maxLength: 4000
        duration_seconds:
          type: integer
          description: Video-only; must match the model duration list.
        resolution:
          type: string
          description: Must match the model resolution list.
        aspect_ratio:
          type: string
          enum:
            - '16:9'
            - '9:16'
            - '1:1'
            - '4:3'
        seed:
          type: integer
          minimum: 0
        generate_audio:
          type: boolean
          description: Video only, subject to model support.
        instrumental:
          type: boolean
          description: Music only.
        lyrics:
          type: string
          maxLength: 5000
          description: Music only.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: APIstable API key
      description: >-
        API key beginning as_. Keep on the server. Scope permissions are checked
        separately.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.