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

# Create an embedding

> Generate a dense vector representation of one or more input strings. Use
the vector to rank documents by similarity, cluster, or as a retrieval
index.




## OpenAPI

````yaml /inference-api/openapi.yaml post /v1/embeddings
openapi: 3.1.0
info:
  title: FlexAI Inference API
  version: 1.0.0
  description: |
    OpenAI-compatible inference API for text, code, reasoning, vision, and
    embedding models hosted by FlexAI. Use any OpenAI SDK by pointing the
    `base_url` at this service.
  contact:
    name: FlexAI Support
    email: support@flex.ai
    url: https://docs.flex.ai/inference-api/overview
servers:
  - url: https://tokens.flex.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Chat
    description: Chat completions (streaming, tool use, vision).
  - name: Completions
    description: Legacy text completions.
  - name: Embeddings
    description: Generate vector embeddings for text.
  - name: Models
    description: Discover available models.
  - name: Usage
    description: Programmatic spend and quota for the calling key.
paths:
  /v1/embeddings:
    post:
      tags:
        - Embeddings
      summary: Create an embedding
      description: |
        Generate a dense vector representation of one or more input strings. Use
        the vector to rank documents by similarity, cluster, or as a retrieval
        index.
      operationId: createEmbedding
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
              properties:
                model:
                  type: string
                  description: >-
                    Embedding model id. See the [model
                    catalog](https://flex.ai/models).
                  example: bge-m3
                input:
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                  description: Text (or list of texts) to embed.
                  example: hello world
                encoding_format:
                  type: string
                  enum:
                    - float
                    - base64
                  default: float
                  description: >
                    Encoding of the returned embedding values. Optional;
                    defaults to

                    `"float"` (matching OpenAI). Use `"base64"` for the compact
                    wire

                    format. Pass a string or omit the field — do not send an
                    explicit `null`.
      responses:
        '200':
          description: Successful response.
          content:
            application/json:
              schema:
                type: object
                required:
                  - object
                  - data
                  - model
                  - usage
                properties:
                  object:
                    type: string
                    enum:
                      - list
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        object:
                          type: string
                          enum:
                            - embedding
                        index:
                          type: integer
                        embedding:
                          type: array
                          items:
                            type: number
                  model:
                    type: string
                  usage:
                    type: object
                    properties:
                      prompt_tokens:
                        type: integer
                      total_tokens:
                        type: integer
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  responses:
    BadRequest:
      description: Invalid request — malformed body, unknown model, or schema violation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    PaymentRequired:
      description: Key budget exhausted — add credit in the dashboard to continue.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: |
        Per-key RPM exceeded. Response includes `Retry-After` and
        `x-ratelimit-*` headers.
      headers:
        Retry-After:
          schema:
            type: integer
          description: Seconds until the next window.
        x-ratelimit-limit-requests:
          schema:
            type: integer
        x-ratelimit-remaining-requests:
          schema:
            type: integer
        x-ratelimit-reset-requests:
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServerError:
      description: Upstream or gateway error. Safe to surface `error.message` to users.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - type
          properties:
            message:
              type: string
            type:
              type: string
              example: invalid_request_error
            code:
              type: string
              description: |
                Stable machine-readable code for the failure. Present on
                most error paths; OMITTED on FastAPI default-validation
                bodies. Do not assume always present.
            doc_url:
              type: string
              format: uri
              description: |
                FlexAI extension. Link to the relevant dashboard / docs
                page for the failure mode (e.g. invalid key → /dashboard/keys).
                Present on auth and quota errors.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: sk-xxxx
      description: |
        Virtual API key. Create one from the
        [FlexAI dashboard](https://tokens.flex.ai/dashboard/keys). Pass as
        `Authorization: Bearer sk-xxxx`.

````