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

# Create embeddings

> Generates embeddings for the given text input.



## OpenAPI

````yaml post /ml/v1alpha/embedding:embed
openapi: 3.0.0
info:
  title: ai/inworld/embedding/v1alpha/embedding_service.proto
  version: version not set
servers:
  - url: https://api.inworld.ai
security:
  - inworld_basic: []
tags:
  - name: CreateEmbeddings
paths:
  /ml/v1alpha/embedding:embed:
    post:
      tags:
        - EmbeddingService
      summary: Create embeddings
      description: Generates embeddings for the given text input.
      operationId: EmbeddingService_Embed
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/v1alphaEmbedRequest'
            examples:
              single_text:
                summary: Single text embeddings
                description: Simple example with a single text input
                value:
                  inputs:
                    - text: Hello Inworld!
                  model:
                    model: >-
                      sentence-transformers/paraphrase-multilingual-mpnet-base-v2
                    serviceProvider: SERVICE_PROVIDER_INWORLD
              multiple_texts:
                summary: Multiple text embeddings
                description: Example with multiple text inputs for batch processing
                value:
                  inputs:
                    - text: Hello Inworld!
                    - text: Could you please generate embeddings?
                    - text: Thanks!
                  model:
                    model: >-
                      sentence-transformers/paraphrase-multilingual-mpnet-base-v2
                    serviceProvider: SERVICE_PROVIDER_INWORLD
              semantic_search:
                summary: Semantic search use case
                description: Embeddings documents for semantic search functionality
                value:
                  inputs:
                    - text: How to implement machine learning models in production
                    - text: Best practices for deploying AI systems at scale
                    - text: Monitoring and observability for ML applications
                  model:
                    model: >-
                      sentence-transformers/paraphrase-multilingual-mpnet-base-v2
                    serviceProvider: SERVICE_PROVIDER_INWORLD
              multilingual_content:
                summary: Multilingual text embedding
                description: Processing text in different languages
                value:
                  inputs:
                    - text: Hello, how are you today?
                    - text: Hola, ¿cómo estás hoy?
                    - text: Bonjour, comment allez-vous aujourd'hui?
                    - text: こんにちは、今日はいかがですか？
                  model:
                    model: >-
                      sentence-transformers/paraphrase-multilingual-mpnet-base-v2
                    serviceProvider: SERVICE_PROVIDER_INWORLD
              long_text_content:
                summary: Long text embeddings
                description: Processing longer text content like paragraphs or articles
                value:
                  inputs:
                    - text: >-
                        Artificial intelligence has revolutionized the way we
                        interact with technology. From voice assistants to
                        recommendation systems, AI is becoming increasingly
                        integrated into our daily lives. Machine learning
                        algorithms can now process vast amounts of data to
                        identify patterns and make predictions with remarkable
                        accuracy. The field continues to evolve rapidly, with
                        new breakthroughs in deep learning, natural language
                        processing, and computer vision emerging regularly.
                  model:
                    model: >-
                      sentence-transformers/paraphrase-multilingual-mpnet-base-v2
                    serviceProvider: SERVICE_PROVIDER_INWORLD
              batch_processing_large:
                summary: Large batch processing
                description: >-
                  Processing a larger batch of texts efficiently in a single
                  request
                value:
                  inputs:
                    - text: Customer service inquiry about order status
                    - text: Product return request for damaged item
                    - text: Technical support ticket for login issues
                    - text: Billing question about subscription charges
                    - text: Feature request for mobile app improvement
                    - text: Feedback on recent website update
                    - text: Question about shipping options and delivery times
                    - text: Request for product catalog and pricing information
                  model:
                    model: >-
                      sentence-transformers/paraphrase-multilingual-mpnet-base-v2
                    serviceProvider: SERVICE_PROVIDER_INWORLD
        required: true
      responses:
        '200':
          description: A successful response message for Embed method
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v1alphaEmbedResponse'
              examples:
                single_embedding:
                  summary: Single text embeddings response
                  description: >-
                    Real example response from DEV (api.dev.inworld.ai), values
                    truncated.
                  value:
                    embeddings:
                      - values:
                          - -0.0034770966
                          - 0.014472961
                          - -0.0031032562
                          - 0.043792725
                          - 0.033081055
                          - 0.003566742
                          - -0.048217773
                          - 0.03970337
                          - 0.023040771
                          - 0.006038666
                multiple_embeddings:
                  summary: Multiple text embeddings response
                  description: Example response for  multiple text inputs embeddings
                  value:
                    embeddings:
                      - values:
                          - 0.009628296
                          - -0.03213501
                          - -0.0030879974
                          - 0.008979797
                          - 0.0146102905
                      - values:
                          - 0.02420044
                          - -0.013900757
                          - 0.029541016
                          - -0.037628174
                          - 0.061950684
        default:
          description: An unexpected error response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/rpcStatus'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl --location 'https://api.inworld.ai/ml/v1alpha/embedding:embed'
            \

            --header "Authorization: Basic $INWORLD_API_KEY" \

            --header 'Content-Type: application/json' \

            --data '{
              "inputs": [
                {
                  "text": "Hello Inworld!"
                }
              ],
              "model": {
                "model": "sentence-transformers/paraphrase-multilingual-mpnet-base-v2",
                "serviceProvider": "SERVICE_PROVIDER_INWORLD"
              }
            }'
        - lang: python
          label: Python
          source: |-
            import requests

            url = "https://api.inworld.ai/ml/v1alpha/embedding:embed"
            headers = {
                "Authorization": "Basic <api-key>",
                "Content-Type": "application/json"
            }
            payload = {
                "inputs": [
                    {"text": "Hello Inworld!"}
                ],
                "model": {
                    "model": "sentence-transformers/paraphrase-multilingual-mpnet-base-v2",
                    "serviceProvider": "SERVICE_PROVIDER_INWORLD"
                }
            }

            response = requests.post(url, json=payload, headers=headers)
            print(response.json())
        - lang: javascript
          label: JavaScript
          source: |-
            const url = 'https://api.inworld.ai/ml/v1alpha/embedding:embed';

            const response = await fetch(url, {
              method: 'POST',
              headers: {
                'Authorization': 'Basic <api-key>',
                'Content-Type': 'application/json',
              },
              body: JSON.stringify({
                inputs: [{ text: 'Hello Inworld!' }],
                model: {
                  model: 'sentence-transformers/paraphrase-multilingual-mpnet-base-v2',
                  serviceProvider: 'SERVICE_PROVIDER_INWORLD',
                },
              }),
            });

            const data = await response.json();
            console.log(data);
