OpenAI: Text Embedding 3 Large

9 tokens

by openai
N/A context$0.13/M input

text-embedding-3-large is OpenAI's new next generation larger embedding model and creates embeddings with up to 3072 dimensions.

Last update: 5/3/2024

Embeddings Requests

To get an embedding, send your text to the embeddings API endpoint with the model name. The response will include an embedding as a list of numbers that you can save in a vector database.

REST API

fetch("https://api.monolyth.ai/v1/embeddings", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${MONOLYTH_API_KEY}`,
    "HTTP-Referer": `${YOUR_SITE_URL}`, // Optional, Shows in analytics dashboard on monolyth.ai
    "X-Name": `${YOUR_SITE_NAME}`, // Optional, Shows in analytics dashboard on monolyth.ai
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "text-embedding-3-small",
    input: "What is your dream?",
  }),
});

OpenAI SDK Integration

import OpenAI from "openai"
 
const openai = new OpenAI({
    baseURL: "https://api.monolyth.ai/v1",
    apiKey: $MONOLYTH_API_KEY,
    defaultHeaders: {
        "HTTP-Referer": $YOUR_SITE_URL, // Optional, Shows in analytics dashboard on monolyth.ai
        "X-Name": $YOUR_APP_NAME, // Optional, Shows in analytics dashboard on monolyth.ai
    },
})
async function main() {
    const embeddings = await openai.embeddings.create({
        model: "text-embedding-3-small",
        input: "What is your dream?",
        encoding_format: "float",
    })
    console.log(embeddings)
}
 
main()

Embeddings Responses

{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [
        -0.006929283495992422,
        -0.005336422007530928,
        ...
        -4.547132266452536e-05,
        -0.024047505110502243
      ],
    }
  ],
  "model": "text-embedding-3-small",
  "usage": {
    "prompt_tokens": 5,
    "total_tokens": 5
  }
}

The default embedding vector length is 1536 for and 3072 for . You can adjust the parameter to reduce the size while preserving conceptual integrity. More details are available in the embedding use case section.

Embeddings Parameters

ParameterDescription
Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for text-embedding-ada-002), cannot be an empty string, and any array must be 2048 dimensions or less.
ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.
The number of dimensions the resulting output embeddings should have. Only supported in and later models.