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

# Generate text embedding

> ### Description
Computes the text embeddings for text fragments using the model with the given model_deployment_id.

### Details
Users can use this API to execute EMBEDDING type EGP model they have access to. To use this API, pass in         the `id` of a model returned by the V3 Create Model API. An example text embedding request

```json
{
    "texts": ["Please compute my embedding vector", "Another text fragment"]
}
```



## OpenAPI

````yaml https://app.stainlessapi.com/api/spec/documented/sgp/openapi.yml post /v4/models/{model_deployment_id}/embeddings
openapi: 3.1.0
info:
  title: EGP API V4
  description: >-
    This is the parent API for all EGP APIs. If you are looking for the EGP API,
    please go to https://api.egp.scale.com/docs.
  contact:
    name: Scale Generative AI Platform
    url: https://scale.com/genai-platform
  version: 0.1.0
servers:
  - url: https://api.egp.scale.com
security: []
tags:
  - name: Models
    description: Model API.
paths:
  /v4/models/{model_deployment_id}/embeddings:
    post:
      tags:
        - Models
      summary: Generate text embedding
      description: >-
        ### Description

        Computes the text embeddings for text fragments using the model with the
        given model_deployment_id.


        ### Details

        Users can use this API to execute EMBEDDING type EGP model they have
        access to. To use this API, pass in         the `id` of a model returned
        by the V3 Create Model API. An example text embedding request


        ```json

        {
            "texts": ["Please compute my embedding vector", "Another text fragment"]
        }

        ```
      operationId: POST-V4-/v3/models/{model_deployment_id}/embeddings
      parameters:
        - name: model_deployment_id
          in: path
          required: true
          schema:
            title: Model Deployment Id
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EmbeddingRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EmbeddingResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from scale_gp import SGPClient

            client = SGPClient(
                api_key=os.environ.get("SGP_API_KEY"),  # This is the default and can be omitted
            )
            embedding_response = client.models.embeddings.create(
                model_deployment_id="model_deployment_id",
                texts=["string"],
            )
            print(embedding_response.embeddings)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/stainless-sdks/sgp-go\"\n\t\"github.com/stainless-sdks/sgp-go/option\"\n)\n\nfunc main() {\n\tclient := sgp.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tembeddingResponse, err := client.Models.Embeddings.New(\n\t\tcontext.TODO(),\n\t\t\"model_deployment_id\",\n\t\tsgp.ModelEmbeddingNewParams{\n\t\t\tTexts: sgp.F([]string{\"string\"}),\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", embeddingResponse.Embeddings)\n}\n"
components:
  schemas:
    EmbeddingRequest:
      properties:
        model_request_parameters:
          $ref: '#/components/schemas/ParameterBindings'
        texts:
          items:
            type: string
          type: array
          title: Texts
      additionalProperties: false
      type: object
      required:
        - texts
      title: EmbeddingRequest
    EmbeddingResponse:
      properties:
        embeddings:
          items:
            prefixItems:
              - type: string
              - items:
                  type: number
                type: array
            type: array
            maxItems: 2
            minItems: 2
          type: array
          title: Embeddings
        tokens_used:
          title: Tokens Used
          default: 0
          type: integer
      additionalProperties: false
      type: object
      required:
        - embeddings
      title: EmbeddingResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ParameterBindings:
      properties:
        bindings:
          additionalProperties:
            anyOf:
              - type: string
              - type: integer
              - type: number
              - type: boolean
          type: object
          title: Bindings
      additionalProperties: false
      type: object
      required:
        - bindings
      title: ParameterBindings
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
          additionalProperties: true
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````