Together AI Embeddings API

The Embeddings API from Together AI — 1 operation(s) for embeddings.

Documentation

Specifications

Other Resources

OpenAPI Specification

together-ai-embeddings-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: remediation.proto Audio Embeddings API
  version: version not set
servers:
- url: https://api.together.xyz/v1
security:
- bearerAuth: []
tags:
- name: Embeddings
paths:
  /embeddings:
    post:
      tags:
      - Embeddings
      summary: Create embedding
      description: Generate vector embeddings for one or more text inputs. Returns numerical arrays representing semantic meaning, useful for search, classification, and retrieval.
      x-codeSamples:
      - lang: Python
        label: Together AI SDK (v2)
        source: "# Docs for v1 can be found by changing the above selector ^\nfrom together import Together\nimport os\n\nclient = Together(\n    api_key=os.environ.get(\"TOGETHER_API_KEY\"),\n)\n\nresponse = client.embeddings.create(\n    model=\"BAAI/bge-large-en-v1.5\",\n    input=\"New York City\",\n)\n\nprint(response.data[0].embedding)\n"
      - lang: Python
        label: Together AI SDK (v1)
        source: "from together import Together\nimport os\n\nclient = Together(\n    api_key=os.environ.get(\"TOGETHER_API_KEY\"),\n)\n\nresponse = client.embeddings.create(\n    model=\"BAAI/bge-large-en-v1.5\",\n    input=\"New York City\",\n)\n\nprint(response.data[0].embedding)\n"
      - lang: TypeScript
        label: Together AI SDK (TypeScript)
        source: "import Together from \"together-ai\";\n\nconst client = new Together({\n  apiKey: process.env.TOGETHER_API_KEY,\n});\n\nconst response = await client.embeddings.create({\n  model: \"BAAI/bge-large-en-v1.5\",\n  input: \"New York City\",\n});\n\nconsole.log(response.data[0].embedding);\n"
      - lang: JavaScript
        label: Together AI SDK (JavaScript)
        source: "import Together from \"together-ai\";\n\nconst client = new Together({\n  apiKey: process.env.TOGETHER_API_KEY,\n});\n\nconst response = await client.embeddings.create({\n  model: \"BAAI/bge-large-en-v1.5\",\n  input: \"New York City\",\n});\n\nconsole.log(response.data[0].embedding);\n"
      - lang: Shell
        label: cURL
        source: "curl -X POST \"https://api.together.ai/v1/embeddings\" \\\n     -H \"Authorization: Bearer $TOGETHER_API_KEY\" \\\n     -H \"Content-Type: application/json\" \\\n     -d '{\n       \"model\": \"BAAI/bge-large-en-v1.5\",\n       \"input\": \"New York City\"\n     }'\n"
      operationId: embeddings
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbeddingsRequest'
      responses:
        '200':
          description: '200'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbeddingsResponse'
        '400':
          description: BadRequest
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
        '404':
          description: NotFound
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
        '429':
          description: RateLimit
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
        '503':
          description: Overloaded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
        '504':
          description: Timeout
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorData'
      deprecated: false
components:
  schemas:
    ErrorData:
      type: object
      required:
      - error
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              nullable: false
            type:
              type: string
              nullable: false
            param:
              type: string
              nullable: true
              default: null
            code:
              type: string
              nullable: true
              default: null
          required:
          - type
          - message
    EmbeddingsResponse:
      type: object
      required:
      - object
      - model
      - data
      properties:
        object:
          description: The object type, which is always `list`.
          const: list
        model:
          type: string
        data:
          type: array
          items:
            type: object
            required:
            - index
            - object
            - embedding
            properties:
              object:
                description: The object type, which is always `embedding`.
                const: embedding
              embedding:
                type: array
                items:
                  type: number
              index:
                type: integer
    EmbeddingsRequest:
      type: object
      required:
      - model
      - input
      properties:
        model:
          type: string
          description: 'The name of the embedding model to use.<br> <br> [See all of Together AI''s embedding models](https://docs.together.ai/docs/serverless-models#embedding-models)

            '
          example: togethercomputer/m2-bert-80M-8k-retrieval
          anyOf:
          - type: string
            enum:
            - WhereIsAI/UAE-Large-V1
            - BAAI/bge-large-en-v1.5
            - BAAI/bge-base-en-v1.5
            - togethercomputer/m2-bert-80M-8k-retrieval
          - type: string
        input:
          oneOf:
          - type: string
            description: A string providing the text for the model to embed.
            example: Our solar system orbits the Milky Way galaxy at about 515,000 mph
          - type: array
            items:
              type: string
              description: A string providing the text for the model to embed.
              example: Our solar system orbits the Milky Way galaxy at about 515,000 mph
          example: Our solar system orbits the Milky Way galaxy at about 515,000 mph
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      x-bearer-format: bearer
      x-default: default