Overview
The Orq.ai Agents Framework provides a powerful API for creating, configuring, and executing intelligent AI agents. This guide covers the complete workflow for building agents programmatically and integrating them into your applications using the Agents API and SDKs.Core Concepts
Agent Lifecycle
Agents follow a simple two-step lifecycle:- Creation - Define your agent configuration via
POST /v2/agents - Execution - Send messages via
POST /v3/router/responseswithmodel: "agent/{key}"
Input Format
Agent input is passed as a plain string via theinput field. For multimodal content (images, files), pass an array of input items instead.
Response IDs and Context
Each agent execution returns a responseid. Pass the same id as previous_response_id in subsequent requests to continue conversations without replaying the full history.
Step 1: Creating Agents
Agent Configuration
An agent requires the following configuration:- key (required): Unique identifier within your workspace
- role: The agent’s function or purpose
- description: Brief summary of capabilities
- instructions: Behavioral guidelines and system prompt
- model: Model to use (string or object format)
- path: Storage location in your project structure
- settings: Execution parameters (max_iterations, max_execution_time, tools)
Creating a Simple Agent
Model Parameter Formats
Themodel parameter supports two formats:
String Format (simple, recommended for basic use):
Agent Settings
Configure execution behavior with thesettings object:
| Parameter | Type | Description | Default |
|---|---|---|---|
max_iterations | number | Maximum agent processing loops | 100 |
max_execution_time | number | Maximum execution time in seconds | 300 |
tools | array | Tools available to the agent | [] |
tool_approval_required | string | Tool approval mode | ”respect_tool” |
"respect_tool"(default) - Use tool’s individual approval settings. Each tool defines whether approval is required"none"- Never require approval, execute all tools automatically. Use for trusted tools and automated workflows"always"- Always require manual approval before any tool execution. Use for high-risk operations (coming soon)
| Mode | Best For | Example |
|---|---|---|
respect_tool | Mixed trust levels | Some tools (web search) are safe, others (CRM inserts) need approval |
none | Automated, trusted tools | Retrieving current date, reading knowledge bases |
always | High-risk operations | Financial transactions, account deletions, data modifications |
To learn more about tools, see the Tools Documentation.
Step 2: Executing Agents
Basic Execution
Execute an agent using the Responses API:Response Structure
The response includes:- output: Array of output items with the agent’s responses
- id: Identifier for continuing this conversation
- usage: Token consumption details
- model: Model used for execution
Step 3: Multi-Turn Conversations
Using Response IDs for Context
Continue conversations by providing theid from a previous response as previous_response_id:
Advanced Configuration
Execution Mode
The/v3/router/responses endpoint waits for the agent to finish and returns the complete response including all output, tool results, and token usage. Pass stream: true to receive the response as a stream of server-sent events instead.
Agent State Management
The/responses endpoint returns:
id: Pass asprevious_response_idto continue multi-turn conversationsoutput: Array of output items with the agent’s responseusage: Token consumption details
id as previous_response_id in subsequent requests to maintain conversation context.
Best Practices
Instructions Design
- Write clear, concise instructions
- Define expected outputs and formats
- Specify when to escalate or ask for clarification
- Include examples when helpful
Performance Optimization
- Set appropriate
max_iterationslimits - Use
max_execution_timeto prevent runaway processes - Leverage
previous_response_idto avoid context replay - Batch related requests when possible
Complete Example: Conversational Loop
Next Steps
- Tools with Agents - Add capabilities like web search and custom functions
- Multi-Agent Workflows - Orchestrate multiple agents together
- API Reference - Detailed endpoint documentation