OpenAI Embeddings
Send a request through RunAPI's OpenAI-compatible Embeddings operation.
Overview
Use RunAPI's OpenAI-compatible Embeddings operation with a compatible model and the protocol's request and response shapes.
Quick start
- Create an API key and set it as RUNAPI_API_KEY.
- Choose a compatible model, then send the documented path parameters and JSON body.
- Read the JSON response or server-sent events shown for this operation, and handle protocol errors.
Endpoint
- Base URL
https://runapi.ai- Contract version
v1- Preferred authentication
Authorization: Bearer YOUR_API_TOKEN
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
Compatible models
Open a model page for current pricing, rate limits, and commercial-usage details.
Show 3 compatible models
Request contract
Only fields with both public protocol and RunAPI support evidence are listed. Additional JSON body fields are passed through.
JSON body4 fields
dimensionsintegerRequested output vector dimensions for models that support it.
encoding_formatstringFormat used for returned embedding vectors.
input["string", "array"]Text or token arrays to embed.
modelstringRunAPI embedding model identifier.
Request example
{
"input": "The quick brown fox.",
"model": "text-embedding-3-small"
}
Synchronous response
Schema
{
"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
{
"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
}
}
Protocol error: invalid_request
Schema
{
"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
{
"error": {
"code": null,
"message": "input is required",
"param": "input",
"type": "invalid_request_error"
}
}
Usage
Schema
{
"additionalProperties": true,
"properties": {
"prompt_tokens": {
"type": "integer"
},
"total_tokens": {
"type": "integer"
}
},
"required": [
"prompt_tokens",
"total_tokens"
],
"type": "object"
}
Example
{
"prompt_tokens": 5,
"total_tokens": 5
}
Generated Code Samples
Each cURL, JavaScript, and Python sample sends the validated request from this contract without requiring a protocol-specific SDK.
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.\"\}
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
pip install requests
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())