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

# Embeddings

> Use DeerAPI to call the Embeddings endpoint with request details, response details, examples, and an OpenAPI playground.

## Overview

Use this endpoint to call the Embeddings workflow through DeerAPI. The API reference on this page shows the request schema, response schema, authentication requirements, and runnable examples for the configured endpoint.

## Before you start

Use the DeerAPI base URL and pass your API Key in the `Authorization` header:

```text theme={null}
https://api.deerapi.com
```

```text theme={null}
Authorization: Bearer $DEERAPI_KEY
```

## Model selection

Choose a current model ID from the [live pricing page](https://api.deerapi.com/pricing). Model availability changes over time, so avoid copying a model ID from an old project without checking the live list first.

## Implementation notes

* Use the OpenAPI playground for the exact request fields accepted by this endpoint.
* Keep API Keys on the server side when you build production applications.
* Log the request ID from failed calls so support can investigate the request.
* Retry `429`, `500`, and `503` responses with exponential backoff.


## OpenAPI

````yaml /api/openapi/text/openai/post-embeddings.openapi.json POST /v1/embeddings
openapi: 3.1.0
info:
  title: Embeddings API
  version: 1.0.0
servers:
  - url: https://api.deerapi.com
security:
  - bearerAuth: []
paths:
  /v1/embeddings:
    post:
      summary: Embeddings
      operationId: embeddings
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              description: Use this field according to the endpoint schema.
              required:
                - model
                - input
              properties:
                model:
                  type: string
                  description: Use this field according to the endpoint schema.
                  default: text-embedding-3-small
                input:
                  type:
                    - string
                    - array
                  description: Use this field according to the endpoint schema.
                  default: Sample value
                dimensions:
                  type: integer
                  description: Use this field according to the endpoint schema.
                encoding_format:
                  type: string
                  description: Use this field according to the endpoint schema.
                  enum:
                    - float
                    - base64
                  default: float
                user:
                  type: string
                  description: Use this field according to the endpoint schema.
              default:
                model: text-embedding-3-small
                input: DeerAPI provides unified access to AI models.
            examples:
              Default:
                summary: Default
                value:
                  model: text-embedding-3-small
                  input: DeerAPI provides unified access to AI models.
              Batch:
                summary: Embeddings API
                value:
                  model: text-embedding-3-small
                  input:
                    - DeerAPI provides unified access to AI models.
                    - Use embeddings for semantic search and clustering.
                  encoding_format: float
              ReduceDimensions:
                summary: Embeddings API
                value:
                  model: text-embedding-3-large
                  input: DeerAPI provides unified access to AI models.
                  dimensions: 1024
            example:
              model: text-embedding-3-small
              input: DeerAPI provides unified access to AI models.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                required:
                  - object
                  - data
                  - model
                  - usage
                properties:
                  object:
                    type: string
                    description: Use this field according to the endpoint schema.
                  data:
                    type: array
                    description: Use this field according to the endpoint schema.
                    items:
                      type: object
                      properties:
                        object:
                          type: string
                          description: Use this field according to the endpoint schema.
                        index:
                          type: integer
                          description: Use this field according to the endpoint schema.
                        embedding:
                          description: Use this field according to the endpoint schema.
                  model:
                    type: string
                    description: Use this field according to the endpoint schema.
                  usage:
                    type: object
                    description: Use this field according to the endpoint schema.
                    required:
                      - prompt_tokens
                      - total_tokens
                    properties:
                      prompt_tokens:
                        type: integer
                        description: Use this field according to the endpoint schema.
                      total_tokens:
                        type: integer
                        description: Use this field according to the endpoint schema.
      x-codeSamples:
        - lang: Shell
          label: cURL
          source: |
            curl https://api.deerapi.com/v1/embeddings \
              -H "Content-Type: application/json" \
              -H "Authorization: Bearer $DEERAPI_KEY" \
              -d '{
                "model": "text-embedding-3-small",
                "input": "DeerAPI provides unified access to AI models."
              }'
        - lang: Python
          label: requests
          source: |
            import os
            import requests

            url = "https://api.deerapi.com/v1/embeddings"
            headers = {
                "Authorization": "Bearer " + os.environ["DEERAPI_KEY"],
                "Content-Type": "application/json",
            }
            payload = {
              "model": "text-embedding-3-small",
              "input": "DeerAPI provides unified access to AI models."
            }

            response = requests.post(url, headers=headers, json=payload)
            print(response.json())
        - lang: JavaScript
          label: fetch
          source: >
            const response = await
            fetch("https://api.deerapi.com/v1/embeddings", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.DEERAPI_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                "model": "text-embedding-3-small",
                "input": "DeerAPI provides unified access to AI models."
              }),
            });


            console.log(await response.json());
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Use a DeerAPI API Key as a Bearer token.

````