# Create an Embed Job

POST https://api.cohere.com/v1/embed-jobs
Content-Type: application/json

This API launches an async Embed job for a [Dataset](https://docs.cohere.com/docs/datasets) of type `embed-input`. The result of a completed embed job is new Dataset of type `embed-output`, which contains the original text entries and the corresponding embeddings.

Reference: https://docs.cohere.com/reference/create-embed-job

## OpenAPI Specification

```yaml
openapi: 3.1.1
info:
  title: Create an Embed Job
  version: endpoint_embedJobs.create
paths:
  /v1/embed-jobs:
    post:
      operationId: create
      summary: Create an Embed Job
      description: >-
        This API launches an async Embed job for a
        [Dataset](https://docs.cohere.com/docs/datasets) of type `embed-input`.
        The result of a completed embed job is new Dataset of type
        `embed-output`, which contains the original text entries and the
        corresponding embeddings.
      tags:
        - - subpackage_embedJobs
      parameters:
        - name: Authorization
          in: header
          description: >-
            Bearer authentication of the form `Bearer <token>`, where token is
            your auth token.
          required: true
          schema:
            type: string
        - name: X-Client-Name
          in: header
          description: |
            The name of the project that is making the request.
          required: false
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateEmbedJobResponse'
        '400':
          description: >
            This error is returned when the request is not well formed. This
            could be because:
              - JSON is invalid
              - The request is missing required fields
              - The request contains an invalid combination of fields
          content: {}
        '401':
          description: >
            This error indicates that the operation attempted to be performed is
            not allowed. This could be because:
              - The api token is invalid
              - The user does not have the necessary permissions
          content: {}
        '403':
          description: >
            This error indicates that the operation attempted to be performed is
            not allowed. This could be because:
              - The api token is invalid
              - The user does not have the necessary permissions
          content: {}
        '404':
          description: >
            This error is returned when a resource is not found. This could be
            because:
              - The endpoint does not exist
              - The resource does not exist eg model id, dataset id
          content: {}
        '422':
          description: >
            This error is returned when the request is not well formed. This
            could be because:
              - JSON is invalid
              - The request is missing required fields
              - The request contains an invalid combination of fields
          content: {}
        '429':
          description: Too many requests
          content: {}
        '498':
          description: >
            This error is returned when a request or response contains a
            deny-listed token.
          content: {}
        '499':
          description: |
            This error is returned when a request is cancelled by the user.
          content: {}
        '500':
          description: >
            This error is returned when an uncategorised internal server error
            occurs.
          content: {}
        '501':
          description: >
            This error is returned when the requested feature is not
            implemented.
          content: {}
        '503':
          description: >
            This error is returned when the service is unavailable. This could
            be due to:
              - Too many users trying to access the service at the same time
          content: {}
        '504':
          description: >
            This error is returned when a request to the server times out. This
            could be due to:
              - An internal services taking too long to respond
          content: {}
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEmbedJobRequest'
components:
  schemas:
    EmbedInputType:
      type: string
      enum:
        - value: search_document
        - value: search_query
        - value: classification
        - value: clustering
        - value: image
    EmbeddingType:
      type: string
      enum:
        - value: float
        - value: int8
        - value: uint8
        - value: binary
        - value: ubinary
        - value: base64
    CreateEmbedJobRequestTruncate:
      type: string
      enum:
        - value: START
        - value: END
      default: END
    CreateEmbedJobRequest:
      type: object
      properties:
        model:
          type: string
          format: string
          description: |
            ID of the embedding model.

            Available models and corresponding embedding dimensions:

            - `embed-english-v3.0` : 1024
            - `embed-multilingual-v3.0` : 1024
            - `embed-english-light-v3.0` : 384
            - `embed-multilingual-light-v3.0` : 384
        dataset_id:
          type: string
          description: >-
            ID of a [Dataset](https://docs.cohere.com/docs/datasets). The
            Dataset must be of type `embed-input` and must have a validation
            status `Validated`
        input_type:
          $ref: '#/components/schemas/EmbedInputType'
        name:
          type: string
          description: The name of the embed job.
        embedding_types:
          type: array
          items:
            $ref: '#/components/schemas/EmbeddingType'
          description: >-
            Specifies the types of embeddings you want to get back. Not required
            and default is None, which returns the Embed Floats response type.
            Can be one or more of the following types.


            * `"float"`: Use this when you want to get back the default float
            embeddings. Valid for all models.

            * `"int8"`: Use this when you want to get back signed int8
            embeddings. Valid for v3 and newer model versions.

            * `"uint8"`: Use this when you want to get back unsigned int8
            embeddings. Valid for v3 and newer model versions.

            * `"binary"`: Use this when you want to get back signed binary
            embeddings. Valid for v3 and newer model versions.

            * `"ubinary"`: Use this when you want to get back unsigned binary
            embeddings. Valid for v3 and newer model versions.
        truncate:
          $ref: '#/components/schemas/CreateEmbedJobRequestTruncate'
          description: >
            One of `START|END` to specify how the API will handle inputs longer
            than the maximum token length.


            Passing `START` will discard the start of the input. `END` will
            discard the end of the input. In both cases, input is discarded
            until the remaining input is exactly the maximum input token length
            for the model.
      required:
        - model
        - dataset_id
        - input_type
    ApiMetaApiVersion:
      type: object
      properties:
        version:
          type: string
        is_deprecated:
          type: boolean
        is_experimental:
          type: boolean
      required:
        - version
    ApiMetaBilledUnits:
      type: object
      properties:
        images:
          type: number
          format: double
          description: |
            The number of billed images.
        input_tokens:
          type: number
          format: double
          description: |
            The number of billed input tokens.
        image_tokens:
          type: number
          format: double
          description: |
            The number of billed image tokens.
        output_tokens:
          type: number
          format: double
          description: |
            The number of billed output tokens.
        search_units:
          type: number
          format: double
          description: |
            The number of billed search units.
        classifications:
          type: number
          format: double
          description: |
            The number of billed classifications units.
    ApiMetaTokens:
      type: object
      properties:
        input_tokens:
          type: number
          format: double
          description: |
            The number of tokens used as input to the model.
        output_tokens:
          type: number
          format: double
          description: |
            The number of tokens produced by the model.
    ApiMeta:
      type: object
      properties:
        api_version:
          $ref: '#/components/schemas/ApiMetaApiVersion'
        billed_units:
          $ref: '#/components/schemas/ApiMetaBilledUnits'
        tokens:
          $ref: '#/components/schemas/ApiMetaTokens'
        cached_tokens:
          type: number
          format: double
          description: |
            The number of prompt tokens that hit the inference cache.
        warnings:
          type: array
          items:
            type: string
    CreateEmbedJobResponse:
      type: object
      properties:
        job_id:
          type: string
        meta:
          $ref: '#/components/schemas/ApiMeta'
      required:
        - job_id

```

## SDK Code Examples

```go Cohere Go SDK
package main

import (
	"context"
	"log"
	"os"

	cohere "github.com/cohere-ai/cohere-go/v2"
	client "github.com/cohere-ai/cohere-go/v2/client"
)

func main() {
	co := client.NewClient(client.WithToken(os.Getenv("CO_API_KEY")))

	resp, err := co.EmbedJobs.Create(
		context.TODO(),
		&cohere.CreateEmbedJobRequest{
			DatasetId: "dataset_id",
			Model:     "embed-english-v3.0",
			InputType: cohere.EmbedInputTypeSearchDocument,
		},
	)

	if err != nil {
		log.Fatal(err)
	}

	log.Printf("%+v", resp)
}

```

```python Sync
import cohere

co = cohere.Client()