{
  "openapi": "3.0.1",
  "info": {
    "title": "OpenRouter for Agents - Tools & Fallbacks",
    "description": "Call OpenRouter with full chat messages, custom tools, validated JSON and model fallbacks. No provider keys. Gateway: $0.01/run + $0.003 per usable response; model usage is billed separately.",
    "version": "0.1",
    "x-build-id": "3P1wnIXtms8NKcniW"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/automa-flow~openrouter-agent-gateway/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-automa-flow-openrouter-agent-gateway",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/automa-flow~openrouter-agent-gateway/runs": {
      "post": {
        "operationId": "runs-sync-automa-flow-openrouter-agent-gateway",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/automa-flow~openrouter-agent-gateway/run-sync": {
      "post": {
        "operationId": "run-sync-automa-flow-openrouter-agent-gateway",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "required": [
          "requests"
        ],
        "properties": {
          "requests": {
            "title": "Agent requests",
            "minItems": 1,
            "maxItems": 25,
            "type": "array",
            "description": "1-25 OpenRouter chat-completion requests. One Dataset row is written per item. Malformed items become uncharged FAILED rows without stopping valid items. Custom tools are forwarded, never executed.",
            "items": {
              "type": "object",
              "required": [
                "id",
                "messages"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "title": "Request id",
                  "description": "Stable caller id returned on the Dataset row (1-128 characters).",
                  "minLength": 1,
                  "maxLength": 128
                },
                "model": {
                  "type": "string",
                  "title": "Primary model",
                  "description": "OpenRouter model slug, for example openai/gpt-4o-mini. Required unless models is a non-empty fallback chain.",
                  "maxLength": 200
                },
                "models": {
                  "type": "array",
                  "title": "Fallback models",
                  "description": "Ordered OpenRouter fallback chain. When model is also set, these are extra fallbacks. Max 5 entries.",
                  "maxItems": 5,
                  "items": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "messages": {
                  "type": "array",
                  "title": "Chat messages",
                  "description": "Full OpenAI-compatible conversation. Do not collapse turns into one prompt. 1-40 messages.",
                  "minItems": 1,
                  "maxItems": 40,
                  "items": {
                    "type": "object",
                    "required": [
                      "role"
                    ],
                    "properties": {
                      "role": {
                        "type": "string",
                        "title": "Role",
                        "description": "system, user, assistant, tool or developer.",
                        "enum": [
                          "system",
                          "user",
                          "assistant",
                          "tool",
                          "developer"
                        ]
                      },
                      "content": {
                        "type": "string",
                        "title": "Content",
                        "description": "Message text. Omit this field, or send null, on an assistant turn that only carries toolCalls.",
                        "nullable": true,
                        "maxLength": 8192
                      },
                      "name": {
                        "type": "string",
                        "title": "Name",
                        "description": "Optional participant name forwarded to OpenRouter.",
                        "maxLength": 128
                      },
                      "toolCallId": {
                        "type": "string",
                        "title": "Tool call id",
                        "description": "Required for role=tool follow-up messages.",
                        "maxLength": 256
                      },
                      "toolCalls": {
                        "type": "array",
                        "title": "Prior tool calls",
                        "description": "Assistant tool_calls from a previous turn, forwarded unchanged.",
                        "items": {
                          "type": "object"
                        }
                      }
                    }
                  }
                },
                "tools": {
                  "type": "array",
                  "title": "Tools",
                  "description": "Custom OpenAI function tools. Forwarded upstream; this Actor never executes them. Max 32.",
                  "maxItems": 32,
                  "items": {
                    "type": "object",
                    "required": [
                      "function"
                    ],
                    "properties": {
                      "type": {
                        "type": "string",
                        "title": "Tool type",
                        "description": "Only function tools are forwarded.",
                        "enum": [
                          "function"
                        ]
                      },
                      "function": {
                        "type": "object",
                        "title": "Function",
                        "description": "Function name, description and JSON Schema parameters.",
                        "required": [
                          "name"
                        ],
                        "properties": {
                          "name": {
                            "type": "string",
                            "title": "Function name",
                            "description": "Tool name the model may call. This Actor does not execute it.",
                            "minLength": 1,
                            "maxLength": 128
                          },
                          "description": {
                            "type": "string",
                            "title": "Function description",
                            "description": "Optional text shown to the model.",
                            "maxLength": 4096
                          },
                          "parameters": {
                            "type": "object",
                            "title": "JSON Schema parameters",
                            "description": "JSON Schema for the function arguments. Forwarded unchanged.",
                            "editor": "json",
                            "additionalProperties": true
                          }
                        }
                      }
                    }
                  }
                },
                "toolChoice": {
                  "type": "string",
                  "title": "Tool choice",
                  "description": "auto, none or required. The published schema accepts only these strings.",
                  "enum": [
                    "auto",
                    "none",
                    "required"
                  ]
                },
                "responseFormat": {
                  "type": "object",
                  "title": "Response format",
                  "description": "Omit for plain text. Use type=json_object or type=json_schema with jsonSchema.",
                  "properties": {
                    "type": {
                      "type": "string",
                      "title": "Format type",
                      "description": "json_object or json_schema.",
                      "enum": [
                        "json_object",
                        "json_schema"
                      ]
                    },
                    "jsonSchema": {
                      "type": "object",
                      "title": "JSON Schema",
                      "description": "OpenRouter JSON Schema object (name, strict, schema), max 16 KiB. Draft 2020-12 validation. Self-contained schemas only: references and $id are rejected.",
                      "editor": "json",
                      "additionalProperties": true
                    }
                  },
                  "required": [
                    "type"
                  ]
                },
                "reasoningEffort": {
                  "type": "string",
                  "title": "Reasoning effort",
                  "description": "Optional OpenRouter reasoning effort. none disables reasoning.",
                  "enum": [
                    "none",
                    "low",
                    "medium",
                    "high"
                  ]
                },
                "temperature": {
                  "type": "number",
                  "title": "Temperature",
                  "description": "Sampling temperature from 0 to 2.",
                  "minimum": 0,
                  "maximum": 2
                },
                "maxTokens": {
                  "type": "integer",
                  "title": "Max tokens",
                  "description": "Completion token cap (1-8192), default 2048 even when omitted. Upstream calls wait at most 90 seconds; the whole batch has a 120-second work budget. Slow or skipped calls return explicit uncharged failures.",
                  "minimum": 1,
                  "maximum": 8192,
                  "default": 2048
                },
                "provider": {
                  "type": "object",
                  "title": "Provider routing",
                  "description": "OpenRouter routing preferences. Every call also enforces maximum provider prices: $10/M prompt tokens, $30/M completion tokens, $0 per-request fee. More expensive providers are excluded.",
                  "properties": {
                    "requireParameters": {
                      "type": "boolean",
                      "title": "Require parameters",
                      "description": "When true, OpenRouter skips providers that cannot honour tools or the response format."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}