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

# Generate text synchronously

> Runs a new generation in the request with a 90-second provider timeout. A reused request ID can return an existing job in any state. Check job status, since a failed job also returns HTTP 200.



## OpenAPI

````yaml /openapi/backapp-public.json post /v2/texts/generations/sync
openapi: 3.1.0
info:
  title: Backapp API
  version: 2.0.0
  description: >-
    Backapp v2 API reference for authentication, files, image effects, and AI
    jobs.
servers:
  - url: https://api.backapp.dev
security: []
paths:
  /v2/texts/generations/sync:
    post:
      summary: Generate text synchronously
      description: >-
        Runs a new generation in the request with a 90-second provider timeout.
        A reused request ID can return an existing job in any state. Check job
        status, since a failed job also returns HTTP 200.
      operationId: runTextGenerationSync
      parameters:
        - $ref: '#/components/parameters/AppVersion'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextGenerationRequest'
            example:
              model: openai:gpt-6-luna
              prompt: Translate Good morning into French. Return only the translation.
              max_output_tokens: 64
              reasoning_effort: none
              request_id: translation-sync-example-01
      responses:
        '200':
          description: Text generation job
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TextGenerationJob'
              example:
                job_id: 20000000-0000-4000-8000-000000000001
                operation: text_to_text
                status: completed
                input:
                  model: openai:gpt-6-luna
                  prompt: >-
                    Translate Good morning into French. Return only the
                    translation.
                  reasoning_effort: none
                  max_output_tokens: 64
                result:
                  text: Bonjour
                  truncated: false
                error: null
                created_at: '2026-11-17T17:59:56.054414Z'
                finished_at: '2026-11-17T17:59:59.416205Z'
        '400':
          description: Invalid input or model not available
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: Usage allowance reached
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Operation not enabled
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Too many active jobs
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: Provider not configured
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - AppKey: []
          Bearer: []
components:
  parameters:
    AppVersion:
      name: X-App-Version
      in: header
      required: true
      schema:
        type: string
        minLength: 1
      description: Version of the client application.
  schemas:
    TextGenerationRequest:
      type: object
      properties:
        model:
          type: string
          minLength: 1
          maxLength: 100
          description: Exact model ID returned by GET /v2/texts/models.
        prompt:
          type: string
          minLength: 1
          maxLength: 3000000
          description: >-
            Prompt and instructions together may contain at most 3,000,000
            characters.
        instructions:
          type: string
          maxLength: 3000000
        max_output_tokens:
          type: integer
          minimum: 16
          description: >-
            Maximum is the selected model’s advertised limit. Omission uses the
            model’s own limit.
        reasoning_effort:
          type: string
          minLength: 1
          maxLength: 16
          description: Choose a value advertised by the selected model.
        request_id:
          type: string
          minLength: 1
          maxLength: 100
          description: >-
            Reuse this ID for the same logical generation, including across sync
            and background routes.
      required:
        - model
        - prompt
    TextGenerationJob:
      allOf:
        - $ref: '#/components/schemas/Job'
        - type: object
          properties:
            operation:
              const: text_to_text
            input:
              type: object
              properties:
                model:
                  type: string
                  minLength: 1
                  maxLength: 100
                  description: Exact model ID returned by GET /v2/texts/models.
                prompt:
                  type: string
                  minLength: 1
                  maxLength: 3000000
                  description: >-
                    Prompt and instructions together may contain at most
                    3,000,000 characters.
                instructions:
                  type: string
                  maxLength: 3000000
                max_output_tokens:
                  type: integer
                  minimum: 16
                  description: >-
                    Maximum is the selected model’s advertised limit. Omission
                    uses the model’s own limit.
                reasoning_effort:
                  type: string
                  minLength: 1
                  maxLength: 16
                  description: Choose a value advertised by the selected model.
              required:
                - model
                - prompt
            result:
              anyOf:
                - type: object
                  properties:
                    text:
                      type: string
                    truncated:
                      type: boolean
                      description: True if generation hit the output token limit.
                  required:
                    - text
                    - truncated
                - type: 'null'
    Error:
      type: object
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
            fields:
              type: object
              additionalProperties: true
      required:
        - error
    Job:
      type: object
      properties:
        job_id:
          type: string
          format: uuid
        operation:
          type: string
          enum:
            - speech_to_text
            - image_to_image
            - text_to_text
        status:
          type: string
          enum:
            - pending
            - processing
            - completed
            - failed
        input:
          anyOf:
            - type: object
              properties:
                file_id:
                  type: string
                  format: uuid
              required:
                - file_id
            - type: object
              properties:
                file_id:
                  type: string
                  format: uuid
                model:
                  type: string
                  maxLength: 100
                prompt:
                  type: string
                  maxLength: 2000
              required:
                - file_id
                - model
                - prompt
            - type: object
              properties:
                model:
                  type: string
                  minLength: 1
                  maxLength: 100
                  description: Exact model ID returned by GET /v2/texts/models.
                prompt:
                  type: string
                  minLength: 1
                  maxLength: 3000000
                  description: >-
                    Prompt and instructions together may contain at most
                    3,000,000 characters.
                instructions:
                  type: string
                  maxLength: 3000000
                max_output_tokens:
                  type: integer
                  minimum: 16
                  description: >-
                    Maximum is the selected model’s advertised limit. Omission
                    uses the model’s own limit.
                reasoning_effort:
                  type: string
                  minLength: 1
                  maxLength: 16
                  description: Choose a value advertised by the selected model.
              required:
                - model
                - prompt
        result:
          anyOf:
            - type: object
              properties:
                text:
                  type: string
              required:
                - text
            - type: object
              properties:
                image:
                  type: object
                  properties:
                    file_id:
                      type: string
                      format: uuid
                    url:
                      type: string
                      format: uri
                    content_type:
                      type: string
                    width:
                      type: integer
                    height:
                      type: integer
                  required:
                    - file_id
                    - url
                    - content_type
                    - width
                    - height
              required:
                - image
            - type: object
              properties:
                text:
                  type: string
                truncated:
                  type: boolean
                  description: True if generation hit the output token limit.
              required:
                - text
                - truncated
            - type: 'null'
        error:
          anyOf:
            - type: object
              properties:
                code:
                  type: string
                message:
                  type: string
                retryable:
                  type: boolean
              required:
                - code
                - message
                - retryable
            - type: 'null'
        created_at:
          type: string
          format: date-time
        finished_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - job_id
        - operation
        - status
        - input
        - result
        - error
        - created_at
        - finished_at
  securitySchemes:
    AppKey:
      type: apiKey
      in: header
      name: X-App-Key
      description: Public application identifier.
    Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

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