Embeddings
Turn text into vectors for semantic search, clustering, classification, and RAG. OpenAI-compatible — works with the official openai SDK by pointing it at api.airforce.
Authentication
Every request needs a Bearer token (your Airforce API key).
Authorization: Bearer sk-air-YOUR_API_KEYPOST /v1/embeddings
OpenAI-compatible Embeddings. Works with the official openai SDK by overriding base_url to https://api.airforce/v1.
https://api.airforce/v1/embeddingsRequest body
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | Embedding model ID — e.g. "text-embedding-3-small". See "Available models" below. |
| input | string | array | Required | The text to embed. Either a single string, or an array of strings to embed in one request — one vector is returned per item, in the same order. |
| encoding_format | string | Optional | "float" (default) returns each vector as an array of numbers; "base64" returns it as a base64-packed string. Forwarded to the provider. |
| dimensions | integer | Optional | Optional reduced output dimensionality, for models that support it (the text-embedding-3 family). Omit to get the model's native size. |
| user | string | Optional | Optional opaque end-user identifier, passed through for abuse monitoring. |
Example
curl https://api.airforce/v1/embeddings \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-3-small",
"input": "The quick brown fox jumps over the lazy dog"
}'Response
| Parameter | Type | Required | Description |
|---|---|---|---|
| object | string | Optional | Always "list". |
| data | array | Optional | One entry per input item: { object: "embedding", index, embedding }. The order matches your input array. |
| data[].embedding | array | string | Optional | The vector — an array of floats, or a base64 string when encoding_format is "base64". |
| model | string | Optional | The embedding model that answered. |
| usage | object | Optional | { prompt_tokens, total_tokens }. Embeddings have no completion, so total_tokens equals prompt_tokens and you are billed on input only. |
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0023064255, -0.009327292, 0.015797347, "…"]
}
],
"model": "text-embedding-3-small",
"usage": { "prompt_tokens": 9, "total_tokens": 9 }
}Pass an array of strings as input to embed many texts in a single call — the data array comes back in the same order, and you are billed for the combined token count.
Available models
Request any of these by its ID in the model field. Each one is served from a pool of upstream providers with automatic failover, so a single provider hiccup does not fail your request.
| Parameter | Type | Required | Description |
|---|---|---|---|
| text-embedding-3-small | 1536 dims | Optional | Fast, low-cost general-purpose embeddings. The usual default for RAG and semantic search. |
| text-embedding-3-large | 3072 dims | Optional | Higher-quality embeddings for when retrieval accuracy matters more than cost. |
| text-embedding-ada-002 | 1536 dims | Optional | Legacy model, kept for drop-in compatibility with existing indexes. |
埋め込みモデル
…· liveBilling is pay-as-you-go on input tokens only (embeddings have no completion). The per-million-token price is shown on each model's page and on your dashboard usage log; tiny requests round down to a fraction of a cent.
Using the OpenAI SDK
Point the official openai client at api.airforce and call embeddings.create as usual.
from openai import OpenAI
client = OpenAI(
api_key="sk-air-YOUR_API_KEY",
base_url="https://api.airforce/v1",
)
resp = client.embeddings.create(
model="text-embedding-3-small",
input=["First document", "Second document"],
)
for item in resp.data:
print(item.index, len(item.embedding))Rerank
クエリに対してドキュメントのリストを採点し、関連度順に並べて返します。ベクトル検索の後に使うと、最も良い一致が先頭に来ます。
https://api.airforce/v1/rerankRerank モデル
…· live| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | Rerank model ID. See the live list below. |
| query | string | Required | The search query the documents are scored against. |
| documents | array | Required | Up to 1,000 documents: plain strings, or objects with a text field. Forwarded unchanged. |
| top_n | integer | Optional | Return only the n most relevant documents. All when omitted. |
| return_documents | boolean | Optional | Include each document in its result, not only its index. |
| max_chunks_per_doc | integer | Optional | Split long documents into at most this many chunks (model-specific; ignored where unsupported). |
| overlap_tokens | integer | Optional | Token overlap between chunks (model-specific). |
| user | string | Optional | Your end-user identifier, forwarded for abuse monitoring. |
curl https://api.airforce/v1/rerank \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "BAAI/bge-reranker-v2-m3",
"query": "How do I rotate an API key?",
"documents": [
"Billing runs pay-as-you-go on input tokens.",
"Create a new key in the dashboard, switch your app to it, then delete the old key.",
"Embeddings return one vector per input string."
],
"top_n": 2
}'レスポンス形式
{
"results": [
{ "index": 1, "relevance_score": 0.97 },
{ "index": 0, "relevance_score": 0.08 }
],
"usage": { "total_tokens": 64 }
}index は documents 配列内の位置を指します。ボディはモデル提供元の応答をそのまま転送したものなので、一部のモデルでは使用量フィールドの名前が異なります。課金は入力トークンのみです。