Embeddings API#
POST /v1/embeddings turns text into vectors for semantic search, clustering, recommendations and retrieval. It is
OpenAI-compatible, so the official OpenAI SDKs and most vector-database integrations work by changing the base URL
and key. Requests are billed per input token from your Pay-2-Go wallet (Pay-2-Go (P2G) API).
Note
Embeddings are part of the Pay-2-Go API only. They are not available on the subscription Generation API
(/gen).
Quick start#
curl
curl https://api.inferenceport.ai/v1/embeddings \
-H "Authorization: Bearer $IP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-3-small",
"input": ["The cat sat on the mat.", "A kitten is resting on a rug."]
}'
Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(base_url="https://api.inferenceport.ai/v1", api_key="ipa_live_...")
result = client.embeddings.create(
model="text-embedding-3-small",
input=["The cat sat on the mat.", "A kitten is resting on a rug."],
)
print(len(result.data[0].embedding), result.usage.prompt_tokens)
ipx
$ ipx p2g embed "The cat sat on the mat." "A kitten is resting on a rug."
Request#
Field |
Type |
Description |
|---|---|---|
|
string |
Embedding model id or alias. Defaults to |
|
string or array |
Required. A string, or an array of at most 32 strings. At most 2,000,000 characters (8 MB) per request; empty items are rejected. Token-id arrays and multimodal content parts are not supported. |
|
string |
|
|
integer |
Optional, 128-4096. Shortens the vector; each model has its own ceiling (its |
|
string |
Optional retrieval hint for Gemini text input (for example |
|
string |
Optional retrieval role for Cohere: |
|
string |
Optional end-user identifier, forwarded to the provider. |
Any other field is ignored. Embeddings are text-only through this API: Gemini and Cohere can also embed images (and Gemini audio and video), but those inputs are not exposed here yet.
Response#
The body is the standard OpenAI shape. model is the InferencePort model id, and usage carries the credits charged
for the request:
{
"object": "list",
"model": "text-embedding-3-small",
"data": [
{ "object": "embedding", "index": 0, "embedding": [0.0123, -0.0456, 0.0789] },
{ "object": "embedding", "index": 1, "embedding": [0.0101, -0.0432, 0.0811] }
],
"usage": {
"prompt_tokens": 14,
"total_tokens": 14,
"payg_credits_charged": 0.0001
}
}
The same charge is returned in response headers:
Header |
Value |
|---|---|
|
Decimal credits charged for this request. |
|
Input tokens billed. |
|
Always |
Models#
GET /v1/embeddings/models lists every embedding model with its price, vector size and input limit (embeddings are also
part of GET /v1/models, with type: "embedding"; use ipx p2g models --type embedding from the CLI). Prices are in
credits (1 credit = 1 USD) per million input tokens.
Model id |
Provider |
Dimensions |
Input limit |
Price / M tokens |
|---|---|---|---|---|
|
OpenAI |
1536 |
8,192 |
0.02 |
|
OpenAI |
3072 |
8,192 |
0.13 |
|
3072 |
8,192 |
0.20 |
|
|
Cohere |
1536 |
128,000 |
0.12 |
|
Qwen |
4096 |
40,960 |
0.01 |
The list endpoint also returns supported_dimensions where a model accepts only specific sizes (Cohere), max_inputs
and the parameters each model understands (supported_parameters).
Each model also answers to its provider id (for example openai/text-embedding-3-large) and a few short aliases such as
embedding-small, embedding-large and qwen3-embedding; the list endpoint shows them all. Rates are the live values
from the model catalog, and the console always shows the current price.
Billing#
You are charged for the input tokens the provider reports; if a response carries no usage the request is billed on an estimate of the input size.
A request that fails upstream is not charged.
Reward discounts and per-user markups apply like they do for every other modality, and each request is written to your ledger as
usage_kind: "embedding"(unittokens).Before forwarding, the API checks that your balance covers the estimated cost (and at least 0.01 credits).
With an organization context (
X-InferencePort-Orgheader, or an organization API key) the request is billed to the organization’s wallet and the organization’s model andembeddingmodality policy applies.
Limits#
Requests are rate-limited per identity (120 per minute by default).
At most 32 inputs per request (
max_inputsin the model list); split larger jobs into batches.ipx p2g embeddoes this for you.
Errors#
Status |
Meaning |
|---|---|
|
Invalid |
|
Missing, invalid or revoked credential. |
|
Not enough credits for the request. |
|
The organization’s policy blocks this model or the |
|
Unknown embedding model. Other models (for example chat or realtime models) are not accepted here. |
|
|
|
Rate limit reached. |
|
The embedding provider could not be reached. |
Embedding models are not chat models: sending one to /v1/chat/completions returns 400 with a pointer to this
endpoint.