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

# AI Completion

> Generate AI completion using configured providers



## OpenAPI

````yaml openapi.json post /api/v1/ai/complete
openapi: 3.0.0
info:
  description: Dualship backend API for workflow automation and API management.
  title: Dualship API
  termsOfService: https://dualship.run/terms
  contact:
    name: Dualship Support
    url: https://dualship.run/support
    email: support@dualship.run
  version: '1.0'
servers:
  - url: https://api.dualship.run
security: []
paths:
  /api/v1/ai/complete:
    post:
      tags:
        - ai
      summary: AI Completion
      description: Generate AI completion using configured providers
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/github_com_dualship_dualship-be_internal_api_rules.AICompletionRequest
        description: Completion request
        required: true
      responses:
        '200':
          description: Completion response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_dualship_dualship-be_internal_ai_providers.CompletionResponse
        '400':
          description: Invalid request or no providers configured
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/internal_api_handler.BadRequestError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/internal_api_handler.UnauthorizedError'
        '500':
          description: Completion failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/internal_api_handler.InternalServerError'
        '503':
          description: AI service not configured or all providers failed
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/internal_api_handler.ServiceUnavailableError
      security:
        - BearerAuth: []
components:
  schemas:
    github_com_dualship_dualship-be_internal_api_rules.AICompletionRequest:
      type: object
      required:
        - messages
        - workspace_id
      properties:
        max_tokens:
          type: integer
          maximum: 16384
          minimum: 1
        messages:
          type: array
          minItems: 1
          items:
            type: object
            required:
              - content
              - role
            properties:
              content:
                type: string
              role:
                type: string
                enum:
                  - system
                  - user
                  - assistant
        model:
          type: string
        stream:
          type: boolean
        temperature:
          type: number
          maximum: 2
          minimum: 0
        workspace_id:
          type: string
    github_com_dualship_dualship-be_internal_ai_providers.CompletionResponse:
      type: object
      properties:
        content:
          type: string
        finish_reason:
          type: string
        input_tokens:
          type: integer
        model:
          type: string
        output_tokens:
          type: integer
    internal_api_handler.BadRequestError:
      description: Bad request error
      type: object
      properties:
        code:
          type: string
          example: BAD_REQUEST
        error:
          type: string
          example: invalid request parameters
    internal_api_handler.UnauthorizedError:
      description: Unauthorized error
      type: object
      properties:
        code:
          type: string
          example: UNAUTHORIZED
        error:
          type: string
          example: unauthorized
    internal_api_handler.InternalServerError:
      description: Internal server error
      type: object
      properties:
        code:
          type: string
          example: INTERNAL_ERROR
        error:
          type: string
          example: internal server error
    internal_api_handler.ServiceUnavailableError:
      description: Service unavailable error
      type: object
      properties:
        code:
          type: string
          example: SERVICE_UNAVAILABLE
        error:
          type: string
          example: service unavailable
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT Bearer token authentication

````