Router.Completions
Create a Completion
For sending requests to legacy completion modelsfrom orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.router.completions.create(model="XC90", prompt="<value>", echo=False, frequency_penalty=0, max_tokens=16, presence_penalty=0, temperature=1, top_p=1, n=1, 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,
}, stream=False)
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)
Show Parameters
Show Parameters
{
"model": str, # required
"prompt": str, # required
"echo": OptionalNullable[bool],
"frequency_penalty": OptionalNullable[float],
"max_tokens": OptionalNullable[float],
"presence_penalty": OptionalNullable[float],
"seed": OptionalNullable[float],
"stop": Union[str, List[str]],
"temperature": OptionalNullable[float],
"top_p": OptionalNullable[float],
"n": OptionalNullable[float],
"user": Optional[str],
"name": Optional[str],
"fallbacks": { # optional
"model": str, # required
},
"retry": { # optional
"count": Optional[float],
"on_codes": List[float],
},
"cache": { # optional
"ttl": Optional[float],
"type": Literal["exact_match"], # required
},
"load_balancer": Union[CreateCompletionLoadBalancer1],
"timeout": { # optional
"call_timeout": float, # required
},
"thinking": Union[ThinkingConfigDisabledSchema, ThinkingConfigEnabledSchema, ThinkingConfigAdaptiveSchema],
"orq": { # optional
"name": Optional[str],
"retry": { # optional
"count": Optional[float],
"on_codes": List[float],
},
"fallbacks": { # optional
"model": str, # required
},
"prompt": { # optional
"id": str, # required
"version": Literal["latest"], # required
},
"identity": { # optional
"id": str, # required
"display_name": Optional[str],
"email": Optional[str],
"metadata": List[Dict[str, Any]],
"logo_url": Optional[str],
"tags": List[str],
},
"~~`contact`~~": { # optional
"id": str, # required
"display_name": Optional[str],
"email": Optional[str],
"metadata": List[Dict[str, Any]],
"logo_url": Optional[str],
"tags": List[str],
},
"thread": { # optional
"id": str, # required
"tags": List[str],
},
"~~`inputs`~~": Union[Dict[str, Any], List[CreateCompletionInputs2]],
"cache": { # optional
"ttl": Optional[float],
"type": Literal["exact_match"], # required
},
"knowledge_bases": { # optional
"top_k": Optional[int],
"threshold": Optional[float],
"search_type": Optional[Literal["vector_search", "keyword_search", "hybrid_search"]],
"filter_by": Union[Dict[str, CreateCompletionFilterBy1], CreateCompletionFilterByAnd, CreateCompletionFilterByOr],
"search_options": { # optional
"include_vectors": Optional[bool],
"include_metadata": Optional[bool],
"include_scores": Optional[bool],
},
"rerank_config": { # optional
"model": str, # required
"threshold": Optional[float],
"top_k": Optional[int],
},
"agentic_rag_config": { # optional
"model": str, # required
},
"knowledge_id": str, # required
"query": Optional[str],
},
"load_balancer": Union[CreateCompletionLoadBalancerRouterCompletions1],
"timeout": { # optional
"call_timeout": float, # required
},
},
"stream": Optional[bool],
}
Show Response
Show Response
{
"id": str,
"choices": {
"finish_reason": Literal["stop", "length", "content_filter", "tool_calls"],
"index": float,
"text": str,
},
"created": Union[str, float],
"model": str,
"system_fingerprint": Optional[str],
"object": str,
"usage": { # optional
"completion_tokens": Optional[float],
"prompt_tokens": Optional[float],
"total_tokens": Optional[float],
"prompt_tokens_details": { # optional
"cached_tokens": OptionalNullable[int],
"cache_creation_tokens": OptionalNullable[int],
"audio_tokens": OptionalNullable[int],
},
"completion_tokens_details": { # optional
"reasoning_tokens": OptionalNullable[float],
"accepted_prediction_tokens": OptionalNullable[float],
"rejected_prediction_tokens": OptionalNullable[float],
"audio_tokens": OptionalNullable[int],
},
},
}