Embeddings
Vectors for semantic search, clustering, recommendations and RAG.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | An embedding model id, e.g. text-embedding-3-large. |
| input | string|array | Required | One string, or a batch of up to 2,048. The batch is capped at 2,000,000 characters in total. |
| encoding_format | string | Optional | One of:floatbase64 Default float |
| dimensions | integer | Optional | Truncate the vector, on models that support shortening. |
| user | string | Optional | A stable id for your own end user. |
Code examples
import os from openai import OpenAI client = OpenAI( api_key=os.environ["OXYY_API_KEY"], base_url="https://api.oxyy.ai/v1" ) # `input` takes one string or a batch of up to 2048. response = client.embeddings.create( model="text-embedding-3-large", input=["The quick brown fox", "jumps over the lazy dog"], encoding_format="float", dimensions=1024, ) for item in response.data: print(item.index, len(item.embedding))
curl https://api.oxyy.ai/v1/embeddings \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OXYY_API_KEY" \ -d '{ "model": "text-embedding-3-large", "input": "The quick brown fox", "encoding_format": "float" }'
Example response
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0023, -0.0091, 0.0156, -0.0042, "..."]
}
],
"model": "text-embedding-3-large",
"usage": { "prompt_tokens": 8, "total_tokens": 8, "cost": 0.0000011 }
}Available models
Reranking
Orders documents by how relevant each is to a query, the usual step after a vector search. The request and the answer follow Cohere's v2 rerank API; the OpenAI SDKs have no rerank call, so send it as plain JSON. Name a rerank model in model (required); rerank models are listed with the text models in the catalogue.
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | string | Required | A non-empty string. |
| documents | array | Required | 1 to 1,000 strings or {"text": "…"} objects. The query and documents are capped at 2,000,000 characters in total. |
| top_n | integer | Optional | Return only the best n results. |
| return_documents | boolean | Optional | Add each document's text to its result. Default false |
Other fields are passed to the provider as sent (Cohere's max_tokens_per_doc, for example). The answer is {"id", "model", "results": [{"index", "relevance_score", "document"}], "meta": {"api_version", "billed_units"}, "usage": {"total_tokens"}}, best result first, where index is the document's position in your request and document is there only with return_documents. A model is priced per search (the provider's search units, or one per request) or per input token.
Moderation
Classifies text or images against the provider's content policy, in OpenAI's shape, so client.moderations.create works. model is required: unlike on OpenAI there is no default, so name a moderation model (they are listed with the text models in the catalogue).
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | string|array | Required | A non-empty string, or up to 2,048 strings, or up to 2,048 content parts: {"type": "text", "text"} and {"type": "image_url", "image_url": {"url"}}. Strings and parts are not mixed. The text is capped at 2,000,000 characters in total. |
The answer is {"id": "modr-…", "model", "results": [...]}, where results are the provider's own (flagged, categories, category_scores), one per input string. An image URL is handed to the provider; the gateway does not fetch it. A model is priced per request or per input token; one priced at zero is free.
