Skip to main content

Gateway

The v1 gateway routes incoming requests to registered plugins. It supports three payment methods — Stripe (existing), MPP (Machine Payments Protocol) via the Tempo blockchain, and session-based billing for low-latency, off-chain per-call payments.

Base URL

POST /api/v1/gateway

Request

Headers

HeaderTypeRequiredDescription
Content-TypestringYesMust be application/json
X-Plugin-IdstringNoPlugin to route the request to. Overrides the plugin field in the body.
X-Payment-MethodstringNoPayment method to use: stripe, mpp, or session. Defaults to stripe.
AuthorizationstringNoFor MPP payments, use Payment <credential>. For session auth, handled via cookies.
X-Session-IdstringNoActive session ID for session-based billing. Required when X-Payment-Method is session.
X-Wallet-AddressstringNoWallet address that owns the session (0x-prefixed). Required when X-Payment-Method is session.
AcceptstringNoSet to text/event-stream for streaming responses (where supported).

Body

{
  "plugin": "agent",
  "messages": [{ "role": "user", "content": "Hello" }]
}
FieldTypeRequiredDescription
pluginstringNoPlugin ID to route to. The X-Plugin-Id header takes priority if both are provided. Defaults to agent.
Additional body fields are forwarded to the target plugin.

Plugins

The gateway routes to the following plugins:
Plugin IDNameDescriptionAuth requiredStreaming
agentAgentAgent orchestrator for multi-step tasksNoYes
generate-textText GenerationLLM text generationNoYes
ttsText-to-SpeechSpeech synthesisNoNo
sttSpeech-to-TextSpeech transcriptionNoNo
agent is the default plugin when no plugin ID is specified.

Authentication

No plugins currently require authentication. The gateway checks whether a plugin has its auth flag enabled — since no built-in plugin sets this flag, all requests are processed without requiring a session, MPP credential, or payment session. If a custom plugin is registered with auth: true, the gateway enforces either a valid session (cookie-based via NextAuth), a verified MPP payment credential, or an active payment session. If you pay with MPP or use session-based billing, cookie-based authentication is not required for auth-enabled plugins.

Payment flow

The gateway supports three payment methods per request:
  1. Stripe — Default. Requires an active subscription or credits. See Stripe integration.
  2. MPP — Crypto-native payments on the Tempo blockchain. See MPP payments.
  3. Session — Off-chain, per-call billing using a pre-funded payment session. See MPP payments — sessions and the wallet sessions API.
The server selects the payment method using the following priority:
  1. X-Payment-Method header (session, mpp, or stripe)
  2. Presence of an Authorization: Payment header (implies mpp)
  3. Default: stripe

MPP 402 challenge

When an MPP request has no valid credential, the gateway returns 402 Payment Required with pricing information for both payment methods:
{
  "error": "payment_required",
  "message": "Payment required for agent. Choose payment method: Stripe or Tempo MPP.",
  "mpp": {
    "scheme": "Payment",
    "amount": "0.05",
    "currency": "0x20c0000000000000000000000000000000000000",
    "recipient": "0xd8fd0e1dce89beaab924ac68098ddb17613db56f",
    "description": "Agent orchestrator request",
    "nonce": "a1b2c3d4e5f6...",
    "expiresAt": 1742472000000
  },
  "stripe": {
    "checkoutUrl": "/api/v1/payments/stripe/create?plugin=agent",
    "amount": "0.05",
    "currency": "usd"
  }
}
The WWW-Authenticate header is also set:
Payment amount="0.05", currency="0x20c0000000000000000000000000000000000000", recipient="0xd8fd0e1dce89beaab924ac68098ddb17613db56f"

Session-based billing

When X-Payment-Method is session, the gateway auto-debits the caller’s payment session using an off-chain voucher. This avoids the 402 challenge/response round-trip and settles each call in sub-100ms. To use session-based billing:
  1. Open a payment session via POST /api/wallet/sessions. See wallet sessions.
  2. Include X-Session-Id and X-Wallet-Address headers on every gateway request.
  3. The gateway looks up the session, verifies the balance covers the plugin price, and debits the session automatically.
  4. The response includes a Payment-Receipt header with the voucher reference and an X-Session-Remaining header with the updated balance.
If the session is missing, expired, or has insufficient balance, the gateway returns 402 with a descriptive error. See error responses for the full list of session-related error codes.

Response

Success (200)

