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
ID of the model to use
The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.
Echo back the prompt in addition to the completion
Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.
The maximum number of tokens that can be generated in the completion.
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics.
If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.
Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly consume your token quota.
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
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.
Configuration for the thinking mode capability. Set type to
adaptive for models that support adaptive thinking (e.g. Claude Opus 4.6, Sonnet 4.6), or enabled with budget_tokens for manual control.Leverage Orq’s intelligent routing capabilities to enhance your AI application with enterprise-grade reliability and observability. Orq provides automatic request management including retries on failures, model fallbacks for high availability, identity-level analytics tracking, conversation threading, and dynamic prompt templating with variable substitution.
Show Properties of ~~`orq`~~
Show Properties of ~~`orq`~~
The name to display on the trace. If not specified, the default system name will be used.
Retry configuration for the request
Show Properties of retry
Show Properties of retry
Number of retry attempts (1-5)
Array of fallback models to use if primary model fails
Prompt configuration for the request
Show Properties of prompt
Show Properties of prompt
Unique identifier of the prompt to use
Information about the identity making the request. If the identity does not exist, it will be created automatically.
Show Properties of identity
Show Properties of identity
@deprecated Use identity instead. Information about the contact making the request.
Show Properties of ~~`contact`~~
Show Properties of ~~`contact`~~
Thread information to group related requests
Show Properties of thread
Show Properties of thread
Unique thread identifier to group related invocations.
@deprecated Use top-level
variables field instead. Values to replace in the prompt messages using {{variableName}} syntax.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).
Show Properties of knowledgeBases
Show Properties of knowledgeBases
The number of results to return. If not provided, will default to the knowledge base configured
top_k.The threshold to apply to the search. If not provided, will default to the knowledge base configured
thresholdThe type of search to perform. If not provided, will default to the knowledge base configured
retrieval_typeThe metadata filter to apply to the search. Check the Searching a Knowledge Base for more information.
Override the rerank configuration for this search. If not provided, will use the knowledge base configured rerank settings.
Show Properties of rerankConfig
Show Properties of rerankConfig
The name of the rerank model to use. Refer to the model list.
The threshold value used to filter the rerank results, only documents with a relevance score greater than the threshold will be returned
Override the agentic RAG configuration for this search. If not provided, will use the knowledge base configured agentic RAG settings.
Unique identifier of the knowledge base to search
Array of models with weights for load balancing requests