> ## 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 Bedrock AgentCore integration

> Run orq.ai-powered agents inside AWS Bedrock AgentCore. Route LLM calls through the AI Gateway, invoke Orq Agents by key, and capture traces with OpenTelemetry.

**AWS Bedrock AgentCore Runtime** is a serverless hosting environment for deploying agents built with any framework (Strands, LangGraph, CrewAI) at production scale, without managing infrastructure. Connect the **AI Gateway** from inside AgentCore to access 300+ models across 20+ providers with automatic fallbacks, cost tracking, and full observability.

<CardGroup cols={2}>
  <Card title="AI Gateway" icon="arrow-right-arrow-left" href="#ai-gateway">
    Route LLM calls through the **AI Gateway** inside AgentCore with a single base URL change.
  </Card>

  <Card title="Orq Agents" icon="robot" href="#orq-agents">
    Invoke any **Orq.ai** Agent by key from inside AgentCore using the OpenAI Responses API.
  </Card>
</CardGroup>

## AI Gateway

Connect the **AI Gateway** to an AgentCore entrypoint to access 300+ LLMs across 20+ providers, with automatic fallbacks, cost tracking, and observability.

### OpenAI Agents SDK

**Install:**

<CodeGroup>
  ```bash Bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  pip install openai-agents openai bedrock-agentcore
  ```
</CodeGroup>

Configure an `AsyncOpenAI` client with the **AI Gateway** base URL, then wrap the agent in a `BedrockAgentCoreApp` entrypoint:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import os
  from openai import AsyncOpenAI
  from agents import Agent, Runner, set_default_openai_client, set_tracing_disabled
  from bedrock_agentcore.runtime import BedrockAgentCoreApp

  client = AsyncOpenAI(
      api_key=os.getenv("ORQ_API_KEY"),
      base_url="https://api.orq.ai/v3/router"
  )
  set_tracing_disabled(True)
  set_default_openai_client(client)

  agent = Agent(
      name="Assistant",
      instructions="You are a helpful assistant.",
      model="openai/gpt-4o"
  )

  app = BedrockAgentCoreApp()

  @app.entrypoint
  async def agent_invocation(payload, context):
      query = payload.get("prompt", "How can I help you?")
      result = await Runner.run(agent, query)
      return {"result": result.final_output}

  app.run()
  ```
</CodeGroup>

### Strands Agents

**Install:**

<CodeGroup>
  ```bash Bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  pip install strands-agents bedrock-agentcore
  ```
</CodeGroup>

Use `OpenAIModel` with the **AI Gateway** base URL inside a Strands agent:

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

  model = OpenAIModel(
      model_id="openai/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."
  )

  app = BedrockAgentCoreApp()

  @app.entrypoint
  def agent_invocation(payload, context):
      result = agent(payload.get("prompt", "How can I help?"))
      return {"result": str(result)}

  app.run()
  ```
</CodeGroup>

## Orq Agents

Invoke any **Orq.ai** Agent by key using `model="agent/YOUR_AGENT_KEY"` with the OpenAI Responses API. The **AI Gateway** executes the configured agent including its system prompt, tools, evaluators, and model settings.

<Info>
  Find the agent key on the [Agents](/docs/agents/agent-studio) page in **Orq.ai**.
</Info>

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import os
  from openai import AsyncOpenAI
  from bedrock_agentcore.runtime import BedrockAgentCoreApp

  client = AsyncOpenAI(
      api_key=os.getenv("ORQ_API_KEY"),
      base_url="https://api.orq.ai/v3/router"
  )

  app = BedrockAgentCoreApp()

  @app.entrypoint
  async def agent_invocation(payload, context):
      query = payload.get("prompt", "How can I help you?")
      response = await client.responses.create(
          model="agent/YOUR_AGENT_KEY",
          input=query
      )
      return {"result": response.output_text}

  app.run()
  ```
</CodeGroup>

## Observability

Capture traces from AgentCore runs and send them to **Orq.ai** using OpenTelemetry.

### Installation

<CodeGroup>
  ```bash Bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
  pip install openai bedrock-agentcore opentelemetry-sdk opentelemetry-exporter-otlp-proto-http openinference-instrumentation-openai
  ```
</CodeGroup>

### Configuration

Set up the OTLP exporter and instrument the OpenAI client before starting the app:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import os
  from opentelemetry.sdk.trace import TracerProvider
  from opentelemetry.sdk.trace.export import BatchSpanProcessor
  from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
  from openinference.instrumentation.openai import OpenAIInstrumentor
  from openai import AsyncOpenAI
  from bedrock_agentcore.runtime import BedrockAgentCoreApp

  exporter = OTLPSpanExporter(
      endpoint="https://api.orq.ai/v2/otel/v1/traces",
      headers={"Authorization": f"Bearer {os.getenv('ORQ_API_KEY')}"}
  )
  provider = TracerProvider()
  provider.add_span_processor(BatchSpanProcessor(exporter))
  OpenAIInstrumentor().instrument(tracer_provider=provider)

  client = AsyncOpenAI(
      api_key=os.getenv("OPENAI_API_KEY")
  )

  app = BedrockAgentCoreApp()

  @app.entrypoint
  async def agent_invocation(payload, context):
      query = payload.get("prompt", "How can I help you?")
      response = await client.responses.create(
          model="gpt-4o",
          input=query
      )
      return {"result": response.output_text}

  app.run()
  ```
</CodeGroup>

View traces in [AI Studio](https://my.orq.ai) under the **Traces** tab.

## Evaluations & Experiments

Once agents are running, use **Evaluatorq** to score outputs across a dataset and **Experiments** to compare configurations side-by-side.

<CardGroup cols={2}>
  <Card title="Run Evaluations with Evaluatorq" icon="flask" href="/docs/evaluators/build#evaluatorq">
    Run parallel evaluations across agents and compare results.
  </Card>

  <Card title="Run Experiments via the API" icon="flask-vial" href="/docs/experiments/api">
    Compare agent configurations and view results in the AI Studio.
  </Card>
</CardGroup>