{
  "plugin": "agent",
  "message": "Request processed by agent plugin",
  "timestamp": "2026-03-20T03:33:15.000Z",
  "payment": {
    "method": "stripe",
    "receipt": null
  }
}
When paid via MPP, the response includes a Payment-Receipt header and the payment.receipt field contains the transaction hash. When paid via a session, the payment.receipt field contains the voucher reference (formatted as session:<sessionId>:<nonce>).

Response headers

HeaderDescription
x-plugin-idThe plugin that handled the request
Payment-ReceiptPayment receipt. For MPP: transaction hash. For sessions: voucher reference (session:<sessionId>:<nonce>). Only present for MPP or session-paid requests.
X-Session-RemainingRemaining session balance in USD after the debit. Only present for session-paid requests.

Error responses

StatusError codeDescription
400unknown_pluginNo pricing configured for the requested plugin (session billing only)
401UnauthorizedAuthentication required for a protected plugin and no valid session, MPP credential, or payment session
402payment_requiredMPP payment required. Response includes challenge and pricing.
402session_requiredSession billing was requested but X-Session-Id or X-Wallet-Address header is missing
402session_invalidNo active session found for the provided session ID and wallet address
402insufficient_balanceSession balance is too low to cover the plugin price. Response includes session.remaining and session.cost.
402voucher_failedThe off-chain voucher could not be processed (e.g., concurrent debit race)
500internalInternal server error
502no_pluginNo plugin registered for the given ID

Per-agent gateway authentication

Each agent container receives a unique gateway auth token at provisioning time. The internal gateway authenticates requests using token-based auth on port 18789.
FieldDescription
gateway.auth.modetoken
gateway.auth.tokenUnique hex token auto-generated per container. Provisioning generates a 48-character token (24 bytes of entropy). The container entrypoint generates a 32-character token (16 bytes) if no token is passed via the OPENCLAW_GATEWAY_TOKEN environment variable.
gateway.port18789
The container entrypoint writes its own minimal configuration to $HOME/.openclaw/openclaw.json using a slightly different schema (auth.method at the top level instead of gateway.auth.mode). The provisioning config written by the backend uses the gateway.auth.mode path. When the entrypoint runs, it overwrites the provisioning config with its own minimal skeleton. To preserve the full provisioning config, pass the gateway token via the OPENCLAW_GATEWAY_TOKEN environment variable so the entrypoint uses the same token.

Agent container configuration

When an agent is provisioned, the backend generates an OpenClaw configuration with the following parameters. These values are set automatically and cannot be overridden by the caller.

Container environment variables

The following environment variables are set on every agent container at launch. Variables are grouped by source — some are set by the container image entrypoint (local Docker path) and others are injected by the provisioning service (Railway path). When both paths set the same variable, the provisioning service value takes precedence.
VariableDefaultDescription
NODE_ENVproductionNode.js environment. Set by the provisioning service.
PORT18789Port the agent process listens on inside the container. Must match the OpenClaw Gateway port. Set by the provisioning service.
HOME/home/nodeHome directory for the node user that the official OpenClaw image runs as
TERMxterm-256colorTerminal type
NODE_COMPILE_CACHE/var/tmp/openclaw-compile-cacheDirectory for the Node.js compile cache. Speeds up cold starts by caching compiled bytecode across process restarts.
OPENCLAW_NO_RESPAWN1When set to 1, prevents the OpenClaw process from automatically respawning after exit. Container-level restart policies (Docker --restart or orchestrator health checks) handle process recovery instead.
OPENCLAW_GATEWAY_TOKENAuto-generatedGateway authentication token. When not set, the entrypoint generates a 32-character hex token. See per-agent gateway authentication.
OPENCLAW_GATEWAY_URLPlatform URLGateway URL for the agent to communicate with the platform gateway. Set by the provisioning service.
OPENCLAW_GATEWAY_PORT18789Port the gateway listens on inside the container
OPENCLAW_GATEWAY_BIND0.0.0.0Bind address for the gateway process. Set to 0.0.0.0 so Railway (and other reverse proxies) can route traffic into the container.
OPENCLAW_BIND0.0.0.0Fallback bind address used when OPENCLAW_GATEWAY_BIND is not set.
AGENTBOT_USER_IDPer-userOwner user ID passed at provisioning time
AGENTBOT_PLANsoloSubscription plan tier (solo, collective, label, or network)
AGENTBOT_API_URLhttps://agentbot-api.onrender.comBackend API URL for the agent to call platform services. Set by the provisioning service.
AGENTBOT_MODEhomeInstallation mode (home for self-hosted, link for existing OpenClaw)
AGENTBOT_API_KEYPer-userAPI key for authenticating with the Agentbot platform
DATABASE_URLPlatform-providedPostgreSQL connection string for agent data persistence. Set by the provisioning service.
OPENROUTER_API_KEYPlatform-providedOpenRouter API key for AI model access. Set by the provisioning service.
INTERNAL_API_KEYPlatform-providedInternal API key for authenticating agent-to-platform requests. Set by the provisioning service.
WALLET_ENCRYPTION_KEYPlatform-providedEncryption key for securing agent wallet data at rest. Set by the provisioning service.

