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

# Create Embedding

> Create vector embeddings for text input using embedding models.

<RequestExample>
  ```bash cURL theme={"dark"}
  curl https://router.requesty.ai/v1/embeddings \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_REQUESTY_API_KEY" \
    -d '{
      "model": "openai/text-embedding-3-small",
      "input": "Requesty is a unified LLM gateway."
    }'
  ```

  ```python Python theme={"dark"}
  from openai import OpenAI

  client = OpenAI(
      api_key="YOUR_REQUESTY_API_KEY",
      base_url="https://router.requesty.ai/v1",
  )

  response = client.embeddings.create(
      model="openai/text-embedding-3-small",
      input="Requesty is a unified LLM gateway.",
  )

  print(response.data[0].embedding[:5])
  ```

  ```typescript TypeScript theme={"dark"}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.REQUESTY_API_KEY,
    baseURL: "https://router.requesty.ai/v1",
  });

  const response = await client.embeddings.create({
    model: "openai/text-embedding-3-small",
    input: "Requesty is a unified LLM gateway.",
  });

  console.log(response.data[0].embedding.slice(0, 5));
  ```
</RequestExample>

<ResponseExample>
  ```json Response 200 theme={"dark"}
  {
    "object": "list",
    "data": [
      {
        "object": "embedding",
        "index": 0,
        "embedding": [0.0023, -0.0091, 0.0153, -0.0028, 0.0074]
      }
    ],
    "model": "openai/text-embedding-3-small",
    "usage": {
      "prompt_tokens": 8,
      "total_tokens": 8
    }
  }
  ```
</ResponseExample>

Create vector embeddings for text input. Embeddings are useful for semantic search, similarity matching, clustering, and retrieval-augmented generation (RAG).

## Supported Models

Browse the full catalog on the [Embedding model library](https://app.requesty.ai/model-library/embeddings).

| Model                           | Dimensions | Best for                        |
| ------------------------------- | ---------- | ------------------------------- |
| `openai/text-embedding-3-small` | 1536       | Cost-efficient, general purpose |
| `openai/text-embedding-3-large` | 3072       | Higher accuracy, multilingual   |
| `openai/text-embedding-ada-002` | 1536       | Legacy compatibility            |


## OpenAPI

````yaml POST /v1/embeddings
openapi: 3.0.3
info:
  title: Requesty API
  description: Requesty API for AI model routing and key management
  version: 1.0.0
servers:
  - url: https://api-v2.requesty.ai
    description: Management API endpoint
  - url: https://router.requesty.ai
    description: Inference router endpoint
security:
  - BearerAuth: []
paths:
  /v1/embeddings:
    servers:
      - url: https://router.requesty.ai
        description: Inference router endpoint
    post:
      summary: Create embedding
      description: Create vector embeddings for text input using embedding models.
      operationId: createEmbedding
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbeddingRequest'
            example:
              model: openai/text-embedding-3-small
              input: Requesty is a unified LLM gateway.
      responses:
        '200':
          description: Embedding response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbeddingResponse'
              example:
                object: list
                data:
                  - object: embedding
                    index: 0
                    embedding:
                      - 0.0023
                      - -0.0091
                      - 0.0153
                      - -0.0028
                      - 0.0074
                model: openai/text-embedding-3-small
                usage:
                  prompt_tokens: 8
                  total_tokens: 8
        '400':
          description: Bad request - malformed payload or invalid parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - missing or empty Authorization header.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Payment required - organization balance exhausted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden - invalid token or model not in access list.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found - provider/model not supported.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded. Retry after the Retry-After header value.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: Bad gateway - upstream provider returned an invalid response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    EmbeddingRequest:
      type: object
      required:
        - input
        - model
      properties:
        input:
          oneOf:
            - type: string
              description: A single text string to embed
            - type: array
              items:
                type: string
              description: An array of text strings to embed
            - type: array
              items:
                type: integer
                format: int64
              description: An array of token integers to embed
            - type: array
              items:
                type: array
                items:
                  type: integer
                  format: int64
              description: An array of token arrays to embed
          description: >-
            Input text to embed, encoded as a string, array of strings, array of
            tokens, or array of token arrays
        model:
          type: string
          description: The model name to use for embedding generation
          example: openai/text-embedding-3-small
        dimensions:
          type: integer
          format: int64
          description: The number of dimensions the resulting output embeddings should have
        encoding_format:
          type: string
          enum:
            - float
            - base64
          description: >-
            The format to return the embeddings in. Can be either float or
            base64.
          default: float
        user:
          type: string
          description: A unique identifier representing your end-user.
    EmbeddingResponse:
      type: object
      required:
        - data
        - model
        - object
        - usage
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/EmbeddingData'
          description: The list of embeddings generated by the model
        model:
          type: string
          description: The name of the model used to generate the embedding
        object:
          type: string
          description: The object type, which is always 'list'
        usage:
          $ref: '#/components/schemas/EmbeddingUsage'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - origin
            - message
          properties:
            origin:
              type: string
              enum:
                - router
                - provider
              description: >-
                Whether the error originated from Requesty's router or an
                upstream provider.
            message:
              type: string
              description: Human-readable error description.
    EmbeddingData:
      type: object
      required:
        - embedding
        - index
        - object
      properties:
        embedding:
          oneOf:
            - type: array
              items:
                type: number
                format: float
              description: The embedding vector as an array of floats
            - type: string
              description: The embedding vector as a base64-encoded string
          description: >-
            The embedding vector, the format of which is determined by the
            encoding_format parameter
        index:
          type: integer
          format: int64
          description: The index of the embedding in the list
        object:
          type: string
          description: The object type, which is always 'embedding'
    EmbeddingUsage:
      type: object
      required:
        - prompt_tokens
        - total_tokens
      properties:
        prompt_tokens:
          type: integer
          format: int64
          description: The number of tokens used by the prompt
        total_tokens:
          type: integer
          format: int64
          description: The total number of tokens used by the request
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key for authentication

````