Skip to content
RunAPI Developer Docs
API Reference
API Reference

OpenAI Embeddings

Send a request through RunAPI's OpenAI-compatible Embeddings operation.

01

Overview

Use RunAPI's OpenAI-compatible Embeddings operation with a compatible model and the protocol's request and response shapes.

Quick start

  1. Create an API key and set it as RUNAPI_API_KEY.
  2. Choose a compatible model, then send the documented path parameters and JSON body.
  3. Read the JSON response or server-sent events shown for this operation, and handle protocol errors.

Endpoint

POST /v1/embeddings
Base URL
https://runapi.ai
Contract version
v1
Preferred authentication
Authorization: Bearer YOUR_API_TOKEN
02

Authentication carriers

RunAPI accepts each carrier listed below. Generated samples use the protocol's preferred header.

header - Preferred
Authorization: Bearer YOUR_API_TOKEN
header
x-api-key: YOUR_API_TOKEN
header
x-goog-api-key: YOUR_API_TOKEN
query
?key=YOUR_API_TOKEN
03

Compatible models

Open a model page for current pricing, rate limits, and commercial-usage details.

Show 3 compatible models
04

Request contract

JSON body

Only fields with both public protocol and RunAPI support evidence are listed. Additional JSON body fields are passed through.

JSON body4 fields
dimensionsinteger
Optional

Requested output vector dimensions for models that support it.

encoding_formatstring
Optional

Format used for returned embedding vectors.

input["string", "array"]
Required

Text or token arrays to embed.

modelstring
Required

RunAPI embedding model identifier.

Request example

JSON
{
  "input": "The quick brown fox.",
  "model": "text-embedding-3-small"
}
05

Synchronous response

HTTP 200

Schema

JSON
{
  "additionalProperties": true,
  "properties": {
    "data": {
      "type": "array"
    },
    "model": {
      "type": "string"
    },
    "object": {
      "const": "list",
      "type": "string"
    },
    "usage": {
      "additionalProperties": true,
      "properties": {
        "prompt_tokens": {
          "type": "integer"
        },
        "total_tokens": {
          "type": "integer"
        }
      },
      "required": [
        "prompt_tokens",
        "total_tokens"
      ],
      "type": "object"
    }
  },
  "required": [
    "object",
    "data",
    "model",
    "usage"
  ],
  "type": "object"
}

Example

JSON
{
  "data": [
    {
      "embedding": [
        0.0023,
        -0.0093,
        0.0151
      ],
      "index": 0,
      "object": "embedding"
    }
  ],
  "model": "text-embedding-3-small",
  "object": "list",
  "usage": {
    "prompt_tokens": 5,
    "total_tokens": 5
  }
}
06

Protocol error: invalid_request

HTTP 400

Schema

JSON
{
  "additionalProperties": true,
  "properties": {
    "error": {
      "additionalProperties": true,
      "properties": {
        "code": {
          "type": [
            "string",
            "null"
          ]
        },
        "message": {
          "type": "string"
        },
        "param": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "message",
        "type"
      ],
      "type": "object"
    }
  },
  "required": [
    "error"
  ],
  "type": "object"
}

Example

JSON
{
  "error": {
    "code": null,
    "message": "input is required",
    "param": "input",
    "type": "invalid_request_error"
  }
}
07

Usage

Schema

JSON
{
  "additionalProperties": true,
  "properties": {
    "prompt_tokens": {
      "type": "integer"
    },
    "total_tokens": {
      "type": "integer"
    }
  },
  "required": [
    "prompt_tokens",
    "total_tokens"
  ],
  "type": "object"
}

Example

JSON
{
  "prompt_tokens": 5,
  "total_tokens": 5
}
08

Generated Code Samples

Each cURL, JavaScript, and Python sample sends the validated request from this contract without requiring a protocol-specific SDK.

CURL
curl -X POST https://runapi.ai/v1/embeddings \
  -H Authorization:\ Bearer\ YOUR_API_TOKEN \
  -H Content-Type:\ application/json \
  -d \{\"model\":\"text-embedding-3-small\",\"input\":\"The\ quick\ brown\ fox.\"\}
JAVASCRIPT
const response = await fetch("https://runapi.ai/v1/embeddings", {
  method: "POST",
  headers: {
  "Authorization": "Bearer YOUR_API_TOKEN",
  "Content-Type": "application/json"
},
  body: JSON.stringify({
  "model": "text-embedding-3-small",
  "input": "The quick brown fox."
})
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
console.log(data);

Install

BASH
pip install requests
PYTHON
import requests

response = requests.post(
    "https://runapi.ai/v1/embeddings",
    headers={"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"},
    json={"model": "text-embedding-3-small", "input": "The quick brown fox."}
)
response.raise_for_status()
print(response.json())