Gateway settings

ParameterValueDescription
gateway.bind0.0.0.0Bind address for the gateway. On Railway-provisioned containers, the OPENCLAW_GATEWAY_BIND environment variable is set to 0.0.0.0 so the gateway listens on all interfaces and Railway’s reverse proxy can route traffic into the container. For local Docker containers, the entrypoint overrides this to loopback via the --bind loopback CLI flag unless OPENCLAW_GATEWAY_BIND is set.
gateway.port18789Internal gateway port
gateway.auth.modetokenAuthentication mode
gateway.auth.rateLimit.maxAttempts10Maximum authentication attempts before lockout
gateway.auth.rateLimit.windowMs60000Rate limit window in milliseconds (1 minute)
gateway.auth.rateLimit.lockoutMs300000Lockout duration in milliseconds (5 minutes)
gateway.auth.rateLimit.exemptLoopbacktrueExempt loopback addresses from rate limiting
gateway.auth.allowTailscaletrueAllow Tailscale network connections
gateway.controlUi.enabledtrueGateway control UI is enabled in containers.

Tool settings

ParameterValueDescription
tools.profilemessaging or codingmessaging for solo plan, coding for all other plans
tools.deny["browser", "canvas"]Tools disabled in container environments
tools.exec.allowedCommandsArray of whitelisted commandsCommands the agent is permitted to execute (includes git, node, npm, python3, curl, ls, cat, grep, find, wget, mkdir, cp, mv, rm, echo, date, whoami, chmod, chown, touch, head, tail, wc, sort, uniq, awk, sed, tar, zip, unzip, docker, ps, df, du)
tools.exec.allowedPaths["~/.openclaw/workspace", "/tmp", "/home/node"]Filesystem paths the agent can access. The official OpenClaw image runs as the node user (/home/node). Configuration is stored at /home/node/.openclaw/openclaw.json.
tools.exec.denyPaths["/etc/shadow", "/etc/passwd", "/proc", "/sys"]Filesystem paths the agent is blocked from accessing
tools.web.maxChars50000Maximum characters returned from web tool requests
tools.loopDetection.maxIterations20Maximum loop iterations before the agent is interrupted
tools.loopDetection.windowMinutes5Time window for loop detection

Session settings

ParameterValueDescription
session.maxTokens100000Maximum tokens per session
session.compaction.strategyautoAutomatic context compaction strategy
session.compaction.triggerAtPercent80Compaction triggers when token usage reaches this percentage

Agent defaults

ParameterValueDescription
agents.defaults.workspace~/.openclaw/workspaceDefault workspace directory
agents.defaults.imageMaxDimensionPx1200Maximum image dimension in pixels (optimizes vision token usage)
agents.defaults.userTimezoneEurope/LondonDefault timezone (overridden by signup timezone when available)
agents.defaults.timeFormat24hTime format
agents.defaults.compaction.maxMessages200Maximum messages before compaction
agents.defaults.compaction.keepLastN20Number of recent messages preserved after compaction
agents.defaults.heartbeat.every30mSelf-monitoring heartbeat interval
agents.defaults.skipBootstrapfalseWhether to skip the bootstrap phase
agents.defaults.bootstrapMaxChars4000Maximum characters for bootstrap content

Health monitoring

The gateway monitors channel health for each agent container. When a channel becomes unresponsive, the gateway can automatically restart it.
ParameterValueDescription
channelHealthCheckMinutes5Interval between health checks for each channel
channelStaleEventThresholdMinutes30Channel is considered stale if no events are received within this window
channelMaxRestartsPerHour10Maximum number of automatic channel restarts per hour

CORS

The gateway supports CORS preflight via OPTIONS /api/v1/gateway. Allowed methods are GET, POST, and OPTIONS. The Content-Type, Authorization, X-Plugin-Id, and Payment headers are permitted in the CORS configuration.
The X-Payment-Method, X-Session-Id, and X-Wallet-Address headers are read server-side but are not included in the CORS Access-Control-Allow-Headers response. Cross-origin requests that include these headers may be rejected by the browser preflight check. Same-origin requests are unaffected. If you need to send these headers from a different origin, configure the GATEWAY_CORS_ORIGIN environment variable or proxy the request through a same-origin endpoint.

