← Back to Blog

How to Run an AI GraphQL Agent with OE Runtime

Query any GraphQL API with natural language. OE Runtime introspects your schema, constructs type-safe queries with variables, executes them against your API, and returns structured results — no GraphQL expertise required.

🔷
Step 1
Introspect Schema
Call the GraphQL introspection query to understand available types, queries, and mutations.
Step 2
Execute Operation
Run a sample query using variables for dynamic values and return the raw result.
Step 3
Report
Summarise the operation executed, fields fetched, record count, and key values from the first results.

The Agent YAML

Create a file called agent.yaml inside a graphql/ directory:

name: GraphQL Agent
description: Run GraphQL queries and mutations
instructions: |
  You are a GraphQL API agent. Run queries to fetch data and mutations to create or update records.
  Always use variables for dynamic values — never interpolate directly into queries.
  Complete all steps fully before writing your report.
steps:
  - name: Introspect Schema
    content: |
      Call the GraphQL introspection query to understand the available types, queries, and mutations.
      List the key types and operations available.
  - name: Execute Operation
    content: |
      Based on the schema, run a sample query to fetch a list of records from the most relevant type.
      Use variables for any dynamic values. Return the raw result.
  - name: Report
    content: |
      Summarize what was returned:
      - Operation executed (query or mutation)
      - Fields fetched
      - Number of records returned
      - Key values from the first 3 records
connectors:
  - connection_name: My GraphQL API
    connection_type: graphql

The Config File

Create oe-config.json in the same directory:

{
  "llm": {
    "provider": "openai",
    "model": "gpt-4o",
    "apiKey": "YOUR_OPENAI_API_KEY"
  },
  "server": {
    "enabled": false,
    "port": 3333,
    "apiKey": "your-secret-api-key"
  },
  "connectors": [
    {
      "connection_name": "My GraphQL API",
      "connection_type": "graphql",
      "endpoint": "https://api.example.com/graphql",
      "headers": {
        "Authorization": "Bearer YOUR_TOKEN"
      }
    }
  ]
}

Replace the endpoint with your GraphQL API URL and set the Authorization header with your API token. The agent works with any GraphQL API including GitHub, Shopify, Hasura, and custom APIs.

Download OE Runtime

OE Runtime — Direct Downloads

Run the Agent

Windows

# Run the agent
oe-runtime-win.exe graphql/agent.yaml --config graphql/oe-config.json

macOS

# Make executable (first time only)
chmod +x oe-runtime-macos

# Run the agent
oe-runtime-macos graphql/agent.yaml --config graphql/oe-config.json

Linux

# Make executable (first time only)
chmod +x oe-runtime-linux

# Run the agent
oe-runtime-linux graphql/agent.yaml --config graphql/oe-config.json

macOS Gatekeeper: On first run, macOS may block the binary. Go to System Settings → Privacy & Security → click "Allow Anyway" next to oe-runtime-macos.

Running as an API Server

Add --serve to start OE Runtime as an HTTP server on port 3333:

oe-runtime-win.exe --serve --config graphql/oe-config.json

Then send a request:

curl -X POST http://localhost:3333/run \
  -H "Content-Type: application/json" \
  -d '{"yaml": "graphql/agent.yaml", "params": {}}'

Or import the Postman collection (download above) to test all endpoints visually.

Use Cases

Build your own agents with OE Runtime

Download OE Runtime and run any AI agent locally or as a server — no cloud required.

Get OE Runtime →