apicheats.dev openai/llms.txt Raw .md
POST

POST /embeddings — OpenAI API

OpenAI API key (required); https://api.openai.com/v1

OpenAI API

Create embeddings

Base URL
https://api.openai.com/v1
Auth
Authorization: Bearer <OPENAI_API_KEY>
Last verified
2026-10-20 · upstream hash matched
Actions Try in browser→
Agents: curl -H "Accept: text/markdown" this URL
→ 316 tokens · Vary: Accept

Critical gotchas

The Responses API is the primary interface for new text and tool workflows; Chat Completions remains a separate compatibility API.

Audio transcription uploads use multipart form data rather than a JSON request body.

cURL

curl -X POST 'https://api.openai.com/v1/embeddings' \  -H "Authorization: Bearer $OPENAI_API_KEY" \  -H 'Content-Type: application/json' \  -d '{  "input": "The quick brown fox jumped over the lazy dog",  "model": "text-embedding-3-small"}'

Parameters

Name In Type Required Description
input body string Yes 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 all embedding models), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. In addition to the per-input token limit, all embedding models enforce a maximum of 300,000 tokens summed across all inputs in a single request.
model body string Yes ID of the model to use. You can use the [List models](https://developers.openai.com/api/reference/resources/models/methods/list) API to see all of your available models, or see our [Model overview](https://developers.openai.com/api/docs/models) for descriptions of them.
encoding_format body string No The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/).
dimensions body integer No The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models.
user body string No A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://developers.openai.com/api/docs/guides/safety-best-practices#implement-safety-identifiers).

Response 200 OK

{
  "data": [
    {
      "index": 0,
      "embedding": [
        0
      ],
      "object": "embedding"
    }
  ],
  "model": "string",
  "object": "list",
  "usage": {
    "prompt_tokens": 0,
    "total_tokens": 0
  }
}
Get a free OpenAI API key → sponsored

Affiliate link - we may earn a commission, at no extra cost to you.