/v1/embeddings/v1/embeddings
Turn text, images, audio or video into vectors with one synchronous call. The request body follows OpenAI's embeddings schema, so the official openai SDK works with only the base URL changed. Embeddings bill on input tokens only — there is no output meter. Rates are on the pricing page.
Request#
input is one string or an array; each element becomes one vector, returned in the same order. A string is embedded as text. For images, audio or video, send an object instead of a string — see the input types section.
curl https://api.atptoken.ai/v1/embeddings \
-H "Authorization: Bearer $ATP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-embedding-2-text",
"input": ["first passage", "second passage"]
}'Parameters#
Only model and input are required.
Response#
{
"object": "list",
"model": "gemini-embedding-2-text",
"data": [
{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, ...] },
{ "object": "embedding", "index": 1, "embedding": [0.0078, 0.0211, ...] }
],
"usage": { "prompt_tokens": 11, "total_tokens": 11 }
}data[].indexis the position of that element ininput.usage.prompt_tokensis the billed amount, summed over every element in the request.- A batch is all-or-nothing: if any element fails, the request returns an error and nothing is billed.
Models#
The four Gemini ids are one model with one meter per content type. They write vectors into the same 3072-dimension space, so a vector from one can be compared with a vector from another — text against images, or a query against a video. Rates per id are on the pricing page.
Input types#
Each element of input is one of the following:
Objects are forwarded as sent. A part the model cannot use — an unknown key, a file over its limit, or a URL it cannot fetch — returns 400 with the model's own message.
Request with an image
curl https://api.atptoken.ai/v1/embeddings \
-H "Authorization: Bearer $ATP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-embedding-2-image",
"input": [
{ "inlineData": { "mimeType": "image/png", "data": "iVBORw0KGgo..." } }
]
}'Every Gemini id accepts every element type, and the request bills at the rate of the id you called. Send images through gemini-embedding-2-image, audio through -audio, video through -video, and text through -text.
Billing#
Embeddings bill on input tokens only. For the Gemini ids the token count follows the content: text by tokens, image at 258 tokens per image, audio at 25 tokens per second, and video at 66 tokens per frame at one frame per second. A content element with several parts bills the sum of its parts. Every element shares one 8,192-token window, and content past it is dropped rather than refused. How tokens turn into credits is on Credits.