API · Gateway

Documentación REST

Autenticación, endpoints del gateway y arranque rápido con curl — mismo lenguaje visual que la home.

Base URL: https://api.agentflowhub.com

Authentication

All requests require an API key. Send it in one of these headers:

Authorization: Bearer afhub_live_abc123
# or
X-API-Key: afhub_live_abc123

Response Format

All responses include gateway metadata in headers:

X-Gateway: agentflow
X-Gateway-Plan: pro
X-Gateway-Latency: 142ms
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1711540800

Endpoints

Agent Farm

POST/gateway/agent-farmfree
GET/gateway/agent-farmfree

Agents CRUD

GET/gateway/agentsfree
GET/gateway/agents/:idfree
POST/gateway/agentspro
PUT/gateway/agents/:idpro

AI Models

POST/gateway/modelsfree
GET/gateway/modelsfree

Embeddings & RAG

POST/gateway/embeddings/embedpro
POST/gateway/embeddings/searchpro
POST/gateway/embeddings/uploadpro
POST/gateway/embeddings/ragpro
GET/gateway/embeddings/stats/:agentIdpro
GET/gateway/embeddings/files/:agentIdpro
DELETE/gateway/embeddings/filepro

Geoeconomics

POST/gateway/agent-farmfree

Health & Analytics

POST/gateway/analyze-healthfree
POST/gateway/analyze-plethysmographyfree

Quick Start

# 1. Get your API key from /dashboard

# 2. Execute an agent
curl -X POST https://api.agentflowhub.com/gateway/agent-farm \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"agent": "health-monitor", "input": {"spo2": 98, "heartRate": 72}}'

# 3. Generate embeddings
curl -X POST https://api.agentflowhub.com/gateway/embeddings/embed \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"texts": ["Water quality in rural areas"]}'

# 4. RAG query
curl -X POST https://api.agentflowhub.com/gateway/embeddings/rag \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"agentId": "AGENT_ID", "query": "What are the safe pH levels?"}'

# 5. Check your usage
curl https://api.agentflowhub.com/api/gateway/usage \
  -H "Authorization: Bearer YOUR_API_KEY"

Stripe — Setup de productos y precios

Comandos curl para crear los productos y precios de suscripción via API de Stripe. Reemplaza $SK con tu STRIPE_SECRET_KEY.

1. Crear producto Starter ($19/mes)
# Paso 1 — crear producto
PROD=$(curl -s https://api.stripe.com/v1/products \
  -u "$SK:" -d "name=Starter" | grep -o '"id": "prod_[^"]*"' | cut -d'"' -f4)

# Paso 2 — crear precio recurrente
curl -s https://api.stripe.com/v1/prices \
  -u "$SK:" \
  -d "product=$PROD" \
  -d "unit_amount=1900" \
  -d "currency=usd" \
  -d "recurring[interval]=month" \
  -d "nickname=Starter"
# → guarda el "id": "price_..." del response
2. Crear producto Growth ($49/mes)
PROD=$(curl -s https://api.stripe.com/v1/products \
  -u "$SK:" -d "name=Growth" | grep -o '"id": "prod_[^"]*"' | cut -d'"' -f4)

curl -s https://api.stripe.com/v1/prices \
  -u "$SK:" \
  -d "product=$PROD" \
  -d "unit_amount=4900" \
  -d "currency=usd" \
  -d "recurring[interval]=month" \
  -d "nickname=Growth"
3. Crear producto Business ($129/mes)
PROD=$(curl -s https://api.stripe.com/v1/products \
  -u "$SK:" -d "name=Business" | grep -o '"id": "prod_[^"]*"' | cut -d'"' -f4)

curl -s https://api.stripe.com/v1/prices \
  -u "$SK:" \
  -d "product=$PROD" \
  -d "unit_amount=12900" \
  -d "currency=usd" \
  -d "recurring[interval]=month" \
  -d "nickname=Business"
4. Verificar que los precios estén activos
curl -s https://api.stripe.com/v1/prices?active=true \
  -u "$SK:" | grep -E '"id"|"nickname"|"unit_amount"|"active"'
5. Actualizar .env con los price IDs
# En .env:
STRIPE_PRICE_STARTER=price_1TJMpV2dx33YwrpgWgTjdajP
STRIPE_PRICE_GROWTH=price_1TJMpj2dx33YwrpgGzX9mZ9J
STRIPE_PRICE_BUSINESS=price_1TJMpk2dx33YwrpgebJGEbUx

# Reiniciar servidor para que tome los nuevos valores
npm run dev

Widget API — chat embebido

Incrusta un widget de conversación en cualquier página HTML con el script y una llamada a AgentFlowhub.init.

<script src="https://hub.agentflowhub.com/widget.js"></script>
<script>
  window.AgentFlowhub.init({
    agentId: "YOUR_AGENT_ID",
    token: "YOUR_WIDGET_TOKEN",
    theme: "dark",
    position: "bottom-right"
  });
</script>