Pipeline de API: dar herramientas a tu oráculo

Índice: Pipelines de API — índice

Objetivo: dar herramientas a tu oráculo: describir tus propios endpoints HTTP como tarjetas y guardar como secretos las claves que necesitan, y luego conectar ambos a la agenda del oráculo.

Una tarjeta de endpoint de API es una llamada HTTP que el oráculo puede hacer; su operation_id es el nombre de la herramienta y su request_schema los argumentos. Un secreto guarda una clave; los endpoints lo referencian por nombre y el valor solo se rellena en el momento de la llamada.

Pasos

1. Guarda la clave.

POST /v0/my/secrets
Idempotency-Key: sec-0a9d…
{"key_name": "secret_shop_api_token", "value": "sk-example-123", "host": "api.example.com",
 "title": "Shop API token", "workspaces": ["470000000000000400"]}
→ {"nonce": "470000000000000410", "key_name": "secret_shop_api_token", "host": "api.example.com",
   "title": "Shop API token", "created_at": "…", …}

2. Describe el endpoint.

POST /v0/my/api_endpoints
Idempotency-Key: ep-77b3…
{"title": "Check order status", "content": "Returns the status of one order. Use when a customer asks where their order is.",
 "operation_id": "orders_status", "method": "GET",
 "path": "https://api.example.com/v1/orders/{id}",
 "request_schema": {"type": "object", "properties": {"id": {"type": "string"}}, "required": ["id"]}}
→ {"nonce": "470000000000000420", "card_type": "api_endpoint", …}

3. Conéctalo a la agenda. PATCH /v0/my/agendas/{agenda} {"api_endpoints": ["470000000000000420"], "secrets": ["470000000000000410"]} — cada lista reemplaza la anterior. Pipeline de API: escribir una agenda para tus oráculos

4. Gestionar.

En segundo plano

Reglas

Superficie de la API

Endpoint Para qué FE IA / oráculo
POST /v0/my/secrets, PATCH/DELETE /v0/my/secrets/{nonce} Guardar, editar, quitar una clave sí sí
GET /v0/my/secrets Tus claves (sin valores) sí sí
POST /v0/my/api_endpoints, PATCH/DELETE /v0/my/api_endpoints/{nonce} Describir una herramienta sí sí
GET /v0/my/api_endpoints, GET /v0/graph/api_endpoints (+ /{nonce}) Los tuyos, los públicos sí sí
PATCH /v0/my/agendas/{ident} (api_endpoints, secrets) Conectar a una agenda sí sí

Mentioned