Router.Embeddings
Create an Embedding
Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.router.embeddings.create(input=[
"<value 1>",
"<value 2>",
], model="V90", encoding_format="float", fallbacks=[
{
"model": "openai/text-embedding-3-small",
},
], retry={
"on_codes": [
429,
500,
502,
503,
504,
],
}, cache={
"ttl": 3600,
"type": "exact_match",
}, load_balancer={
"type": "weight_based",
"models": [
{
"model": "openai/gpt-4o",
"weight": 0.7,
},
],
}, timeout={
"call_timeout": 30000,
}, orq={
"fallbacks": [
{
"model": "openai/gpt-4o-mini",
},
],
"cache": {
"ttl": 3600,
"type": "exact_match",
},
"retry": {
"on_codes": [
429,
500,
502,
503,
504,
],
},
"identity": {
"id": "contact_01ARZ3NDEKTSV4RRFFQ69G5FAV",
"display_name": "Jane Doe",
"email": "jane.doe@example.com",
"metadata": [
{
"department": "Engineering",
"role": "Senior Developer",
},
],
"logo_url": "https://example.com/avatars/jane-doe.jpg",
"tags": [
"hr",
"engineering",
],
},
"load_balancer": {
"type": "weight_based",
"models": [
{
"model": "openai/gpt-4o",
"weight": 0.7,
},
{
"model": "anthropic/claude-3-5-sonnet",
"weight": 0.3,
},
],
},
"timeout": {
"call_timeout": 30000,
},
})
# Handle response
print(res)
Show Parameters
Show Parameters
Input text to embed, encoded as a string or array of tokens.
ID of the model to use
Type of the document element
The number of dimensions the resulting output embeddings should have.
A unique identifier representing your end-user
The name to display on the trace. If not specified, the default system name will be used.
Array of fallback models to use if primary model fails
Retry configuration for the request
Show Properties of retry
Show Properties of retry
Number of retry attempts (1-5)
Cache configuration for the request.
Show Properties of cache
Show Properties of cache
Time to live for cached responses in seconds. Maximum 259200 seconds (3 days).
Load balancer configuration for the request.
Timeout configuration to apply to the request. If the request exceeds the timeout, it will be retried or fallback to the next model if configured.
Show Response
Show Response
ID of the model to used.