components:
  schemas:
    v1alphaEmbedRequest:
      type: object
      properties:
        inputs:
          type: array
          items:
            $ref: '#/components/schemas/v1alphaEmbedRequestInput'
          description: Input to embed.
        model:
          $ref: '#/components/schemas/v1alphaModelId'
          description: >-
            The ID of the model to be used to generate embeddings. If no
            model_id is specified, the default model will be used. See
            [Models](../../../models#embedding) for available models.
      description: >-
        Request message for Embed method. Contains the input texts and model
        configuration for the embeddings request
      required:
        - inputs
        - model
    v1alphaEmbedResponse:
      type: object
      properties:
        embeddings:
          type: array
          items:
            $ref: '#/components/schemas/v1alphaEmbedding'
          description: List of embeddings generated from the input messages
    rpcStatus:
      type: object
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
        details:
          type: array
          items:
            $ref: '#/components/schemas/protobufAny'
    v1alphaEmbedRequestInput:
      type: object
      properties:
        text:
          type: string
          description: Text string input
      required:
        - text
    v1alphaModelId:
      type: object
      properties:
        model:
          type: string
          description: >-
            The ID of the model to be used to generate embeddings. If no
            model_id is specified, the default model will be used. See
            [Models](../../../models#embedding) for available models.
        serviceProvider:
          $ref: '#/components/schemas/v1alphaServiceProvider'
          description: Service provider hosting model and handling requests
      description: >-
        The ID of the model to be used to generate embeddings. If no model_id is
        specified, the default model will be used. See
        [Models](../../../models#embedding) for available models.
      required:
        - model
        - serviceProvider
    v1alphaEmbedding:
      type: object
      properties:
        values:
          type: array
          items:
            type: number
            format: float
          description: The embeddings vector, which is a list of floats
      required:
        - values
    protobufAny:
      type: object
      properties:
        '@type':
          type: string
      additionalProperties: {}
    v1alphaServiceProvider:
      type: string
      enum:
        - SERVICE_PROVIDER_UNSPECIFIED
        - SERVICE_PROVIDER_INWORLD
        - SERVICE_PROVIDER_OPENAI
      default: SERVICE_PROVIDER_UNSPECIFIED
      description: |-
        Service provider hosting model and handling requests.

         - SERVICE_PROVIDER_UNSPECIFIED: No service provider specified. Default SERVICE_PROVIDER_INWORLD will be used
         - SERVICE_PROVIDER_INWORLD: Inworld service provider
  securitySchemes:
    inworld_basic:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Should follow the format Basic {credentials}. The {credentials} consists
        of the Base64-encoded string of the API key and the secret in the format
        key:secret. You can create a key in one command with the [Inworld
        CLI](../../../tts/resources/inworld-cli): `inworld workspace add-key`.

````