Embeddings
The OpenAI embeddings API for text or token-ID input, single or batched.
Create embeddings
model must be an embedding model available to your key (check GET /v1/models); text-embedding-3-small, text-embedding-3-large and text-embedding-ada-002 are the OpenAI targets. Match results to inputs by data[].index. /api/v1/embeddings relays to the same route.
/v1/embeddingscurl https://api.experientiallabs.ai/v1/embeddings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "text-embedding-3-small", "input": ["first document", "second document"]}'Request fields
Unknown fields are rejected, not ignored.
| Field | Contract |
|---|---|
model | Required; an embedding model (a chat model is 400 unsupported_capability) |
input | Required. A nonempty string, a list of nonempty strings, a token-ID array (one vector), or a list of token-ID arrays (a batch). No mixing text and tokens, no empty items, negative ids, floats or booleans |
dimensions | Optional; only on models that support it (text-embedding-3-* yes, ada-002 no) |
encoding_format | float (raw HTTP default) or base64. The OpenAI Python SDK asks for base64 and decodes it for you |
stream | Omit or false; true is unsupported |
user | Optional, at most 1,024 characters, not forwarded upstream |
Token ids must match the model's tokenizer; they are forwarded as is.
import tiktoken
enc = tiktoken.encoding_for_model("text-embedding-3-small")
batches = [enc.encode(t) for t in ["A short document.", "A second document."]]
r = client.embeddings.create(model="text-embedding-3-small", input=batches)Billing, retries, caching
Billed on provider-reported input tokens (usage.prompt_tokens equals total_tokens); no output tokens. On BYOK your provider bills you. There is no response cache and Idempotency-Key is not honored: a repeated request can be charged again, so store vectors yourself and retry deliberately (the examples set SDK retries to 0). Errors: 400 invalid_parameter (fix param), 400 unsupported_parameter (remove the field).
from langchain_openai import OpenAIEmbeddings
emb = OpenAIEmbeddings(
model="text-embedding-3-small",
base_url="https://api.experientiallabs.ai/v1",
api_key="YOUR_API_KEY",
)
vectors = emb.embed_documents(["A small example.", "A second document."])