openapi: 3.0.3
info:
  title: SOAT Embeddings API
  version: 1.0.0
  description: API for generating text embeddings using the server's configured embedding model
  contact:
    name: SOAT Team
    url: https://github.com/ttoss/soat
servers:
  - url: '{baseUrl}'
    description: Base URL of your SOAT deployment (e.g. https://your-soat.com or http://localhost:5047)
    variables:
      baseUrl:
        description: The base URL of your SOAT deployment
        default: http://localhost:5047
tags:
  - name: Embeddings
    description: Generate text embeddings
security:
  - bearerAuth: []
paths:
  /api/v1/embeddings:
    post:
      tags:
        - Embeddings
      summary: Create embeddings
      description: |
        Generates embedding vectors for one or more text inputs using the server's configured embedding model.
        Provide `input` for a single text or `inputs` for a batch. At least one is required.
        Returns `embedding` when `input` is used, and `embeddings` when `inputs` is used.

        `project_id` names the project the call's token usage is metered against, so
        embedding spend reaches the usage rollup and the project's `cost_usd` / `tokens`
        quotas. A project-scoped credential supplies its own project; a call that names
        none and is bound to none is `400 VALIDATION_FAILED`.
      operationId: createEmbeddings
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                project_id:
                  type: string
                  description: >-
                    Project the call's usage is billed to. Required unless the
                    credential is bound to a project, which then supplies its own.
                    Requires write access to the named project.
                  example: proj_V1StGXR8Z5jdHi6B
                input:
                  type: string
                  description: Single text to embed.
                  example: 'The quick brown fox jumps over the lazy dog.'
                inputs:
                  type: array
                  description: >-
                    Batch of texts to embed. At most 256 per request — each
                    input is one call to the embedding model, so a larger batch
                    is refused (`VALIDATION_FAILED`) rather than queued. Split
                    it across requests.
                  maxItems: 256
                  items:
                    type: string
                  example:
                    - 'The quick brown fox.'
                    - 'Pack my box with five dozen liquor jugs.'
      responses:
        '200':
          description: Embeddings generated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbeddingsResponse'
        '400':
          description: Invalid request body, or no project to bill (no `project_id` and a credential bound to none)
          content:
            application/json:
              schema:
                $ref: './errors.yaml#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: './errors.yaml#/components/schemas/ErrorResponse'
        '403':
          description: The caller cannot write to the named `project_id`
          content:
            application/json:
              schema:
                $ref: './errors.yaml#/components/schemas/ErrorResponse'
        '503':
          description: Embedding service not configured
          content:
            application/json:
              schema:
                $ref: './errors.yaml#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    EmbeddingsResponse:
      type: object
      description: Response containing generated embeddings. Fields present depend on whether `input` or `inputs` was provided.
      properties:
        embedding:
          type: array
          description: Embedding vector for the single `input` text.
          items:
            type: number
          example: [0.123, -0.456, 0.789]
        embeddings:
          type: array
          description: Embedding vectors for each item in the `inputs` batch.
          items:
            type: array
            items:
              type: number
          example:
            - [0.123, -0.456, 0.789]
            - [0.321, -0.654, 0.987]
