Saltar para o conteúdo principal
POST
/
v1
/
embeddings
curl -X POST "https://api.lemondata.cc/v1/embeddings" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": "The quick brown fox jumps over the lazy dog"
  }'
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.0023, -0.0194, 0.0081, ...]
    }
  ],
  "model": "text-embedding-3-small",
  "usage": {
    "prompt_tokens": 9,
    "total_tokens": 9
  }
}

Corpo da Requisição

model
string
obrigatório
ID do modelo de embedding a ser usado (ex: text-embedding-3-small).
input
string | array
obrigatório
Texto de entrada para gerar o embedding. Pode ser uma string ou um array de strings.
encoding_format
string
padrão:"float"
Formato para os embeddings: float ou base64.
dimensions
integer
Número de dimensões para a saída (específico do modelo).
user
string
Um identificador único representando seu usuário final para monitoramento de abusos.

Modelos Disponíveis

ModeloDimensõesDescrição
text-embedding-3-large3072Melhor qualidade
text-embedding-3-small1536Equilibrado
text-embedding-ada-0021536Legado

Resposta

object
string
Sempre list.
data
array
Array de objetos de embedding.Cada objeto contém:
  • object (string): embedding
  • index (integer): Índice no array de entrada
  • embedding (array): O vetor de embedding
model
string
Modelo utilizado.
usage
object
Uso de tokens com prompt_tokens e total_tokens.
curl -X POST "https://api.lemondata.cc/v1/embeddings" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-embedding-3-small",
    "input": "The quick brown fox jumps over the lazy dog"
  }'
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.0023, -0.0194, 0.0081, ...]
    }
  ],
  "model": "text-embedding-3-small",
  "usage": {
    "prompt_tokens": 9,
    "total_tokens": 9
  }
}

Embeddings em Lote

# Embed multiple texts at once
response = client.embeddings.create(
    model="text-embedding-3-small",
    input=[
        "First document text",
        "Second document text",
        "Third document text"
    ]
)

for i, data in enumerate(response.data):
    print(f"Document {i}: {len(data.embedding)} dimensions")