> ## 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.

# Build your first AI agent with Orq.ai

> Build an AI agent with Orq.ai: create the agent, connect a model, add tools, and call it from your code. Beginner-friendly, no AI experience needed.

This guide walks you through every step of getting started with **orq.ai**. By the end you will have a working AI agent that can search the web and answer questions, with full visibility into every call it makes.

<Steps>
  <Step>
    ### Create your orq.ai account

    [Sign up](https://my.orq.ai/auth/signup) for a free **orq.ai** account and create a workspace.
  </Step>

  <Step>
    ### Add your provider API key

    **orq.ai** routes requests through provider credentials managed in the workspace, keeping spend and data under full control. This quickstart uses OpenAI as an example, but any [supported provider](/docs/integrations/providers/overview) works the same way.

    * Go to **AI Gateway > BYOK** in the [AI Studio](https://my.orq.ai).
    * Find the [OpenAI](/docs/integrations/providers/openai) provider.
    * Click <kbd className="key">Setup your own API Key</kbd> and enter the OpenAI API key.

    <Frame caption="Add your OpenAI API key in the AI Gateway">
      <img src="https://mintcdn.com/orqai/bhQw0kXY4gf3CTsS/images/providers-add-openai.gif?s=fa38b3d351fb5e0308ab0151206941e9" alt="Adding OpenAI API key in the AI Gateway" width="1200" height="758" data-path="images/providers-add-openai.gif" />
    </Frame>

    <Card title="Supported providers" icon="plug" href="/docs/integrations/providers/overview">
      See the full list of supported model providers and how to connect them.
    </Card>
  </Step>

  <Step>
    ### Enable models in the AI Gateway

    With your provider connected:

    * Go to **AI Gateway > Models** and search for `gpt-4o`.
    * Click on it and toggle it on.

    Only enabled models can be selected when creating **Agents** and **Deployments**.

    <Frame caption="Enabling models in the AI Gateway">
      <img src="https://mintcdn.com/orqai/bhQw0kXY4gf3CTsS/images/openai-enable.gif?s=3110edd1fed7c564f691b12a67f4164a" alt="Enabling gpt-4o in the AI Gateway" width="1200" height="645" data-path="images/openai-enable.gif" />
    </Frame>

    <Card title="AI Gateway" icon="cubes" href="/docs/model-garden/overview">
      Browse and manage all available models across providers.
    </Card>
  </Step>

  <Step>
    ### Get your orq.ai API key

    Go to **Organization > [API Keys](/docs/administer/api-keys)** in the left sidebar. Click <kbd className="key">Create API Key</kbd>, give it a name, and copy it.

    Then open a terminal and run the command below, replacing `your-api-key-here` with the key you just copied. The code samples in the next steps read it from this environment variable.

    <CodeGroup>
      ```bash macOS / Linux theme={"theme":{"light":"github-light","dark":"github-dark"}}
      export ORQ_API_KEY="your-api-key-here"
      ```

      ```powershell Windows theme={"theme":{"light":"github-light","dark":"github-dark"}}
      $env:ORQ_API_KEY = "your-api-key-here"
      ```
    </CodeGroup>
  </Step>

  <Step>
    ### Create your agent

    Build an **Agent** named `my-assistant` with **OpenAI GPT-4o** and the **Web Search** and **Web Scraper** tools.

    <Tabs>
      <Tab title="AI Studio" icon="https://mintcdn.com/orqai/My16MDKJXrKALEHC/images/logos/ai-studio-round.svg?fit=max&auto=format&n=My16MDKJXrKALEHC&q=85&s=ac04dd509320d58ab9701cb6d6137733" width="100" height="100" data-path="images/logos/ai-studio-round.svg">
        1. Open the [AI Studio](https://my.orq.ai) and navigate to your project.
        2. Click the **+** button and select **Agent**.
        3. In the popup, select **openai/gpt-4o** as the model.
        4. Name the agent `my-assistant`.
        5. Add a description: `A helpful assistant with web search`.
        6. Click <kbd className="key">Create</kbd>.
        7. Set the agent's instructions to: `You are a helpful assistant. Be concise and accurate. When answering questions that require current or up-to-date information, use the web search tool to find the latest data before responding.`
        8. Under **Tools**, add **Web Search** and **Web Scraper**.
        9. Click <kbd className="key">Publish</kbd>, choose a version bump (**Major**, **Minor**, or **Patch**), and click <kbd className="key">Publish</kbd> to confirm.

        <Note>
          See the [Agent Studio guide](/docs/agents/agent-studio) for the full walkthrough.
        </Note>

        <Frame caption="my-assistant agent in orq.ai Studio">
          <img src="https://mintcdn.com/orqai/bhQw0kXY4gf3CTsS/images/my-assistant-quickstart.png?fit=max&auto=format&n=bhQw0kXY4gf3CTsS&q=85&s=c7c4aff43fe01374123fd8245bf69d5c" alt="my-assistant agent in orq.ai Studio" width="1517" height="888" data-path="images/my-assistant-quickstart.png" />
        </Frame>
      </Tab>

      <Tab title="API & SDK" icon="code">
        Use the [Create Agent API](/reference/agents/create-agent). The `key` is a unique identifier for invoking the agent later, and `path` is the **Project** folder it lives in. Tools are attached under `settings.tools` using their built-in `type`.

        <CodeGroup>
          ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
          curl -X POST https://api.orq.ai/v2/agents \
            -H "Authorization: Bearer $ORQ_API_KEY" \
            -H "Content-Type: application/json" \
            -d '{
              "key": "my-assistant",
              "role": "Assistant",
              "description": "A helpful assistant with web search",
              "instructions": "You are a helpful assistant. Be concise and accurate. When answering questions that require current or up-to-date information, use the web search tool to find the latest data before responding.",
              "path": "YOUR_PROJECT_NAME",
              "model": { "id": "openai/gpt-4o" },
              "settings": {
                "max_iterations": 5,
                "max_execution_time": 300,
                "tools": [
                  { "type": "google_search" },
                  { "type": "web_scraper" }
                ]
              }
            }'
          ```

          ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
          from orq_ai_sdk import Orq
          import os

          with Orq(api_key=os.getenv("ORQ_API_KEY", "")) as orq:
              agent = orq.agents.create(
                  key="my-assistant",
                  role="Assistant",
                  description="A helpful assistant with web search",
                  instructions=(
                      "You are a helpful assistant. Be concise and accurate. "
                      "When answering questions that require current or up-to-date "
                      "information, use the web search tool to find the latest data "
                      "before responding."
                  ),
                  path="YOUR_PROJECT_NAME",
                  model={"id": "openai/gpt-4o"},
                  settings={
                      "max_iterations": 5,
                      "max_execution_time": 300,
                      "tools": [
                          {"type": "google_search"},
                          {"type": "web_scraper"},
                      ],
                  },
              )
              print(f"Agent created: {agent.key}")
          ```

          ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
          import { Orq } from "@orq-ai/node";

          const orq = new Orq({ apiKey: process.env.ORQ_API_KEY ?? "" });

          const agent = await orq.agents.create({
            key: "my-assistant",
            role: "Assistant",
            description: "A helpful assistant with web search",
            instructions:
              "You are a helpful assistant. Be concise and accurate. When answering questions that require current or up-to-date information, use the web search tool to find the latest data before responding.",
            path: "YOUR_PROJECT_NAME",
            model: { id: "openai/gpt-4o" },
            settings: {
              maxIterations: 5,
              maxExecutionTime: 300,
              tools: [
                { type: "google_search" },
                { type: "web_scraper" },
              ],
            },
          });

          console.log(`Agent created: ${agent.key}`);
          ```
        </CodeGroup>

        <Note>
          See [Build agents with the API](/docs/agents/agent-api) for the full list of built-in tool types and how to attach custom HTTP, function, or MCP tools.
        </Note>
      </Tab>

      <Tab title="MCP" icon="https://mintcdn.com/orqai/i7ZhKI7LFRfXU7ox/images/logos/mcp.svg?fit=max&auto=format&n=i7ZhKI7LFRfXU7ox&q=85&s=cef7916eb5fe1f6bb97541398d3f7639" width="16" height="16" data-path="images/logos/mcp.svg">
        Install the [**Orq MCP** server](/docs/workspace-mcp) in the editor or AI assistant, then ask the coding assistant:

        ```prompt wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
        Create an agent called "my-assistant" with the instructions "You are a helpful assistant. Be concise and accurate. When answering questions that require current or up-to-date information, use the web search tool to find the latest data before responding." using the openai/gpt-4o model. Add the web_search and web_scraper tools. Create it in the <YOUR_PROJECT_NAME> project.
        ```

        The assistant calls `create_agent` and the new **Agent** appears in the **AI Studio**.
      </Tab>
    </Tabs>
  </Step>

  <Step>
    ### Call your agent

    Send a message to `my-assistant` and read the response.

    <Tabs>
      <Tab title="AI Studio" icon="https://mintcdn.com/orqai/My16MDKJXrKALEHC/images/logos/ai-studio-round.svg?fit=max&auto=format&n=My16MDKJXrKALEHC&q=85&s=ac04dd509320d58ab9701cb6d6137733" width="100" height="100" data-path="images/logos/ai-studio-round.svg">
        Open the **Agent** in the [AI Studio](https://my.orq.ai) and use the built-in chat panel to send a message. Conversations and traces are saved automatically.
      </Tab>

      <Tab title="API & SDK" icon="code">
        Invoke the **Agent** by passing `agent/my-assistant` as the model on the [unified router responses endpoint](/docs/agents/agent-api#execute-the-agent) (`POST /v3/router/responses`).

        <CodeGroup>
          ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
          curl --request POST \
            --url 'https://my.orq.ai/v3/router/responses' \
            --header "Authorization: Bearer $ORQ_API_KEY" \
            --header 'Content-Type: application/json' \
            --data '{
              "model": "agent/my-assistant",
              "input": "What is the capital of France?"
            }'
          ```

          ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
          import os
          from orq_ai_sdk import Orq

          client = Orq(
              api_key=os.environ["ORQ_API_KEY"],
              server_url="https://my.orq.ai",
          )

          response = client.responses.create(
              model="agent/my-assistant",
              input="What is the capital of France?",
          )

          print(response.output[0]["content"][0]["text"])
          print(response.usage)
          ```

          ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
          import { Orq } from "@orq-ai/node";

          const client = new Orq({
            serverURL: "https://my.orq.ai",
            apiKey: process.env.ORQ_API_KEY,
          });

          const response = await client.responses.create({
            model: "agent/my-assistant",
            input: "What is the capital of France?",
          });

          console.log(response.output[0].content[0].text);
          console.log(response.usage);
          ```
        </CodeGroup>

        Install with `pip install orq-ai-sdk` (Python) or `npm install @orq-ai/node` (TypeScript).

        <Accordion title="Streaming responses">
          For long-running agents or chat interfaces, use the streaming API to receive partial output as it is generated. See [Execute the Agent](/docs/agents/agent-api#execute-the-agent) for details.
        </Accordion>
      </Tab>

      <Tab title="MCP" icon="https://mintcdn.com/orqai/i7ZhKI7LFRfXU7ox/images/logos/mcp.svg?fit=max&auto=format&n=i7ZhKI7LFRfXU7ox&q=85&s=cef7916eb5fe1f6bb97541398d3f7639" width="16" height="16" data-path="images/logos/mcp.svg">
        Ask the assistant to invoke the **Agent** directly:

        ```prompt wrap theme={"theme":{"light":"github-light","dark":"github-dark"}}
        Run my-assistant with the message "What is the capital of France?" and print the response.
        ```

        The assistant uses `invoke_agent` and returns the **Agent**'s reply, including any tool calls it made along the way.
      </Tab>
    </Tabs>
  </Step>

  <Step>
    ### View your traces

    Every **Agent** call is automatically traced. Execution history, token counts, latency, and cost are visible in the **AI Studio** or queryable through **MCP**.

    <Tabs>
      <Tab title="AI Studio" icon="https://mintcdn.com/orqai/My16MDKJXrKALEHC/images/logos/ai-studio-round.svg?fit=max&auto=format&n=My16MDKJXrKALEHC&q=85&s=ac04dd509320d58ab9701cb6d6137733" width="100" height="100" data-path="images/logos/ai-studio-round.svg">
        Open `my-assistant` in the [AI Studio](https://my.orq.ai) and click the **Traces** tab to see the full execution history, including model calls, tool use, token counts, and latency.

        <Frame caption="my-assistant traces in orq.ai Studio">
          <img src="https://mintcdn.com/orqai/bhQw0kXY4gf3CTsS/images/my-assistant-traces.png?fit=max&auto=format&n=bhQw0kXY4gf3CTsS&q=85&s=7777e19d8593096b077e08d64b91e4d5" alt="my-assistant traces in orq.ai Studio" width="1516" height="1043" data-path="images/my-assistant-traces.png" />
        </Frame>
      </Tab>

      <Tab title="MCP" icon="https://mintcdn.com/orqai/i7ZhKI7LFRfXU7ox/images/logos/mcp.svg?fit=max&auto=format&n=i7ZhKI7LFRfXU7ox&q=85&s=cef7916eb5fe1f6bb97541398d3f7639" width="16" height="16" data-path="images/logos/mcp.svg">
        Ask the assistant to query analytics for the **Agent**:

        ```prompt theme={"theme":{"light":"github-light","dark":"github-dark"}}
        How is my-assistant performing?
        ```

        The assistant calls `query_analytics` and returns a summary:

        <Frame caption="my-assistant analytics returned by the MCP client">
          <img src="https://mintcdn.com/orqai/bhQw0kXY4gf3CTsS/images/my-assistant-mcp-traces.png?fit=max&auto=format&n=bhQw0kXY4gf3CTsS&q=85&s=d66c4eaa47a0ad5cbc24d6ed25ebfc36" alt="my-assistant analytics returned by the MCP client" width="1037" height="307" data-path="images/my-assistant-mcp-traces.png" />
        </Frame>
      </Tab>
    </Tabs>
  </Step>
</Steps>

***

<CardGroup cols={2}>
  <Card title="Run your first experiment" icon="flask" href="/docs/experiments/overview">
    Compare prompts, models, and configurations side by side to find what performs best before shipping.
  </Card>

  <Card title="Add an evaluator" icon="clipboard-check" href="/docs/evaluators/build">
    Score your **Agent**'s outputs automatically with LLM-based, code, or human **Evaluators**.
  </Card>

  <Card title="Connect a knowledge base" icon="book" href="/docs/knowledge/overview">
    Give your **Agent** access to your own documents and data with built-in RAG.
  </Card>

  <Card title="Log your first trace" icon="chart-line" href="/docs/quickstarts/log-your-first-trace">
    Already running agents elsewhere? Connect via OpenTelemetry to get full trace visibility and cost tracking.
  </Card>
</CardGroup>
