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

# Create embeddings

> Exact-model text embeddings. OpenAI text-embedding-3-small: $0.02 per million input tokens. Voyage voyage-4-large: $0.12 per million. Charges round up to the wallet's $0.0001 precision. No cross-model fallback or input truncation by default.



## OpenAPI

````yaml /openapi.json post /embeddings
openapi: 3.1.0
info:
  title: NinjaChat API
  version: 1.0.0
  description: >-
    Clean-break NinjaChat v1. Chat and Responses bill actual token usage; images
    and videos use catalog unit pricing.
servers:
  - url: https://www.ninjachat.ai/api/v1
security: []
paths:
  /embeddings:
    post:
      summary: Create embeddings
      description: >-
        Exact-model text embeddings. OpenAI text-embedding-3-small: $0.02 per
        million input tokens. Voyage voyage-4-large: $0.12 per million. Charges
        round up to the wallet's $0.0001 precision. No cross-model fallback or
        input truncation by default.
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbeddingsRequest'
      responses:
        '200':
          description: Ordered embeddings and metered token usage.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbeddingsResponse'
        '400':
          description: Invalid or unsupported request parameter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Insufficient balance or project spend limit reached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Gateway error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: javascript
          label: TypeScript SDK
          source: >-
            import { NinjaChat } from "@ninjachat/sdk";

            const client = new NinjaChat({ apiKey:
            process.env.NINJACHAT_API_KEY! });

            const result = await client.embeddings.create({
              model: "text-embedding-3-small", input: ["A document to index"],
            });

            console.log(result.data[0].embedding);
        - lang: python
          label: Python SDK
          source: |-
            import os
            from ninjachat import NinjaChat
            client = NinjaChat(api_key=os.environ["NINJACHAT_API_KEY"])
            result = client.embeddings.create(
                model="text-embedding-3-small", input=["A document to index"],
            )
            print(result["data"][0]["embedding"])
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      schema:
        type: string
        minLength: 1
        maxLength: 255
      description: >-
        Safely retry the same logical write without duplicate billing or
        execution.
  schemas:
    EmbeddingsRequest:
      type: object
      properties:
        model:
          type: string
          enum:
            - text-embedding-3-small
            - voyage-4-large
        input:
          anyOf:
            - type: string
              minLength: 1
            - type: array
              items:
                type: string
                minLength: 1
              minItems: 1
            - type: array
              items:
                type: integer
                minimum: 0
              minItems: 1
            - type: array
              items:
                type: array
                items:
                  type: integer
                  minimum: 0
                minItems: 1
              minItems: 1
        dimensions:
          type: integer
          exclusiveMinimum: 0
        encoding_format:
          type: string
          enum:
            - float
            - base64
          default: float
        input_type:
          type: string
          enum:
            - query
            - document
        truncation:
          type: boolean
          default: false
        user:
          type: string
      required:
        - model
        - input
      additionalProperties: false
    EmbeddingsResponse:
      type: object
      properties:
        object:
          type: string
          enum:
            - list
        model:
          type: string
        data:
          type: array
          items:
            type: object
            properties:
              object:
                type: string
                enum:
                  - embedding
              index:
                type: integer
                minimum: 0
              embedding:
                anyOf:
                  - type: array
                    items:
                      type: number
                  - type: string
            required:
              - object
              - index
              - embedding
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
              minimum: 0
            total_tokens:
              type: integer
              minimum: 0
          required:
            - prompt_tokens
            - total_tokens
        cost_usd:
          type: number
          minimum: 0
        request_id:
          type: string
      required:
        - object
        - model
        - data
        - usage
        - cost_usd
        - request_id
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
            param:
              type:
                - string
                - 'null'
          required:
            - message
            - type
            - code
          additionalProperties: false
      required:
        - error
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: NinjaChat API key
      description: Use an API key created in the NinjaChat developer console.

````