Retrieval workflow: embed, shortlist and rerank
Build retrieval with UplinkSwitch embeddings and rerank, keep indexing in your application and distinguish documented routes from moderation availability.
A retrieval pipeline chooses useful evidence before a generation request starts. Use an embedding model to support similarity search, keep the vectors and source references in your own storage, then rerank the candidates against the current question. This page describes that application workflow; the embeddings and rerank reference is the related operation reference.
Check the catalog by operation
The public GET /v1/catalog needs no key. Inspect each entry’s type, endpoints and availability, rather than assuming a model that can chat can also embed or rerank.
| Identifier | Type | Endpoint | Availability |
|---|---|---|---|
bge-m3 | embedding | /v1/embeddings | ok |
bge-reranker-base | rerank | /v1/rerank | ok |
These are catalog observations, not inference results from this workflow. The catalog snapshot was generated on 2026-11-24; refresh it before selecting a production dependency.
OpenAPI declares POST /v1/moderations with default model text-moderation-latest. The catalog determines whether a moderation model is currently available, so check its type and availability before adding moderation to a production pipeline.
1. Embed the source text
POST /v1/embeddings requires string model and input as a string or array. The body ceiling is 10 MB and additional properties are allowed. HTTP 200 is described as the model’s OpenAI-format embedding list, but the typed response is an open object.
For vector dimensions, exact response members or encoding guarantees, the OpenAPI document does not say. Confirm those details before choosing the schema of your vector store. The API contract does not specify a hosted vector index, document chunker or retrieval database for this workflow; those are application responsibilities.
For a prepared corpus, the batch workflow can execute uploaded embedding requests. Its input format and authenticated result files are covered by Files. Check the batch window and per-line results before treating an index refresh as complete.
2. Retrieve candidates in your application
Keep each candidate’s source identifier with its text. Similarity search and access filtering happen in your application before reranking. This ordering is a design recommendation, not a claim that the API evaluates document access rights.
Use a candidate limit appropriate for the next operation. Sending the whole corpus to a reranker changes the request size and the number of documents scored; the query remains the same input for that request.
3. Score the shortlist
POST /v1/rerank requires string model, string query and array documents. Documents may be strings or objects with text; the description caps the array at 1,000 and the body at 2 MB. Optional integer top_n selects how many results to return, and optional boolean return_documents requests the text in those results.
This illustrative request uses an ordinary key in UPLINKSWITCH_API_KEY. Executing it consumes balance.
curl --fail-with-body 'https://api.uplinkswitch.com/v1/rerank' \
-H "Authorization: Bearer ${UPLINKSWITCH_API_KEY}" \
-H 'Content-Type: application/json' \
--data '{"model":"bge-reranker-base","query":"How do we reconcile a completed import?","documents":["The import checklist compares accepted and rejected row totals.","The deployment guide describes choosing a region."],"top_n":1,"return_documents":true}'The response requires id, object: list, model, results and usage. Results arrive best first. Each requires integer index, pointing to the original document array, and numeric relevance_score, where larger means more relevant. Optional document.text echoes the passage. The required usage object declares optional integer prompt_tokens and total_tokens.
Map each result index back to your stored source reference before assembling context. A relevance score ranks candidates; it does not verify the truth of a passage or establish a calibrated probability.
Cost and failure boundaries
Rerank counts the query once for each document: the cross-encoder reads each query-document pair. Input tokens are estimated at about four characters per token and billed at the catalog rate. Its description states that failed requests are not charged. top_n reduces returned results, not the submitted candidates read by the model.
Both retrieval operations use API-key authentication, and their 403 responses explicitly reject admin keys for inference. For console-session access, the OpenAPI document does not say. Both declare 200 success and errors for invalid input (400), invalid key (401), balance or budget failures (402), scope or account failures (403), unknown model (404), body size (413), throttling (429) and upstream failures (502/503). Embeddings includes additional error cases; consult its complete response table rather than assuming both operations share every code.
SDK setup leads to the connection guide. Keep retry behavior sensitive to the reported error: a caller configuration or permission failure is different from a temporarily unavailable route.