Responses
Create a Response
Creates a model response for the given input. Returns a response object or a stream of server-sent events.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.responses.create()
with res as event_stream:
for event in event_stream:
# handle event
print(event, flush=True)
Show Parameters
Show Parameters
{
"conversation": { # optional
"id": str, # required
},
"fallbacks": { # optional
"model": str, # required
},
"frequency_penalty": Optional[float],
"guardrails": { # optional
"execute_on": Literal["input", "output", "both"], # required
"id": str, # required
"is_guardrail": Optional[bool],
"sample_rate": Optional[float],
},
"identity": { # optional
"display_name": Optional[str],
"email": Optional[str],
"id": str, # required
"metadata": List[Dict[str, Any]],
"tags": List[str],
},
"input": Union[str, List[CreateRouterResponseInput2]],
"instructions": Optional[str],
"limits": { # optional
"max_cost": Optional[float],
"max_depth": Optional[int],
"max_execution_time": Optional[int],
"max_iterations": Optional[int],
"tool_timeout": Optional[int],
},
"max_output_tokens": Optional[int],
"max_tool_calls": Optional[int],
"memory": { # optional
"entity_id": str, # required
},
"metadata": Dict[str, str],
"model": Optional[str],
"parallel_tool_calls": Optional[bool],
"presence_penalty": Optional[float],
"previous_response_id": Optional[str],
"prompt_cache_key": Optional[str],
"reasoning": { # optional
"effort": Optional[str],
"summary": Optional[str],
},
"retry": { # optional
"count": int, # required
"on_codes": List[int], # required
},
"safety_identifier": Optional[str],
"store": Optional[bool],
"stream": Optional[bool],
"stream_options": { # optional
"include_obfuscation": bool, # required
},
"temperature": Optional[float],
"template_engine": Optional[Literal["text", "jinja", "mustache"]],
"text": { # optional
"format_": Union[PlainText, FormatJSONSchema],
"verbosity": Optional[Literal["low", "medium", "high"]],
},
"thread": { # optional
"id": str, # required
"tags": List[str],
},
"tool_choice": Union[Shorthand, SpecificFunction],
"tools": Union[ToolsFunction, OrqAiTool, OrqAiTool, OrqAiTool, OrqAiTool, OrqAiTool, OrqAiTool, ToolsMCPTool],
"top_logprobs": Optional[int],
"top_p": Optional[float],
"variables": Dict[str, Any],
}
Show Response
Show Response
{
"background": bool,
"completed_at": Nullable[int],
"conversation": { # optional
"id": str,
},
"created_at": int,
"error": {
"code": str,
"message": str,
},
"frequency_penalty": float,
"id": str,
"incomplete_details": {
"reason": str,
},
"input": List[Any],
"instructions": Nullable[str],
"max_output_tokens": Nullable[int],
"max_tool_calls": Nullable[int],
"memory": { # optional
"entity_id": str,
},
"metadata": Dict[str, str],
"model": str,
"object": str,
"output": List[Any],
"parallel_tool_calls": bool,
"presence_penalty": float,
"previous_response_id": Nullable[str],
"prompt_cache_key": Nullable[str],
"prompt_cache_retention": Nullable[str],
"reasoning": {
"effort": Optional[str],
"summary": Optional[str],
},
"safety_identifier": Nullable[str],
"service_tier": Literal["auto", "default", "flex", "priority"],
"status": Literal["queued", "in_progress", "completed", "failed", "incomplete", "requires_action"],
"store": bool,
"temperature": float,
"text": Any,
"tool_choice": Any,
"tools": List[Any],
"top_logprobs": int,
"top_p": float,
"truncation": Literal["disabled", "auto"],
"usage": {
"input_cost": Optional[float],
"input_tokens": int,
"input_tokens_details": {
"cache_creation_1h_tokens": Optional[int],
"cache_creation_5m_tokens": Optional[int],
"cache_creation_tokens": int,
"cached_tokens": int,
},
"output_cost": Optional[float],
"output_tokens": int,
"output_tokens_details": {
"reasoning_tokens": int,
},
"total_cost": Optional[float],
"total_tokens": int,
"web_search_requests": Optional[int],
},
"user": Nullable[str],
"variables": Dict[str, Any],
}
Retrieve a Response
Retrieves a previously created response by its ID.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.responses.get(response_id="<id>")
# Handle response
print(res)
Show Parameters
Show Parameters
{
"response_id": str, # required
}
Show Response
Show Response
{
"background": bool,
"completed_at": Nullable[int],
"conversation": { # optional
"id": str,
},
"created_at": int,
"error": {
"code": str,
"message": str,
},
"frequency_penalty": float,
"id": str,
"incomplete_details": {
"reason": str,
},
"input": List[Any],
"instructions": Nullable[str],
"max_output_tokens": Nullable[int],
"max_tool_calls": Nullable[int],
"memory": { # optional
"entity_id": str,
},
"metadata": Dict[str, str],
"model": str,
"object": str,
"output": List[Any],
"parallel_tool_calls": bool,
"presence_penalty": float,
"previous_response_id": Nullable[str],
"prompt_cache_key": Nullable[str],
"prompt_cache_retention": Nullable[str],
"reasoning": {
"effort": Optional[str],
"summary": Optional[str],
},
"safety_identifier": Nullable[str],
"service_tier": Literal["auto", "default", "flex", "priority"],
"status": Literal["queued", "in_progress", "completed", "failed", "incomplete", "requires_action"],
"store": bool,
"temperature": float,
"text": Any,
"tool_choice": Any,
"tools": List[Any],
"top_logprobs": int,
"top_p": float,
"truncation": Literal["disabled", "auto"],
"usage": {
"input_cost": Optional[float],
"input_tokens": int,
"input_tokens_details": {
"cache_creation_1h_tokens": Optional[int],
"cache_creation_5m_tokens": Optional[int],
"cache_creation_tokens": int,
"cached_tokens": int,
},
"output_cost": Optional[float],
"output_tokens": int,
"output_tokens_details": {
"reasoning_tokens": int,
},
"total_cost": Optional[float],
"total_tokens": int,
"web_search_requests": Optional[int],
},
"user": Nullable[str],
"variables": Dict[str, Any],
}