> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS Strands Agents integration

> Connect AWS Strands Agents to Orq.ai's AI Gateway. Access 300+ LLMs with built-in fallbacks, load balancing, and cost tracking.

## AI Gateway

### Overview

AWS Strands is a framework for building AI agents with structured reasoning and tool use. Connecting AWS Strands to Orq.ai's **AI Gateway** transforms experimental agents into production-ready systems with enterprise-grade capabilities.

### Key Benefits

Orq.ai's AI Gateway enhances AWS Strands Agents with:

<CardGroup cols={2}>
  <Card title="Complete Observability" icon="chart-line">
    Track every agent step, tool use, and interaction with detailed traces and analytics
  </Card>

  <Card title="Built-in Reliability" icon="shield-check">
    Automatic fallbacks, retries, and load balancing for production resilience
  </Card>

  <Card title="Cost Optimization" icon="chart-pie">
    Real-time cost tracking and spend management across all AI operations
  </Card>

  <Card title="Multi-Provider Access" icon="cubes">
    Access 300+ LLMs and 20+ providers through a single, unified integration
  </Card>
</CardGroup>

### Prerequisites

Before integrating AWS Strands with Orq.ai, ensure the following are in place:

* An Orq.ai account and [API Key](/docs/ai-gateway/configuration/api-keys)
* Python 3.10 or higher
* AWS Strands SDK installed

<Info>
  To set up an API key, see [API keys & Endpoints](/docs/ai-gateway/configuration/api-keys).
</Info>

### Installation

Install the Strands Agents SDK (requires Python 3.10+):

<CodeGroup>
  ```bash Bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  # Install Strands Agents SDK
  pip install strands-agents

  # Optional: Install additional tools
  pip install strands-agents-tools
  ```
</CodeGroup>

### Configuration

Configure Strands Agents to use Orq.ai's AI Gateway by passing custom client arguments with the base URL:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from strands import Agent
  from strands.models.openai import OpenAIModel
  import os

  # Configure model with Orq.ai AI Gateway
  model = OpenAIModel(
      model_id="gpt-4o",
      client_args={
          "api_key": os.getenv('ORQ_API_KEY'),
          "base_url": "https://api.orq.ai/v3/router"
      }
  )

  # Create agent with Orq.ai-powered model
  agent = Agent(
      model=model,
      system_prompt="You are a helpful AI assistant."
  )
  ```
</CodeGroup>

> **base\_url**: `https://api.orq.ai/v3/router`

### Basic Agent Example

Here's a complete example of creating and running a Strands agent through Orq.ai:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from strands import Agent
  from strands.models.openai import OpenAIModel
  import os

  # Configure model with Orq.ai AI Gateway
  model = OpenAIModel(
      model_id="gpt-4o",
      client_args={
          "api_key": os.getenv('ORQ_API_KEY'),
          "base_url": "https://api.orq.ai/v3/router"
      }
  )

  # Create a simple agent
  agent = Agent(
      model=model,
      system_prompt="You are a research assistant that helps users find and summarize information."
  )

  # Run the agent
  result = agent("Explain quantum computing in simple terms")
  print(result)
  ```
</CodeGroup>

### Agent with Tools

Strands agents can use tools while routing through Orq.ai:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from strands import Agent, tool
  from strands.models.openai import OpenAIModel
  import os

  # Configure model
  model = OpenAIModel(
      model_id="gpt-4o",
      client_args={
          "api_key": os.getenv('ORQ_API_KEY'),
          "base_url": "https://api.orq.ai/v3/router"
      }
  )

  # Define a custom tool using the @tool decorator
  @tool
  def search_database(query: str) -> str:
      """Search the knowledge database for relevant information."""
      # Your database search logic here
      return f"Search results for: {query}"

  # Create agent with tools
  agent = Agent(
      model=model,
      tools=[search_database],
      system_prompt="You are a knowledge assistant. Use the search_database tool to find information when needed."
  )

  # Run agent with tool access
  result = agent("Find information about machine learning best practices")
  print(result)
  ```
</CodeGroup>

### Fallback Configuration

Configure automatic fallbacks for reliability:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from strands import Agent
  from strands.models.openai import OpenAIModel
  import os

  # Configure model - Orq.ai handles fallbacks automatically
  model = OpenAIModel(
      model_id="gpt-4o",
      client_args={
          "api_key": os.getenv('ORQ_API_KEY'),
          "base_url": "https://api.orq.ai/v3/router"
      }
  )

  agent = Agent(
      model=model,
      system_prompt="You are a helpful assistant."
  )
  ```
</CodeGroup>