OpenAI-compatible endpoints

The gateway exposes a set of endpoints that follow the OpenAI API format. These allow you to use Agentbot as a drop-in replacement for the OpenAI SDK or any tool that supports the OpenAI API shape.

List models

GET /v1/models
Returns all available models in OpenAI-compatible format. This endpoint is public and does not require authentication.

Response (200)

{
  "object": "list",
  "data": [
    {
      "id": "openrouter/openai/gpt-4o-mini",
      "object": "model",
      "created": 1742472000,
      "owned_by": "openrouter"
    }
  ]
}

Model object

FieldTypeDescription
idstringModel identifier (provider-prefixed)
objectstringAlways model
creatednumberUnix timestamp of when the response was generated
owned_bystringProvider that serves the model (e.g., openrouter, agentbot)

Errors

StatusDescription
500Failed to fetch models — an internal error occurred while retrieving the model list

Retrieve a model

GET /v1/models/:model
Returns details for a single model by its ID. This endpoint is public and does not require authentication.

Path parameters

ParameterTypeRequiredDescription
modelstringYesThe model ID to look up (e.g., openrouter/openai/gpt-4o-mini)

Response (200)

{
  "id": "openrouter/openai/gpt-4o-mini",
  "object": "model",
  "created": 1742472000,
  "owned_by": "openrouter"
}

Errors

StatusDescription
404Model {model} not found — no model matches the provided ID
500Failed to fetch model — an internal error occurred

Create embeddings

POST /v1/embeddings
Generates embeddings for the given input. Proxies the request to OpenRouter. Requires authentication.

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token or session cookie
Content-TypestringYesMust be application/json

Request body

{
  "input": "The quick brown fox jumps over the lazy dog",
  "model": "openai/text-embedding-3-small"
}
FieldTypeRequiredDescription
inputstring or string[]YesText to generate embeddings for. Can be a single string or an array of strings.
modelstringNoEmbedding model to use. Defaults to openai/text-embedding-3-small.

Response (200)

The response follows the OpenAI embeddings format. The exact shape depends on the upstream provider.
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [0.0023064255, -0.009327292, ...]
    }
  ],
  "model": "openai/text-embedding-3-small",
  "usage": {
    "prompt_tokens": 9,
    "total_tokens": 9
  }
}

Errors

StatusDescription
400input is required — the input field is missing from the request body
401Unauthorized — valid authentication is required
503Embeddings not configured — the server does not have an OpenRouter API key configured
500Embeddings request failed — the upstream provider returned an error

Rate limits

EndpointLimit
/api/v1/gateway100/min
/v1/models120/min (general)
/v1/models/:model120/min (general)
/v1/embeddings120/min (general)

Examples

Route a request to the agent plugin (Stripe)

curl -X POST https://agentbot.raveculture.xyz/api/v1/gateway \
  -H "Content-Type: application/json" \
  -H "X-Plugin-Id: agent" \
  -H "Cookie: next-auth.session-token=YOUR_SESSION" \
  -d '{"messages": [{"role": "user", "content": "Summarize my tasks"}]}'

Route a request with MPP payment

curl -X POST https://agentbot.raveculture.xyz/api/v1/gateway \
  -H "Content-Type: application/json" \
  -H "X-Plugin-Id: generate-text" \
  -H "Authorization: Payment {\"scheme\":\"Payment\",\"transaction\":\"0x76...\",\"challengeNonce\":\"abc123\"}" \
  -d '{"messages": [{"role": "user", "content": "Hello"}]}'

Route a request with session-based billing

curl -X POST https://agentbot.raveculture.xyz/api/v1/gateway \
  -H "Content-Type: application/json" \
  -H "X-Plugin-Id: agent" \
  -H "X-Payment-Method: session" \
  -H "X-Session-Id: ses_a1b2c3d4e5f6..." \
  -H "X-Wallet-Address: 0xd8fd0e1dce89beaab924ac68098ddb17613db56f" \
  -d '{"messages": [{"role": "user", "content": "Summarize my tasks"}]}'
The response includes the remaining session balance:
Payment-Receipt: session:ses_a1b2c3d4e5f6...:v_abc123def456
X-Session-Remaining: 9.95

List available models (OpenAI-compatible)

curl https://agentbot.raveculture.xyz/v1/models

Retrieve a specific model

curl https://agentbot.raveculture.xyz/v1/models/openrouter/openai/gpt-4o-mini

Generate embeddings

curl -X POST https://agentbot.raveculture.xyz/v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"input": "Hello world", "model": "openai/text-embedding-3-small"}'