# Class Embedding

java.lang.Object
com.codename1.ai.Embedding

public final class Embedding extends Object
One vector returned by an embedding provider. The vector is defensively copied on construction and access so callers cannot mutate stored results. `getIndex()` identifies the corresponding input position in a batched `EmbeddingRequest`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Embedding(float[] vector, int index)`
  Creates an embedding result.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getDimensions()`
  `int`
  `getIndex()`
  `float[]`
  `getVector()`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Embedding

    public Embedding(float[] vector, int index)
    Creates an embedding result.
    Parameters:
      `vector` - numeric embedding coordinates, defensively copied; a `null` value creates an empty vector
      `index` - zero-based position of the corresponding request input

- ## Method Details

  - ### getVector

    public float[] getVector()
    Returns:
      a defensive copy of the embedding coordinates

  - ### getIndex

    public int getIndex()
    Returns:
      zero-based position of this item in the request

  - ### getDimensions

    public int getDimensions()
    Returns:
      number of coordinates in the embedding